Gah I'm really angry right now, because I've been making a simple* mind you simple plugin that redistributes weapons back to players on join.
Now I've tried setting tasks with "task_exists" and even global variables for stops....no matter what it always EXECUTES TWICE!?!?!?!? W#%(*@#(@$@(%#)$%
I've been working with this for over 2 hours and I'm really annoyed at this point.
Code:
public client_authorized(id)
{
give_weapons(id+6500)
}
public give_weapons(id)
{
id -= 6500
if(g_weapon_hold[id] == 1) return PLUGIN_HANDLED
if(!is_user_connected(id) && !is_user_connecting(id))
{
remove_task(id+6500)
return PLUGIN_HANDLED
}
if(!is_user_alive(id))
{
//client_print(id,print_chat,"[WeaponSave] You have weapons pending. Please spawn immediately for re-distribution.")
set_task(5.0,"give_weapons",id+6500)
return PLUGIN_HANDLED
}
if(g_weapon_hold[id] == 1) return PLUGIN_HANDLED
g_weapon_hold[id] = 1
format(g_Query[id],QUERY_MAX_USER-1,"SELECT WID,WClip,WAmmo,WMode,WAddons,WAddons_Active FROM users_weapons WHERE SteamID='%s'",g_SteamIDS[id])
result = dbi_query(dbc,"%s",g_Query[id])
if(dbi_nextrow(result) > 0)
{
new wid, clip, ammo, mode, extras, extras_active
new num_rows = dbi_num_rows(result)
for(new i=0; i < num_rows;i++)
{
wid = dbi_field(result,1)
clip = dbi_field(result,2)
ammo = dbi_field(result,3)
mode = dbi_field(result,4)
extras = dbi_field(result,5)
extras_active = dbi_field(result,6)
client_print(id,print_console,"WID: %i",wid)
ts_giveweapon(id,wid,clip,extras)
dbi_nextrow(result)
}
client_cmd(id,"weapon_0")
}
dbi_free_result(result)
server_print("GIVEN")
g_weapon_hold[id] = 1
return PLUGIN_HANDLED
}
Can anyone help me? Thanks.
__________________