Raised This Month: $51 Target: $400
 12% 

Solved weird Index out of bounds


Post New Thread Reply   
 
Thread Tools Display Modes
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-23-2020 , 20:51   Re: weird Index out of bounds
Reply With Quote #11

Problem is here:
PHP Code:
    if( ( get_user_flagsid ) & ADMIN_LEVEL_H ) || ( get_user_flagsid ) & ADMIN_LEVEL_G ) )
        
menu_additemmenu"\yVIP Skin^n" )
    else
        
menu_additemmenu"\dVIP Skin^n" 
Above this code, you already fill the menu with items based on the size of Modelitems. Anything beyond that will trigger index out of bounds. The error will occur when you pick VIP Skin.
__________________
Bugsy is offline
JocAnis
Veteran Member
Join Date: Jun 2010
Old 05-23-2020 , 20:54   Re: weird Index out of bounds
Reply With Quote #12

@Bugsy, but i did with:
Code:
 for( new i; i < sizeof ModelItems - 1; i++ )
meaning last item will not be included, right?
so because of it, im adding last item (9.) for VIP item
__________________
KZ Public Autocup - PrimeKZ

My blog: http://primekz.xyz (in progress...) - not active (dec 2022)

Last edited by JocAnis; 05-23-2020 at 20:54.
JocAnis is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-23-2020 , 20:59   Re: weird Index out of bounds
Reply With Quote #13

No, they are all included in that loop (0 to 2). Arrays go from 0 to size-1

PHP Code:
new const ModelItems[][ eModels ] =
{
    { 
"Default""gign"},   // SLOT 0
    
"Agent Smith""agent"1000 },  // SLOT 1
    
"Terminator""terminator"1500 }  // SLOT 2

VIP skin results in an item value of 3
PHP Code:
ModelItems][ MODEL_LOCATION ]  // == Index out of bounds 
__________________

Last edited by Bugsy; 05-23-2020 at 20:59.
Bugsy is offline
JocAnis
Veteran Member
Join Date: Jun 2010
Old 05-23-2020 , 21:02   Re: weird Index out of bounds
Reply With Quote #14

i skipped some itesm from ModelItems, here is the full list:
Code:
new const ModelItems[][ eModels ] =
{
    { "Default", "gign", 0 }, //0
    { "Agent Smith", "agent", 1000 },
    { "Terminator", "terminator", 1500 },
    { "Lara (Girl Skin)", "lara", 2000 },
    { "Assassin", "assassin", 2500 },
    { "Goku", "goku", 3000 },
    { "Putin", "putin", 3500 },
    { "SWAT", "newswat", 4000 },
    { "VIP Skin", "vip", 4000 } //8 but 9. in the menu
}
Im really confused
__________________
KZ Public Autocup - PrimeKZ

My blog: http://primekz.xyz (in progress...) - not active (dec 2022)
JocAnis is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-23-2020 , 21:03   Re: weird Index out of bounds
Reply With Quote #15

This is the ModelItems array you gave me here
PHP Code:
new const ModelItems[][ eModels ] =
{
    { 
"Default""gign"},
    { 
"Agent Smith""agent"1000 },
    { 
"Terminator""terminator"1500 }

__________________
Bugsy is offline
JocAnis
Veteran Member
Join Date: Jun 2010
Old 05-23-2020 , 21:22   Re: weird Index out of bounds
Reply With Quote #16

Thank you @Bugsy for contributin to the thread and trying to help.

I had these lines left, probably from testing, now its all ok after deleting that TOTALLY unnecessary code
__________________
KZ Public Autocup - PrimeKZ

My blog: http://primekz.xyz (in progress...) - not active (dec 2022)

Last edited by JocAnis; 05-23-2020 at 21:23.
JocAnis is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 04:46.


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