Code:
register_forward(FM_EmitSound, "EmitSound");
register_clcmd("/nade", "buy_nade");
public buy_nade(id) {
if(!get_pcvar_num(pcvar[CMOD])) {
client_print(id, print_chat, "SuperNade Disabled by Admin, sry :(");
return PLUGIN_HANDLED;
}
if(!is_user_alive(id) || !is_user_connected(id)) {
client_print(id, print_chat, "You must be alive to buy a SuperNade!");
return PLUGIN_HANDLED;
}
if(cs_get_user_team(id) == CS_TEAM_SPECTATOR || cs_get_user_team(id) == CS_TEAM_UNASSIGNED) {
client_print(id, print_chat, "You must be on a team to buy a SuperNade!");
return PLUGIN_HANDLED;
}
if(HasSuperNade[id-1]) {
client_print(id, print_chat, "You already have a supernade!");
return PLUGIN_HANDLED;
}
if(cs_get_user_money(id) < get_pcvar_num(pcvar[CCOST])) {
client_print(id, print_chat, "You cant afford to buy a SuperNade! It cost: %i", get_pcvar_num(pcvar[CCOST]));
return PLUGIN_HANDLED;
}
cs_set_user_money(id, cs_get_user_money(id)-get_pcvar_num(pcvar[CCOST]), 1);
new wpnids[32], num;
get_user_weapons(id, wpnids, num);
new bool:has;
for(new i = 0; i < num; i++) {
if(wpnids[i] == CSW_HEGRENADE) {
has = true;
}
}
if(!has) {
give_nade(id);
}
HasSuperNade[id-1] = true;
client_print(id, print_chat, "You now hold a SuperNade...be careful!!");
return PLUGIN_HANDLED;
}
public EmitSound(entity, channel, const sound[]) {
if(!get_pcvar_num(pcvar[CMOD]))
return FMRES_IGNORED;
if(!pev_valid(entity))
return FMRES_IGNORED;
if(contain(sound, "debris") == -1)
return FMRES_IGNORED;
new Float:origin[3], owner;
pev(entity, pev_origin, origin);
owner = pev(entity, pev_owner);
//extend the nade's range
if(!HasSuperNade[owner])
return FMRES_IGNORED;
HasSuperNade[owner] = false;
extend_range(origin);
if(!Planted)
return FMRES_IGNORED;
//search entities around the nade explosion
new ent = -1
while((ent = engfunc(EngFunc_FindEntityInSphere, ent, origin, get_pcvar_float(pcvar[CRADIUS]))) != 0) {
if(!pev_valid(ent))
continue
//get classname of entity
static Classname[33]
pev(ent, pev_classname, Classname, 32)
//make sure is grenade entity, and is the c4 grenade
if(!equal(Classname,g_Classname) || fm_cs_get_grenade_type(ent) != CSW_C4)
continue
set_pdata_float(ent, 100, 0.0); //makes the c4 entity explode
}
return FMRES_IGNORED;
}
Now when I am in the server by myself and I type /buy in chat my id is returned as "1", I know this because I had many client prints telliing me everything that was happening during testing, but later when I throw it, and pev() gets the owner, my id is returned as "0". so to remedy this problem I did HasSuperNade[id-1] = true; on buy function and it works fine, if I am only person in server. If others are tho, the person with id=1 can buy multiple nades per round, but everyone else cant, it isnt setting false correctly on them, what is the problem?