AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Solved [Help] Exception reported: Array index out-of-bounds (https://forums.alliedmods.net/showthread.php?t=313099)

Dr.Mohammad 12-28-2018 08:24

[Help] Exception reported: Array index out-of-bounds
 
hi guys!
i have a problem:
HTML Code:

L 12/28/2018 - 13:41:26: SourceMod error session started
L 12/28/2018 - 13:41:26: Info (map "dz_blacksite") (file "errors_20181228.log")
L 12/28/2018 - 13:41:26: [SM] Exception reported: Array index out-of-bounds (index 9, limit 9)
L 12/28/2018 - 13:41:26: [SM] Blaming: DangerZone.smx
L 12/28/2018 - 13:41:26: [SM] Call stack trace:
L 12/28/2018 - 13:41:26: [SM]  [1] Line 114, DangerZone.sp::Event_PlayerSpawn
L 12/28/2018 - 13:41:26: [SM] Exception reported: Stack leak detected: sp:27964 should be 28004!
L 12/28/2018 - 13:46:10: [SM] Exception reported: Array index out-of-bounds (index 9, limit 9)
L 12/28/2018 - 13:46:10: [SM] Blaming: DangerZone.smx
L 12/28/2018 - 13:46:10: [SM] Call stack trace:
L 12/28/2018 - 13:46:10: [SM]  [1] Line 114, DangerZone.sp::Event_PlayerSpawn
L 12/28/2018 - 13:46:10: [SM] Exception reported: Stack leak detected: sp:27924 should be 27964!
L 12/28/2018 - 13:50:01: [SM] Exception reported: Array index out-of-bounds (index 24, limit 24)
L 12/28/2018 - 13:50:01: [SM] Blaming: DangerZone.smx
L 12/28/2018 - 13:50:01: [SM] Call stack trace:
L 12/28/2018 - 13:50:01: [SM]  [1] Line 110, DangerZone.sp::Event_PlayerSpawn
L 12/28/2018 - 13:50:01: [SM] Exception reported: Stack leak detected: sp:27888 should be 27924!
L 12/28/2018 - 13:51:02: [SM] Exception reported: Array index out-of-bounds (index 24, limit 24)
L 12/28/2018 - 13:51:02: [SM] Blaming: DangerZone.smx
L 12/28/2018 - 13:51:02: [SM] Call stack trace:
L 12/28/2018 - 13:51:02: [SM]  [1] Line 110, DangerZone.sp::Event_PlayerSpawn
L 12/28/2018 - 13:51:02: [SM] Exception reported: Stack leak detected: sp:27852 should be 27888!
L 12/28/2018 - 13:51:59: Error log file session closed.
L 12/28/2018 - 13:52:08: SourceMod error session started
L 12/28/2018 - 13:52:08: Info (map "dz_blacksite") (file "errors_20181228.log")
L 12/28/2018 - 13:52:08: [SM] Exception reported: Array index out-of-bounds (index 24, limit 24)
L 12/28/2018 - 13:52:08: [SM] Blaming: DangerZone.smx
L 12/28/2018 - 13:52:08: [SM] Call stack trace:
L 12/28/2018 - 13:52:08: [SM]  [1] Line 474, DangerZone.sp::GiveRandomPrimaryWeapons
L 12/28/2018 - 13:52:08: [SM]  [2] Line 108, DangerZone.sp::Event_PlayerSpawn
L 12/28/2018 - 13:52:08: [SM] Exception reported: Stack leak detected: sp:27992 should be 28044!
L 12/28/2018 - 14:08:30: Error log file session closed.
L 12/28/2018 - 14:08:58: SourceMod error session started
L 12/28/2018 - 14:08:58: Info (map "dz_blacksite") (file "errors_20181228.log")
L 12/28/2018 - 14:08:58: [SM] Exception reported: Array index out-of-bounds (index 24, limit 24)
L 12/28/2018 - 14:08:58: [SM] Blaming: DangerZone.smx
L 12/28/2018 - 14:08:58: [SM] Call stack trace:
L 12/28/2018 - 14:08:58: [SM]  [1] Line 480, DangerZone.sp::GiveRandomPrimaryWeapons
L 12/28/2018 - 14:08:58: [SM]  [2] Line 108, DangerZone.sp::Event_PlayerSpawn
L 12/28/2018 - 14:08:58: [SM] Exception reported: Stack leak detected: sp:28304 should be 28356!
L 12/28/2018 - 14:21:15: SourceMod error session started
L 12/28/2018 - 14:21:15: Info (map "dz_blacksite") (file "errors_20181228.log")
L 12/28/2018 - 14:21:15: [SM] Exception reported: Array index out-of-bounds (index 9, limit 9)
L 12/28/2018 - 14:21:15: [SM] Blaming: DangerZone.smx
L 12/28/2018 - 14:21:15: [SM] Call stack trace:
L 12/28/2018 - 14:21:15: [SM]  [1] Line 489, DangerZone.sp::GiveRandomSecondaryWeapons
L 12/28/2018 - 14:21:15: [SM]  [2] Line 110, DangerZone.sp::Event_PlayerSpawn
L 12/28/2018 - 14:21:15: [SM] Exception reported: Stack leak detected: sp:28280 should be 28332!
L 12/28/2018 - 15:25:50: Error log file session closed.
L 12/28/2018 - 15:26:46: SourceMod error session started
L 12/28/2018 - 15:26:46: Info (map "dz_blacksite") (file "errors_20181228.log")
L 12/28/2018 - 15:26:46: [SM] Exception reported: Array index out-of-bounds (index 9, limit 9)
L 12/28/2018 - 15:26:46: [SM] Blaming: DangerZone.smx
L 12/28/2018 - 15:26:46: [SM] Call stack trace:
L 12/28/2018 - 15:26:46: [SM]  [1] Line 489, DangerZone.sp::GiveRandomSecondaryWeapons
L 12/28/2018 - 15:26:46: [SM]  [2] Line 110, DangerZone.sp::Event_PlayerSpawn
L 12/28/2018 - 15:26:46: [SM] Exception reported: Stack leak detected: sp:28256 should be 28308!
L 12/28/2018 - 15:27:04: [SM] Exception reported: Array index out-of-bounds (index 22, limit 22)
L 12/28/2018 - 15:27:04: [SM] Blaming: DangerZone.smx
L 12/28/2018 - 15:27:04: [SM] Call stack trace:
L 12/28/2018 - 15:27:04: [SM]  [1] Line 480, DangerZone.sp::GiveRandomPrimaryWeapons
L 12/28/2018 - 15:27:04: [SM]  [2] Line 108, DangerZone.sp::Event_PlayerSpawn
L 12/28/2018 - 15:27:04: [SM] Exception reported: Stack leak detected: sp:28204 should be 28256!
L 12/28/2018 - 15:37:06: [SM] Exception reported: Array index out-of-bounds (index 9, limit 9)
L 12/28/2018 - 15:37:06: [SM] Blaming: DangerZone.smx
L 12/28/2018 - 15:37:06: [SM] Call stack trace:
L 12/28/2018 - 15:37:06: [SM]  [1] Line 489, DangerZone.sp::GiveRandomSecondaryWeapons
L 12/28/2018 - 15:37:06: [SM]  [2] Line 110, DangerZone.sp::Event_PlayerSpawn
L 12/28/2018 - 15:37:06: [SM] Exception reported: Stack leak detected: sp:28152 should be 28204!
L 12/28/2018 - 15:37:38: [SM] Exception reported: Array index out-of-bounds (index 9, limit 9)
L 12/28/2018 - 15:37:38: [SM] Blaming: DangerZone.smx
L 12/28/2018 - 15:37:38: [SM] Call stack trace:
L 12/28/2018 - 15:37:38: [SM]  [1] Line 489, DangerZone.sp::GiveRandomSecondaryWeapons
L 12/28/2018 - 15:37:38: [SM]  [2] Line 110, DangerZone.sp::Event_PlayerSpawn
L 12/28/2018 - 15:37:38: [SM] Exception reported: Stack leak detected: sp:28100 should be 28152!
L 12/28/2018 - 15:37:46: [SM] Exception reported: Array index out-of-bounds (index 22, limit 22)
L 12/28/2018 - 15:37:46: [SM] Blaming: DangerZone.smx
L 12/28/2018 - 15:37:46: [SM] Call stack trace:
L 12/28/2018 - 15:37:46: [SM]  [1] Line 480, DangerZone.sp::GiveRandomPrimaryWeapons
L 12/28/2018 - 15:37:46: [SM]  [2] Line 108, DangerZone.sp::Event_PlayerSpawn
L 12/28/2018 - 15:37:46: [SM] Exception reported: Stack leak detected: sp:28048 should be 28100!
L 12/28/2018 - 15:41:22: [SM] Exception reported: Array index out-of-bounds (index 9, limit 9)
L 12/28/2018 - 15:41:22: [SM] Blaming: DangerZone.smx
L 12/28/2018 - 15:41:22: [SM] Call stack trace:
L 12/28/2018 - 15:41:22: [SM]  [1] Line 489, DangerZone.sp::GiveRandomSecondaryWeapons
L 12/28/2018 - 15:41:22: [SM]  [2] Line 110, DangerZone.sp::Event_PlayerSpawn
L 12/28/2018 - 15:41:22: [SM] Exception reported: Stack leak detected: sp:27996 should be 28048!
L 12/28/2018 - 15:42:52: [SM] Exception reported: Array index out-of-bounds (index 9, limit 9)
L 12/28/2018 - 15:42:52: [SM] Blaming: DangerZone.smx
L 12/28/2018 - 15:42:52: [SM] Call stack trace:
L 12/28/2018 - 15:42:52: [SM]  [1] Line 489, DangerZone.sp::GiveRandomSecondaryWeapons
L 12/28/2018 - 15:42:52: [SM]  [2] Line 110, DangerZone.sp::Event_PlayerSpawn
L 12/28/2018 - 15:42:52: [SM] Exception reported: Stack leak detected: sp:27944 should be 27996!
L 12/28/2018 - 15:43:08: [SM] Exception reported: Array index out-of-bounds (index 9, limit 9)
L 12/28/2018 - 15:43:08: [SM] Blaming: DangerZone.smx
L 12/28/2018 - 15:43:08: [SM] Call stack trace:
L 12/28/2018 - 15:43:08: [SM]  [1] Line 489, DangerZone.sp::GiveRandomSecondaryWeapons
L 12/28/2018 - 15:43:08: [SM]  [2] Line 110, DangerZone.sp::Event_PlayerSpawn
L 12/28/2018 - 15:43:08: [SM] Exception reported: Stack leak detected: sp:27892 should be 27944!
L 12/28/2018 - 15:43:34: [SM] Exception reported: Array index out-of-bounds (index 9, limit 9)
L 12/28/2018 - 15:43:34: [SM] Blaming: DangerZone.smx
L 12/28/2018 - 15:43:34: [SM] Call stack trace:
L 12/28/2018 - 15:43:34: [SM]  [1] Line 489, DangerZone.sp::GiveRandomSecondaryWeapons
L 12/28/2018 - 15:43:34: [SM]  [2] Line 110, DangerZone.sp::Event_PlayerSpawn
L 12/28/2018 - 15:43:34: [SM] Exception reported: Stack leak detected: sp:27840 should be 27892!
L 12/28/2018 - 15:43:48: [SM] Exception reported: Array index out-of-bounds (index 22, limit 22)
L 12/28/2018 - 15:43:48: [SM] Blaming: DangerZone.smx
L 12/28/2018 - 15:43:48: [SM] Call stack trace:
L 12/28/2018 - 15:43:48: [SM]  [1] Line 480, DangerZone.sp::GiveRandomPrimaryWeapons
L 12/28/2018 - 15:43:48: [SM]  [2] Line 108, DangerZone.sp::Event_PlayerSpawn
L 12/28/2018 - 15:43:48: [SM] Exception reported: Stack leak detected: sp:27788 should be 27840!
L 12/28/2018 - 15:43:57: [SM] Exception reported: Array index out-of-bounds (index 9, limit 9)
L 12/28/2018 - 15:43:57: [SM] Blaming: DangerZone.smx
L 12/28/2018 - 15:43:57: [SM] Call stack trace:
L 12/28/2018 - 15:43:57: [SM]  [1] Line 489, DangerZone.sp::GiveRandomSecondaryWeapons
L 12/28/2018 - 15:43:57: [SM]  [2] Line 110, DangerZone.sp::Event_PlayerSpawn
L 12/28/2018 - 15:43:57: [SM] Exception reported: Stack leak detected: sp:27736 should be 27788!
L 12/28/2018 - 15:56:50: Error log file session closed.
L 12/28/2018 - 15:57:17: SourceMod error session started
L 12/28/2018 - 15:57:17: Info (map "dz_blacksite") (file "errors_20181228.log")
L 12/28/2018 - 15:57:17: [SM] Exception reported: Array index out-of-bounds (index 22, limit 22)
L 12/28/2018 - 15:57:17: [SM] Blaming: DangerZone.smx
L 12/28/2018 - 15:57:17: [SM] Call stack trace:
L 12/28/2018 - 15:57:17: [SM]  [1] Line 480, DangerZone.sp::GiveRandomPrimaryWeapons
L 12/28/2018 - 15:57:17: [SM]  [2] Line 108, DangerZone.sp::Event_PlayerSpawn
L 12/28/2018 - 15:57:17: [SM] Exception reported: Stack leak detected: sp:27684 should be 27736!
L 12/28/2018 - 15:58:18: [SM] Exception reported: Array index out-of-bounds (index 9, limit 9)
L 12/28/2018 - 15:58:18: [SM] Blaming: DangerZone.smx
L 12/28/2018 - 15:58:18: [SM] Call stack trace:
L 12/28/2018 - 15:58:18: [SM]  [1] Line 489, DangerZone.sp::GiveRandomSecondaryWeapons
L 12/28/2018 - 15:58:18: [SM]  [2] Line 110, DangerZone.sp::Event_PlayerSpawn
L 12/28/2018 - 15:58:18: [SM] Exception reported: Stack leak detected: sp:27632 should be 27684!

my cod:
PHP Code:

char PrimaryWeaponsList[][] =  {"weapon_galilar""weapon_famas""weapon_ak47""weapon_m4a1""weapon_m4a1_silencer""weapon_ssg08""weapon_aug""weapon_sg556""weapon_awp""weapon_nova""weapon_xm1014""weapon_mag7""weapon_m249""weapon_negev""weapon_mac10""weapon_mp9""weapon_mp7""weapon_ump45""weapon_p90""weapon_bizon""weapon_mp5sd""weapon_sawedoff"};

char SecondaryWeaponsList[][] =  
{
"weapon_glock""weapon_usp_silencer""weapon_deagle""weapon_tec9""weapon_hkp2000""weapon_p250""weapon_fiveseven""weapon_elite""weapon_cz75a"};

public 
void OnPluginStart()
{
    
HookEvent("player_spawn"Event_PlayerSpawn);
}


public 
Action Event_PlayerSpawn(Event event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(event.GetInt("userid"));
    
    if(
IsWarmup() && IsValidClient(client))
    {
        
RemoveClientPrimaryWeapons(client);
        
GiveRandomPrimaryWeapons(client);
        
RemoveClientSecondaryWeapons(client);
        
GiveRandomSecondaryWeapons(client);
    }
}

/*********************************
 *  Remove Client Primary Weapons
 *********************************/
void RemoveClientPrimaryWeapons(int client)
{
    
int weapon_index = -1;
    
    if((
weapon_index GetPlayerWeaponSlot(clientCS_SLOT_PRIMARY)) != -1)
    {
        if (
IsValidEntity(weapon_index))
        {
            
RemovePlayerItem(clientweapon_index);
            
AcceptEntityInput(weapon_index"Kill");
        }
    }
}

/*********************************
 *  Remove Client Primary Weapons
 *********************************/
void RemoveClientSecondaryWeapons(int client)

    
int weapon_index = -1;
    
    if((
weapon_index GetPlayerWeaponSlot(clientCS_SLOT_SECONDARY)) != -1)
    {
        if (
IsValidEntity(weapon_index))
        {
            
RemovePlayerItem(clientweapon_index);
            
AcceptEntityInput(weapon_index"Kill");
        }
    }
}

