Код за потвърждение: Избери целия код
#include <amxmodx>
#include <cstrike>
#include <engine>
#include <customshop>
#define Sound "misc/teleport.wav"
#define PLUGIN_VERSION "4.x"
additem ITEM_VENGEANCE
new p_iHealth, p_Sound, p_szPrefix
new g_szPrefix[32]
new bool: bHasItem[33]
public plugin_init()
{
register_plugin("CSHOP: Vengeance", PLUGIN_VERSION, "OciXCrom")
register_event("Health", "Event_Health", "be")
p_iHealth = register_cvar("vengeance_health", "50")
p_Sound = register_cvar("vengeance_sound", "1")
new iEnt = create_entity("info_target")
entity_set_string(iEnt, EV_SZ_classname, "show_infomsg_entity")
}
public plugin_precache()
{
precache_sound(Sound)
ITEM_VENGEANCE = cshop_register_item("vengeance", "TeleportBase -Health", 3000, 0)
}
public cshop_item_selected(id, iItem)
{
if(iItem == ITEM_VENGEANCE)
{
if(bHasItem[id])
{
client_print(id, print_chat, "%s You already have this item.", g_szPrefix)
return DONT_BUY
}
else
bHasItem[id] = true
}
return BUY_ITEM
}
public Clcmd_Vengeance(id)
{
new iMoney = cshop_get_item_data(ITEM_VENGEANCE, CSHOP_DATA_PRICE);
get_pcvar_string(p_szPrefix, g_szPrefix, charsmax(g_szPrefix))
if(bHasItem[id])
{
client_print(id, print_chat, "%s You already have this item!", g_szPrefix)
}
else if(iMoney < 0)
{
client_print(id, print_chat, "%s You don't have enough money to buy this item!", g_szPrefix)
}
else if(!is_user_alive(id))
{
client_print(id, print_chat, "%s You must be alive to buy this item!", g_szPrefix)
}
else
{
cs_set_user_money(id, iMoney)
client_print(id, print_chat, "%s At low health you'll be teleported in your base", g_szPrefix)
bHasItem[id] = true
}
}
public client_connect(id)
{
bHasItem[id] = false
}
public client_disconnect(id)
{
bHasItem[id] = false
}
public Event_Health(id)
{
new iHealth = read_data(1)
if(iHealth <= get_pcvar_num(p_iHealth) && bHasItem[id])
{
Teleport(id)
}
}
public Teleport(id)
{
if(is_user_alive(id))
{
new iPoint
switch(cs_get_user_team(id))
{
case 1:iPoint = find_ent_by_class(-1, "info_player_deathmatch")
case 2:iPoint = find_ent_by_class(-1, "info_player_start")
}
if(iPoint)
{
new Float: iOrigin[3]
entity_get_vector(iPoint, EV_VEC_origin, iOrigin)
entity_set_origin(id, iOrigin)
if(get_pcvar_num(p_Sound) == 1)
client_cmd(id, "spk %s", Sound)
bHasItem[id] = false
}
}
}