Scripting issue
#1

Hello,

I have a problem with connecting to my server with underscores.. it loops on restarting server, and when I ran the plugin crashdetect I came with this
Код:
    [21:47:51] [debug] Run time error 4: "Array index out of bounds"
    [21:47:51] [debug] Accessing element at index 65535 past array upper bound 1999
    [21:47:51] [debug] AMX backtrace:
    [21:47:51] [debug] #0 0000b1b4 in ?? () from Aegis.amx
    [21:47:51] [debug] #1 0000a8f8 in ?? () from Aegis.amx
    [21:47:51] [debug] #2 0004d1d4 in public OnGameModeInit () from Aegis.amx
Reply
#2

I guess you made something under OnGameModeInit out of the index you defined earlier. it can be anything?

Example:
Код:
pInfo
{
   	pGate[3],
}
Then if i'll make this :
Код:
format(var, 32, "Gate3", PlayerInfo[playerid][pGate][3]);fwrite(hFile, var);
or more then 3 that i defined earlier it'll give message "Array index out of bounds"
After you define numbers remember to start from 0 not from 1 you can get confused then with arrays.
Reply
#3

Could this be the reason I cannot log in with underscores in my name?
Reply
#4

When you compile your script it doesn't give you an errors or warnings about "Array index out of bounds"?
Reply
#5

Nope, nothing. Which confused us on why we couldn't connect til we got the crashdetect plugin
Reply
#6

Show what's under OnGameModeInit, You are trying making 'something' without arrays therefore you should first make something like that:
that 'something' can be giveplayerid, killerid, or anything else in your script under OnGameModeInit..
You have to check if 'something' is INVALID_PLAYER_ID before you use it on an array as an index.
INVALID_PLAYER_ID equals 65536 (0xFFFF).
new array[ MAX_PLAYERS ];
array[ 65536 ] = something;//indexed oob

This is an example for OnPlayerDeath to check if the killer id is not INVALID_PLAYER_ID:
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    if( killerid != INVALID_PLAYER_ID )
    {
        ++kills[ killerid ];//killerid is ok it's not INVALID_PLAYER_ID
        ++deaths[ playerid ];
    }
    else
    {
        //dont use killerid as index here it's INVALID_PLAYER_ID
        ++deaths[ playerid ];
    }
    return 1;
}
Taken from Similar problem like yours https://sampforum.blast.hk/showthread.php?tid=347895 that should work.
Reply
#7

Okay this makes sense, Linux is more of code nazi. Because this script on windows don't give us the problem.. but thanks. I'll forward this to the scripter so he can fix this. Thanks for your help!.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)