Raised This Month: $ Target: $400
 0% 

[AMXX] Run time error 4: index out of bounds


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Michell
Member
Join Date: Oct 2015
Old 12-13-2015 , 15:19   [AMXX] Run time error 4: index out of bounds
Reply With Quote #1

PHP Code:
public MakeMsg(){
    new 
iTeamiTempidszName[33], szTemp[100];
    
    for( new 
06i++ ){
        if(
iPlayers] < 1)
            continue;
        
        
iTempid iPlayers];
        
        
iTeam fm_cs_get_user_teamiTempid );
        
        
get_user_name(iTempidszNamecharsmax(szName));
        
        
formatex(szTempsizeof(szTemp), "%s - %d Kills^n"szNameg_killsiTempid ]);
        
add(HudMsg[iTeam],511,szTemp);
    }

Michell is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-13-2015 , 15:33   Re: [AMXX] Run time error 4: index out of bounds
Reply With Quote #2

Show how iPlayers is defined and getting filled with player id's

You should use charsmax() and not sizeof() in formatex().
__________________
Bugsy is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-13-2015 , 15:46   Re: [AMXX] Run time error 4: index out of bounds
Reply With Quote #3

Quote:
Originally Posted by Michell View Post
PHP Code:
new playersg_kills[33], HudMsg[3][ 512 ], iPlayers] ; 
Quote:
Originally Posted by Bugsy View Post
Show how iPlayers is defined and getting filled with player id's
__________________

Last edited by Bugsy; 12-13-2015 at 15:46.
Bugsy is offline
Michell
Member
Join Date: Oct 2015
Old 12-13-2015 , 15:43   Re: [AMXX] Run time error 4: index out of bounds
Reply With Quote #4

PHP Code:
new playersg_kills[33], HudMsg[3][ 512 ], iPlayers] ; 
Michell is offline
Michell
Member
Join Date: Oct 2015
Old 12-13-2015 , 15:50   Re: [AMXX] Run time error 4: index out of bounds
Reply With Quote #5

like this ?

PHP Code:
public MakeMsg(){
    new 
iTeamiTempidszName[33], szTemp[100];
    
    for( new 
06i++ ){
        if(
iPlayers] < 1)
            continue;
        
        
iTempid iPlayers];
        
        
iTeam fm_cs_get_user_teamiTempid );
        
        
get_user_name(iTempidszNamecharsmax(szName));
        
        
formatex(szTempcharsmax(szTemp), "%s - %d Kills^n"szNameg_killsiTempid ]);
        
add(HudMsg[iTeam],511,szTemp);
    }

Michell is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-13-2015 , 15:54   Re: [AMXX] Run time error 4: index out of bounds
Reply With Quote #6

Based on that code, the whole iPlayers[] array will be 0's. You are not showing how it is populated with player id's.

What you should do, is define iPlayers[ 32 ], and use get_players() to fill it.

http://www.amxmodx.org/api/amxmodx/get_players
__________________

Last edited by Bugsy; 12-13-2015 at 15:54.
Bugsy 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 18:14.


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