AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Run time error 4: Index out of bounds (https://forums.alliedmods.net/showthread.php?t=120837)

NiQu 03-08-2010 12:55

Run time error 4: Index out of bounds
 
I got that thing in my server console...

Line's it gives this on is 540 and 2659:
FIXED! For others with this problem: Check if users are connected!

l540:
PHP Code:

F_Print(id"You got 10 dollars!"); //Line 540 

Function #1
PHP Code:

F_Print(id, const sMsg[], any:...)
{
    static 
iid id get_Player();
    if ( !
) return;
    
    new 
sMessage[256];
    new 
len formatex(sMessagesizeof(sMessage) - 1"^x04[%s %s]^x03 "PLUGIN_PREFIXVERSION);
    
vformat(sMessage[len], sizeof(sMessage) - lensMsg3);
    
sMessage[192] = '^0';
    
    static 
msgid_SayText;
    if ( !
msgid_SayText msgid_SayText get_user_msgid("SayText");
    
    new const 
team_Names[][] =
    {
        
"",
        
"TERRORIST",
        
"CT",
        
"SPECTATOR"
    
};
    
    new 
sTeam get_user_team(i);
    
    
team_Info(iidteam_Names[0]);
    
    
message_begin(id MSG_ONE_UNRELIABLE MSG_BROADCASTmsgid_SayText_id);
    
write_byte(i);
    
write_string(sMessage);
    
message_end();
    
    
team_Info(iidteam_Names[sTeam]); //Line 2659!


Function #2:
PHP Code:

team_Info(receiversendersTeam[])
{
    static 
msgid_TeamInfo;
    if ( !
msgid_TeamInfo msgid_TeamInfo get_user_msgid("TeamInfo");
    
    
message_begin(sender MSG_ONE_UNRELIABLE MSG_BROADCASTmsgid_TeamInfo_sender);
    
write_byte(receiver);
    
write_string(sTeam);
    
message_end();


Function #3:
PHP Code:

get_Player()
{
    for ( new 
id 1id <= gMaxPlayersid++ )
    {
        if ( 
gbConnected[id] )
        {
            return 
id;
        }
    }
    
    return 
0;


Please help , what can the problem be ?

Bugsy 03-08-2010 13:42

Re: Run time error 4: Index out of bounds
 
show where gbConnected is defined

NiQu 03-08-2010 14:03

Re: Run time error 4: Index out of bounds
 
Quote:

Originally Posted by Bugsy (Post 1111950)
show where gbConnected is defined

PHP Code:

new bool:gbConnected[33]; 

Its above plugin_init and everything.

Bugsy 03-08-2010 16:28

Re: Run time error 4: Index out of bounds
 
Try using cs_get_user_team().

wrecked_ 03-08-2010 16:32

Re: Run time error 4: Index out of bounds
 
What's line 2659?

Also, post the full function that the incorrect F_Print is in, please.

Bugsy 03-08-2010 16:34

Re: Run time error 4: Index out of bounds
 
Im on my phone now so cant take a good look. You can post or pm your full code if you cant figure it out.

Wrecked, see function #1, theres a comment after the line.

NiQu 03-08-2010 17:33

Re: Run time error 4: Index out of bounds
 
wrecked_ i did, look in the first post.. all functions is in there.

and Bugsy is right.


All times are GMT -4. The time now is 08:36.

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