I'm trying to make a plugin that does the following:
Gives ammo to killer. (Not sure if it is correctly done)
Gives weapon + ammo when you spawn, weapon and ammo is different depending on mapname.
Is it correct to check mapname in plugin init?
Thank you very much.
I'm getting these errors:
Quote:
ERROR [28]: array index out of bounds (variable "mapname")
ERROR [30]: array index out of bounds (variable "weapon")
ERROR [31]: array index out of bounds (variable "ammo")
Also you can carry two primary weapons.
And if it is possible I would like to remove the weapons that are dropped to reduce CPU usage.
|
Code:
new mapname[31]
new weapon[31]
new ammo[31]
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
RegisterHam(Ham_Spawn, "player", "fwHamPlayerSpawnPost", 1)
register_event("DeathMsg", "AmmoOnKill", "a")
register_cvar("gn_impulse", "0")
checkMapName()
}
public checkMapName()
{
get_mapname(mapname,31)
if (mapname[31] == "aim_map_tmp")
{
weapon[31] = "weapon_tmp"
ammo[31] = "ammo_9mm"
}
else
{
weapon[31] = "weapon_ak47"
ammo[31] = "CSW_SCOUT"
}
}
public fwHamPlayerSpawnPost(id)
{
if (!get_cvar_num("gn_impulse"))
{
if (mapname[31] == "aim_map_usp" && is_user_alive(id))
{
client_cmd(id, "lastinv")
}
else if (is_user_alive(id))
{
giveWeapons(id)
}
}
return PLUGIN_CONTINUE
}
public giveWeapons(id)
{
cs_set_user_armor(id, 100, CS_ARMOR_KEVLAR)
give_item(id, weapon[31])
cs_set_user_bpammo(id, ammo[31], 90)
}
public AmmoOnKill()
{
new killer = read_data( 1 ), szWp[5];
read_data(4, szWp, charsmax(szWp))
if (killer > 0 && killer != read_data(2) && equal(szWp, "usp", 3))
{
cs_set_weapon_ammo(find_ent_by_owner(-1,"weapon_usp",killer),12)
}
if (killer > 0 && killer != read_data(2) && equal(szWp, "ak47", 3))
{
cs_set_weapon_ammo(find_ent_by_owner(-1,"weapon_ak47",killer),30)
}
}
__________________