I'm making a HS mod for scoutzknivez (counterstrike) and am having a little difficulty with catching the start of a round. What this plugin does so far is removes the knife, restarts the round and then on the beginning of every round *should* give scout with 100 bullets and deagle with 0 bullets. What actually happens is that this procedure works for most people for about 10 rounds and then randomly stops giving deagle and scout ammo.
Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <engine>
#include <fun>
#include <fakemeta>
#define recheck_time 10.0
#define hs_task 34
#define all_zones_time 30.0
#define check_round_time 1.5
new dev_anti = 1
new Float:max_interp = 0.05
new hs_mode = 0
new knife_mode = 0
public plugin_init()
{
register_plugin("scoutz_suite","1.1","iQuizzle")
register_concmd("amx_hs","set_hsmode",ADMIN_KICK,"sets headshot mode: 0=off, 1=on")
}
public set_hsmode(id,level,cid)
{
if (!cmd_access(id,level,cid,2))
return PLUGIN_HANDLED
new hs_arg[5]
read_argv(1,hs_arg,4)
if (!(hs_mode==str_to_num(hs_arg)))
{
hs_mode = str_to_num(hs_arg)
if (hs_mode==1)
{
set_user_hitzones(0 ,0, 2)
cs_set_no_knives(1)
set_cvar_num("sv_restart",2)
client_print(0,print_chat,"**[SS] Scoutz HS Mod Enabled**")
}
else
{
set_user_hitzones(0 ,0, 255)
cs_set_no_knives(0)
set_cvar_num("sv_restart",2)
client_print(0,print_chat,"**[SS] Scoutz HS Mod Disabled**")
}
}
return PLUGIN_HANDLED
}
public enable_zones()
{
client_print(0,print_chat,"**[SS] All Hitzones Enabled!**")
client_print(0,print_chat,"**[SS] All Hitzones Enabled!**")
set_user_hitzones(0 ,0, 255)
//cs_set_no_knives(0)
}
public check_round()
{
new players[32], num
get_players(players, num)
new id
if(hs_mode==1)
{
set_user_hitzones(0 ,0, 2)
//cs_set_no_knives(1)
for (new i = 0; i < num; i++)
{
id = players[i]
give_item(id,"weapon_scout")
new sct = find_ent_by_owner(-1,"weapon_scout",id)
cs_set_weapon_ammo(sct,100)
give_item(id,"weapon_deagle")
new pist1 = find_ent_by_owner(-1,"weapon_deagle",id)
cs_set_weapon_ammo(pist1,0)
}
if(task_exists(hs_task))
remove_task(hs_task)
set_task(all_zones_time, "enable_zones",hs_task)
client_print(0,print_chat,"**[SS] Headshot Mod is currently in use** say /a for more ammo")
}
else
{
set_user_hitzones(0 ,0, 255)
cs_set_no_knives(0)
}
}
public event_newround()
{
set_task(check_round_time, "check_round")
}
public hs_ammo(id)
{
if(hs_mode==1)
{
give_item(id,"weapon_scout")
new sct = find_ent_by_owner(-1,"weapon_scout",id)
cs_set_weapon_ammo(sct,100)
give_item(id,"weapon_deagle")
new pist1 = find_ent_by_owner(-1,"weapon_deagle",id)
cs_set_weapon_ammo(pist1,0)
}
}
there's more in the plugin, but i trimmed out the stuff that wasn't relevant.