I'm not positive, but I believe it could be that there aren't two people on the server - one with a glock and one with a usp. Plus, ResetHUD occurs at user spawn or at the very end of the round (at least that's my understanding of it). I could be wrong of cours, but I would try this:
Code:
#include <amxmodx>
#include <fun>
#include <cstrike>
new givedeagle = 0;
new g_szWeapon[] = //our weapon category
{
"weapon_glock18",
"weapon_usp"
}
public plugin_init()
{
register_plugin("Drop&Give", "1.0", "PandaGirl")
register_event("ResetHUD", "spawned", "b")
new mapname[33]
get_mapname(mapname,32)
if(containi(mapname,"fy_") > -1 )
{
givedeagle = 1;
}
}
public spawned(id)
{
if(givedeagle == 1) //no if(user_is_alive(id)) is needed since this is at spawn event
{
set_task(0.5, "give_it", id) //just so it doesn't clutter the event
}
}
public give_it(id)
{
client_cmd(id, "drop", g_szWeapon) //drops either of the weapons in our weapon category
give_item(id, "weapon_deagle")
cs_set_user_bpammo(id, CSW_DEAGLE, 56)
return PLUGIN_CONTINUE
}
Optionally you can try this, but I think the first one shoudl work:
Code:
#include <amxmodx>
#include <fun>
#include <cstrike>
#define MAX_SECONDARY 2
new g_szWeapon[MAX_SECONDARY][] = //our weapon category
{
"weapon_glock18",
"weapon_usp"
}
new givedeagle = 0;
new bool:g_bSecondary[33];
//--------------------------------------------------------------------------------
public plugin_init()
{
register_plugin("Drop&Give", "1.0", "PandaGirl")
register_event("ResetHUD", "spawned", "b")
register_event("CurWeapon", "Check_Weapon", "be", "2!0")
new mapname[33]
get_mapname(mapname,32)
if(containi(mapname,"fy_") > -1 )
{
givedeagle = 1;
}
}
//--------------------------------------------------------------------------------
public Check_Weapon(id) //checks if they have either weapon
{
new clip, ammo, weapon = get_user_weapon(id,clip,ammo);
new szWeapName[33];
get_weaponname(weapon, szWeapName, 32);
g_bSecondary[id] = false;
for(new i = 0; i < MAX_SECONDARY; i++)
{
if(equali(szWeapName, g_szWeapon[i]))
g_bSecondary[id] = true;
}
if(!g_bSecondary[id])
{
for(new i = 0; i < MAX_SECONDARY; i++)
{
if(equali(szWeapName, g_szWeapon[i]))
client_cmd(id, "%s", g_szWeapon[i])
return PLUGIN_CONTINUE
}
}
return PLUGIN_CONTINUE
}
//--------------------------------------------------------------------------------
public spawned(id)
{
if(givedeagle == 1) //no if(user_is_alive(id)) is needed since this is at spawn event
{
set_task(0.5, "give_it", id) //just so it doesn't clutter the event
}
}
//--------------------------------------------------------------------------------
public give_it(id)
{
client_cmd(id, "drop", g_szWeapon) //drops either of the weapons in our weapon category
give_item(id, "weapon_deagle")
cs_set_user_bpammo(id, CSW_DEAGLE, 56)
return PLUGIN_CONTINUE
}