/*********************************
 *  Give Random Primary Weapons
 *********************************/
void GiveRandomPrimaryWeapons(int client)
{
    if(
IsValidClient(client))
    {
        
int Primary GetRandomInt(0sizeof(PrimaryWeaponsList));
        
GivePlayerItem(clientPrimaryWeaponsList[Primary]);
    }
}

/*********************************
 *  Give Random Secondary Weapons
 *********************************/
void GiveRandomSecondaryWeapons(int client)
{
    if(
IsValidClient(client))
    {
        
int Secondary GetRandomInt(0sizeof(SecondaryWeaponsList));
        
GivePlayerItem(clientSecondaryWeaponsList[Secondary]);
    }


thank you guys.

8guawong 12-28-2018 10:36

Re: [Help] Exception reported: Array index out-of-bounds
 
Code:

sizeof(PrimaryWeaponsList)
to

Code:

sizeof(PrimaryWeaponsList[])

Facksy 12-28-2018 10:55

Re: [Help] Exception reported: Array index out-of-bounds
 
Quote:

Originally Posted by 8guawong (Post 2631436)
Code:

sizeof(PrimaryWeaponsList)
to

Code:

sizeof(PrimaryWeaponsList[])

No, in his case, its
Code:

sizeof(PrimaryWeaponsList)-1
So it should be like that
Code:

int Primary = GetRandomInt(0, sizeof(PrimaryWeaponsList)-1);

Dr.Mohammad 12-28-2018 14:30

Re: [Help] Exception reported: Array index out-of-bounds
 
Quote:

Originally Posted by Facksy (Post 2631437)
No, in his case, its
Code:

sizeof(PrimaryWeaponsList)-1
So it should be like that
Code:

int Primary = GetRandomInt(0, sizeof(PrimaryWeaponsList)-1);

thank you. worked!!

:bacon!::bacon!::bacon!::bacon!:

Dr.Mohammad 12-28-2018 14:31

Re: [Help] Exception reported: Array index out-of-bounds
 
Quote:

Originally Posted by 8guawong (Post 2631436)
Code:

sizeof(PrimaryWeaponsList)
to

Code:

sizeof(PrimaryWeaponsList[])

thank you for help but dont work.


All times are GMT -4. The time now is 01:28.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.