View Single Post
Author Message
asdian
Member
Join Date: Sep 2016
Location: Indonesia
Old 08-14-2022 , 08:41   Console Keeps Saying Index Out of Bounds
Reply With Quote #1

I am remaking my old weapon plugin with new system, that is merging them into one single plugin. That's pretty hard for me, really X'D and now i'm facing this problem. Console keeps saying "index out of bounds" and i dont know which one. I have checked many times but still couldn't find the problem.

Error code :

Code:
L 08/14/2022 - 19:29:26: [AMXX] Displaying debug trace (plugin "zp_skull_weapon_all_v3.amxx", version "3.0")
L 08/14/2022 - 19:29:26: [AMXX] Run time error 4: index out of bounds 
L 08/14/2022 - 19:29:26: [AMXX]    [0] zp_skull_weapon_all_v3.sma::IsHaveSkull (line 1043)
L 08/14/2022 - 19:29:26: [AMXX]    [1] zp_skull_weapon_all_v3.sma::HamF_ItemDeploy_Post (line 796)
The code :

Code:
#define TOTAL_SKULL 9

enum _:WhichSkull
{
	IS_SK1 = 0,
	IS_SK3,
	IS_SK4,
	IS_SK5,
	IS_SK6,
	IS_SK7,
	IS_SK8,
	IS_SK9,
	IS_SK11
}

new g_had_wpnskull[33][TOTAL_SKULL]


public HamF_ItemDeploy_Post(ent)
{
	if(!pev_valid(ent))
		return
	
	static id, ActiveSlot
	id = pev(ent, pev_owner)
	ActiveSlot = ExecuteHam(Ham_Item_ItemSlot, ent)
	
	if(!IsHaveSkull(id, SLOT_PRI) || !IsHaveSkull(id, SLOT_SEC)) // -> Line 796
		return 
		
	static iCsWpnPri, iCsWpnPri2, iCsWpnSec, iCSW;
	iCSW = get_pdata_int(ent,43,4)
	iCsWpnPri = Get_SkullCSW(id, SLOT_PRI)
	iCsWpnPri2 = Get_SkullCSW(id, SLOT_PRI, 1)
	iCsWpnSec = Get_SkullCSW(id, SLOT_SEC)
	
	set_pev(id, pev_viewmodel2, V_MODEL_SKULL[ActiveSlot == 1 ? g_type1[id] : g_type2[id]])
	set_pev(id, pev_weaponmodel2, P_MODEL_SKULL[ActiveSlot == 1 ? g_type1[id] : g_type2[id]])
	
	set_weapon_anim(id, Get_SkullDeployAnim(id, ActiveSlot))
	set_nextattack(ent, id, Get_SkullDeployTime(id, ActiveSlot))
	
	if(ActiveSlot == SLOT_PRI && g_had_wpnskull[id][IS_SK3])
	{
		if(iCSW == iCsWpnPri2)
		{
			g_skull3_changing[id] = !g_skull3_mode[id]
			set_weapon_anim(id, g_skull3_mode[id] ? ANIM_DRAW_B : ANIM_CHANGE_TO_B)
			set_nextattack(ent, id, g_skull3_mode[id] ? 1.0 : 3.03)
		} else if(iCSW == iCsWpnPri) {
			g_skull3_changing[id] = g_skull3_mode[id]
			set_weapon_anim(id, g_skull3_mode[id] ? ANIM_CHANGE_TO_A : ANIM_DRAW_A)
			set_nextattack(ent, id, g_skull3_mode[id] ? 3.03 : 1.0)
		}
	}
}

public IsHaveSkull(id, ActiveSlot)
{
	if(ActiveSlot == SLOT_PRI && g_had_wpnskull[id][IS_SK3]) return 1 // -> Line 1043
	if(ActiveSlot == SLOT_SEC && g_had_wpnskull[id][IS_SK1]) return 1
	return 0
}
What do you guys think is the problem?

PS. ignore the mess please, still WIP
Attached Files
File Type: sma Get Plugin or Get Source (zp_skull_weapon_all_v3.sma - 74 views - 48.7 KB)

Last edited by asdian; 02-09-2023 at 19:27.
asdian is offline