Did you debug the array holding the weapon ids in the kill-event and in the respawn function?
Your for loop is wrong (
for(new i = 1; i <= g_iMaxPlayers; i++) ), have another look at my example. Stripping the players weapon is enough, you dont need to give him a knife, as tat would give him the knife twice (because it's already included in the weapons-array), then, you are not destroying the menus in the handler sometimes.
Edit: Btw, you are saving the killers weapons and not the victims...
Edit2: Both of you guys do the bpammo thing wrong; take this as a base and add your origin stuff:
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <fun>
#include <cstrike>
new iWeapons[33][32]
new iWeaponBackPack[33][32]
new iDeadOrigin[33][3]
public plugin_init()
{
RegisterHam(Ham_Killed, "player", "eventPlayerKilled", false)
}
public eventPlayerKilled(id)
{
new iNum
get_user_weapons(id, iWeapons[id], iNum)
for(new i = 0; i < iNum; i++)
{
if(iWeapons[id][i])
{
if(iWeapons[id][i] != CSW_KNIFE)
{
iWeaponBackPack[id][i] = cs_get_user_bpammo(id, iWeapons[id][i])
}
}
else
{
break
}
}
get_user_origin(id, iDeadOrigin[id])
new menu = menu_create("Respawn ?", "menuRespawnHandler")
menu_additem(menu, "Yes")
menu_additem(menu, "No")
menu_display(id, menu)
}
public menuRespawnHandler(id, menu, item)
{
if(!is_user_connected(id) || is_user_alive(id))
{
menu_destroy(menu)
return PLUGIN_HANDLED
}
if(item == 0)
{
ExecuteHamB(Ham_CS_RoundRespawn, id)
set_user_origin(id, iDeadOrigin[id])
new szWeaponName[45]
for(new i = 0; i < 32; i++)
{
if(iWeapons[id][i])
{
if(iWeapons[id][i] == CSW_KNIFE)
{
give_item(id, "weapon_knife")
}
else
{
get_weaponname(iWeapons[id][i], szWeaponName, charsmax(szWeaponName))
give_item(id, szWeaponName)
cs_set_user_bpammo(id, iWeapons[id][i], iWeaponBackPack[id][i])
}
}
else
{
break
}
}
}
arrayset(iWeapons[id], 0, 32)
arrayset(iWeaponBackPack[id], 0, 32)
menu_destroy(menu)
return PLUGIN_HANDLED
}
Note: You could avoid useless loop cycles using break when iWeapons[id][i] == 0...
Edit3: Added the origin stuff and testet, should work o.k.