PHP Kod:
cost_cvar = register_cvar("RB_Cost","0")
Yada bu eklentiyi deneyin
PHP Kod:
#define VERSION "2.1"
#define TAG "^4[Red Bull]"
#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <cstrike>
new bool:has_rb[33]
new g_cost
new Float:g_duration
new Float:g_speed
new g_max_hp
new g_hp_regen
new Float:g_gravity
new pcvar_cost
new pcvar_duration
new pcvar_speed
new pcvar_max_hp
new pcvar_hp_regen
new pcvar_gravity
new g_maxplayers
enum _:TASK_IDS
{
TASK_DURATION = 100,
TASK_HP_REGEN = 200
}
public plugin_init()
{
register_plugin("Red Bull", VERSION, "GHW_Chronic")
register_clcmd("say /redbull", "say_cmd_handle")
register_clcmd("say /rb", "say_cmd_handle")
pcvar_cost = register_cvar("rbi_cost", "2500")
pcvar_duration = register_cvar("rbi_duration", "20.0")
pcvar_speed = register_cvar("rbi_speed", "400.0")
pcvar_max_hp = register_cvar("rbi_max_hp", "150")
pcvar_hp_regen = register_cvar("rbi_hp_regen", "1")
pcvar_gravity = register_cvar("rbi_gravity", "0.5")
register_clcmd("rbi_reload", "cmd_reload_cvars", ADMIN_RCON, "Reload RB cvars")
register_event("CurWeapon", "curweap", "be")
register_event("DeathMsg", "event_death", "a")
register_dictionary("GHW_Red_Bull.txt")
g_maxplayers = get_maxplayers()
}
public plugin_cfg()
{
cache_cvars()
}
public cmd_reload_cvars(id, level, cid)
{
if(!cmd_access(id, level, cid, 1))
return PLUGIN_HANDLED
cache_cvars()
colored_print(id, "%s ^1CVAR degerleri yenilendi!", TAG)
client_print(id, print_console, "[RB] Cost: %d", g_cost)
client_print(id, print_console, "[RB] Duration: %.1f", g_duration)
client_print(id, print_console, "[RB] Speed: %.1f", g_speed)
client_print(id, print_console, "[RB] Max HP: %d", g_max_hp)
client_print(id, print_console, "[RB] HP Regen: %d", g_hp_regen)
client_print(id, print_console, "[RB] Gravity: %.2f", g_gravity)
return PLUGIN_HANDLED
}
cache_cvars()
{
g_cost = get_pcvar_num(pcvar_cost)
g_duration = get_pcvar_float(pcvar_duration)
g_speed = get_pcvar_float(pcvar_speed)
g_max_hp = get_pcvar_num(pcvar_max_hp)
g_hp_regen = get_pcvar_num(pcvar_hp_regen)
g_gravity = get_pcvar_float(pcvar_gravity)
}
public curweap(id)
{
if(is_user_alive(id) && has_rb[id])
{
set_user_maxspeed(id, g_speed)
}
}
public event_death()
{
new victim = read_data(2)
if(victim < 1 || victim > g_maxplayers)
return
if(has_rb[victim])
reset_redbull(victim)
}
public client_connect(id)
has_rb[id] = false
public client_disconnect(id)
reset_redbull(id)
public say_cmd_handle(id)
{
if(!is_user_alive(id))
{
colored_print(id, "%s ^1%L", TAG, id, "MSG_NOBUY_DEAD")
return PLUGIN_HANDLED
}
if(has_rb[id])
{
colored_print(id, "%s ^1%L", TAG, id, "MSG_NOBUY_HAVE")
return PLUGIN_HANDLED
}
if(cs_get_user_money(id) < g_cost)
{
colored_print(id, "%s ^1%L", TAG, id, "MSG_NOBUY_POOR", g_cost)
return PLUGIN_HANDLED
}
cs_set_user_money(id, cs_get_user_money(id) - g_cost, 1)
has_rb[id] = true
set_task(g_duration, "redbull_over", id + TASK_DURATION)
set_task(1.0, "plus_hp", id + TASK_HP_REGEN, "", 0, "b")
set_user_gravity(id, g_gravity)
set_user_maxspeed(id, g_speed)
colored_print(id, "%s ^3%L", TAG, id, "MSG_REDBULL1")
colored_print(id, "%s ^3%L", TAG, id, "MSG_REDBULL2")
return PLUGIN_HANDLED
}
public plus_hp(taskid)
{
new id = taskid - TASK_HP_REGEN
if(id < 1 || id > g_maxplayers)
{
remove_task(taskid)
return
}
if(!is_user_alive(id) || !has_rb[id])
{
reset_redbull(id)
return
}
new current_hp = get_user_health(id)
if(current_hp < g_max_hp)
set_user_health(id, min(current_hp + g_hp_regen, g_max_hp))
}
public redbull_over(taskid)
{
new id = taskid - TASK_DURATION
if(id < 1 || id > g_maxplayers)
return
if(!is_user_connected(id))
return
reset_redbull(id)
colored_print(id, "%s ^1%L", TAG, id, "MSG_REDBULL_OFF")
}
reset_redbull(id)
{
if(!has_rb[id])
return
has_rb[id] = false
remove_task(id + TASK_DURATION)
remove_task(id + TASK_HP_REGEN)
if(is_user_alive(id))
set_user_gravity(id, 1.0)
}
stock colored_print(id, const msg[], any:...)
{
new buffer[192]
vformat(buffer, charsmax(buffer), msg, 3)
message_begin(MSG_ONE, get_user_msgid("SayText"), _, id)
write_byte(id)
write_string(buffer)
message_end()
}
PHP Kod:
rbi_cost 5000
rbi_duration 30.0
rbi_speed 500.0
rbi_max_hp 200
rbi_hp_regen 2
rbi_gravity 0.3
)

