Raised This Month: $ Target: $400
 0% 

index out of bounds


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DoviuX
Senior Member
Join Date: Jun 2009
Location: Lithuania
Old 08-14-2012 , 12:52   index out of bounds
Reply With Quote #1

I have this const:
PHP Code:
new const PRIMARY[ ][ ] = { 
    
"weapon_m4a1",        // Gun ID - 1
    
"weapon_ak47",        // Gun ID - 2
    
"weapon_m3",         // Gun ID - 3
    
"weapon_xm1014",    // Gun ID - 4
    
"weapon_aug",        // Gun ID - 5
    
"weapon_mac10",        // Gun ID - 6
    
"weapon_ump45",        // Gun ID - 7
    
"weapon_mp5navy",    // Gun ID - 8
    
"weapon_p90",        // Gun ID - 9
    
"weapon_galil",        // Gun ID - 10
    
"weapon_famas"        // Gun ID - 11
}; 
and I need that from another const:
PHP Code:
 new const allowed_primary[ ] = { 124567891011 
Would print into menu only those ids which are in const:
PHP Code:
        for( i_prim 0i_prim 8i_prim++ ) {
            
p_id = ( ( _curr_pageid ] * ) + i_prim );
            if( 
p_id _totalguns )
                
len += formatexdata_holderlen ], charsmaxdata_holder ) - len"^n \r%i\d. %s"i_prim 1P_NAMESallowed_primaryp_id ] ] );                
        } 
But I get index out of bounds here:
PHP Code:
P_NAMESallowed_primaryp_id ] ] 
Is there any other way to do this ?
DoviuX is offline
Send a message via Skype™ to DoviuX
lucas_7_94
Leche Loco
Join Date: Mar 2009
Location: Argentina
Old 08-14-2012 , 13:31   Re: index out of bounds
Reply With Quote #2

PRIMARY[][] has 11 weapons , and allowed_primary[] has 10.. check that.
__________________
ATWWMH - MiniDuels
Madness is like gravity, just need a little push.
lucas_7_94 is offline
Send a message via Skype™ to lucas_7_94
DoviuX
Senior Member
Join Date: Jun 2009
Location: Lithuania
Old 08-14-2012 , 13:40   Re: index out of bounds
Reply With Quote #3

I know but I want that if allowed_primary has 10 then in menu shows 10 but primary still leaves 11, what I want to say is if there is guns id in allowed_primary so it will be in the menu.

example:
new const allowed_primary[ ] = { 1, 2, 4, 5, 6, 7, 8, 9, 10, 11 }

meniu:
1. 1 gun ( becouse id 1 )
2. 2 gun ( becouse id 2 )
3. 4 gun ( becouse id 4 )
and etc.
DoviuX is offline
Send a message via Skype™ to DoviuX
Merciless
BANNED
Join Date: Aug 2009
Location: Belgium
Old 08-14-2012 , 13:45   Re: index out of bounds
Reply With Quote #4

"weapon_m4a1", // Gun ID - 1

its gun id 0

It starts with 0 not 1
Merciless is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 08-14-2012 , 17:25   Re: index out of bounds
Reply With Quote #5

Quote:
Originally Posted by Merciless View Post
"weapon_m4a1", // Gun ID - 1

its gun id 0

It starts with 0 not 1
Not if you set a value to the array
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 08-14-2012 , 17:44   Re: index out of bounds
Reply With Quote #6

PHP Code:
new const PRIMARY[ ][ ] = { 
    
"weapon_m4a1",        // Gun ID - 1
    
"weapon_ak47",        // Gun ID - 2
    
"weapon_m3",         // Gun ID - 3
    
"weapon_xm1014",    // Gun ID - 4
    
"weapon_aug",        // Gun ID - 5
    
"weapon_mac10",        // Gun ID - 6
    
"weapon_ump45",        // Gun ID - 7
    
"weapon_mp5navy",    // Gun ID - 8
    
"weapon_p90",        // Gun ID - 9
    
"weapon_galil",        // Gun ID - 10
    
"weapon_famas"        // Gun ID - 11
}; 

PHP Code:
new const PRIMARY[ ][ ] = { 
    
""// Gun ID - 0, doesn't exist
    
"weapon_m4a1",        // Gun ID - 1
    
"weapon_ak47",        // Gun ID - 2
    
"weapon_m3",         // Gun ID - 3
    
"weapon_xm1014",    // Gun ID - 4
    
"weapon_aug",        // Gun ID - 5
    
"weapon_mac10",        // Gun ID - 6
    
"weapon_ump45",        // Gun ID - 7
    
"weapon_mp5navy",    // Gun ID - 8
    
"weapon_p90",        // Gun ID - 9
    
"weapon_galil",        // Gun ID - 10
    
"weapon_famas"        // Gun ID - 11
}; 
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Merciless
BANNED
Join Date: Aug 2009
Location: Belgium
Old 08-14-2012 , 19:48   Re: index out of bounds
Reply With Quote #7

Quote:
Originally Posted by Napoleon_be View Post
Not if you set a value to the array
Say w00t ?
Merciless is offline
Reply


Thread Tools
Display Modes

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 05:45.


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