Hello, I have encountered a problem, once in an ~hour, it throws an error in errorlog, which goes as follow:
PHP Code:
L 08/11/2020 - 08:39:03: Start of error session.
L 08/11/2020 - 08:39:03: Info (map "zm_kancl3r") (file "addons/amxmodx/logs/error_20200811.log")
L 08/11/2020 - 08:39:03: [AMXX] Displaying debug trace (plugin "biohazard.amxx", version "1")
L 08/11/2020 - 08:39:03: [AMXX] Run time error 4: index out of bounds
L 08/11/2020 - 08:39:03: [AMXX] [0] biohazard.sma::equipweapon (line 1726)
L 08/11/2020 - 08:39:03: [AMXX] [1] biohazard.sma::action_sec (line 1432)
L 08/11/2020 - 10:10:25: Start of error session.
L 08/11/2020 - 10:10:25: Info (map "zm_infantry") (file "addons/amxmodx/logs/error_20200811.log")
L 08/11/2020 - 10:10:25: [AMXX] Displaying debug trace (plugin "biohazard.amxx", version "1")
L 08/11/2020 - 10:10:25: [AMXX] Run time error 4: index out of bounds
L 08/11/2020 - 10:10:25: [AMXX] [0] biohazard.sma::equipweapon (line 1706)
L 08/11/2020 - 10:10:25: [AMXX] [1] biohazard.sma::action_prim (line 1414)
Since there are 3d arrays and I'm confused just by looking at it, I would request a tip on how to fix this, below I attach needed code:
equipweapon:
PHP Code:
stock equipweapon(id, weapon)
{
if(!is_user_alive(id))
return
static weaponid[2], weaponent
if(weapon & EQUIP_PRI)
{
weaponent = fm_lastprimary(id)
weaponid[1] = get_weaponid(g_primaryweapons[g_player_weapons[id][0]][1])
if(pev_valid(weaponent))
{
weaponid[0] = fm_get_weapon_id(weaponent)
if(weaponid[0] != weaponid[1])
fm_strip_user_gun(id, weaponid[0])
}
else
weaponid[0] = -1
if(weaponid[0] != weaponid[1])
fm_give_item(id, g_primaryweapons[g_player_weapons[id][0]][1])
fm_set_user_bpammo(id, weaponid[1], g_weapon_ammo[weaponid[1]])
}
if(weapon & EQUIP_SEC)
{
weaponent = fm_lastsecondry(id)
weaponid[1] = get_weaponid(g_secondaryweapons[g_player_weapons[id][1]][1])
if(pev_valid(weaponent))
{
weaponid[0] = fm_get_weapon_id(weaponent)
if(weaponid[0] != weaponid[1])
fm_strip_user_gun(id, weaponid[0])
}
else
weaponid[0] = -1
if(weaponid[0] != weaponid[1])
fm_give_item(id, g_secondaryweapons[g_player_weapons[id][1]][1])
fm_set_user_bpammo(id, weaponid[1], g_weapon_ammo[weaponid[1]])
}
if(weapon & EQUIP_GREN)
fm_give_item(id, "weapon_hegrenade")
}
action_prim:
PHP Code:
public action_prim(id, menu, item)
{
if(item == MENU_EXIT)
menu_destroy(menu)
if(!is_user_alive(id) || g_zombie[id])
return PLUGIN_HANDLED
g_player_weapons[id][0] = item
equipweapon(id, EQUIP_PRI)
display_weaponmenu(id, MENU_SECONDARY)
return PLUGIN_HANDLED
}
action_sec:
PHP Code:
public action_sec(id, menu, item)
{
if(item == MENU_EXIT)
menu_destroy(menu)
if(!is_user_alive(id) || g_zombie[id])
return PLUGIN_HANDLED
g_menufailsafe[id] = false
g_player_weapons[id][1] = item
equipweapon(id, EQUIP_SEC)
equipweapon(id, EQUIP_GREN)
return PLUGIN_HANDLED
}
and the aforementioned arrays:
PHP Code:
new g_primaryweapons[][][] =
{
{ "M4A1", "weapon_m4a1" },
{ "AK47", "weapon_ak47" },
{ "AWP", "weapon_awp" },
{ "AUG", "weapon_aug" },
{ "SG552", "weapon_sg552" },
{ "Galil", "weapon_galil" },
{ "Famas", "weapon_famas" },
{ "MP5 Navy", "weapon_mp5navy" },
{ "P90", "weapon_p90" },
{ "M3", "weapon_m3" },
{ "XM1014", "weapon_xm1014" }
}
new g_secondaryweapons[][][] =
{
{ "Glock", "weapon_glock18" },
{ "USP", "weapon_usp" },
{ "Deagle", "weapon_deagle" },
{ "P228", "weapon_p228" },
{ "Elite", "weapon_elite" }
}
new const g_weapon_ammo[] =
{
-1, 52, -1, 90, 1, 32,
1, 100, 90, 1, 120, 100,
100, 90, 90, 90, 100, 120,
30, 120, 200, 32, 90, 120,
90, 2, 35, 90, 90, -1, 100
}
Any ideas? I tried to make the g_weapon_ammo an 2d array and despite lack of errorlogs, server crashed sometime... Thanks for reading, cheers ;d.