Crash detect with OnPlayerInteriorChange
#1

I wanted to check crashes with crashdetect plugin and it printed out something which im not sure how to fix..
It doesn't crash the player ingame, however i want to know why this is explained as a crash.
pawn Код:
[debug] AMX backtrace:
[debug] #0 00231924 in ?? (0, 6, 0) from RP.amx
[debug] #1 0000fa2c in public OnPlayerInteriorChange (0, 6, 0) from LG-RP.amx
[debug] Run time error 4: "Array index out of bounds"
[debug]  Accessing element at negative index -100
This is the code:
pawn Код:
public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
    new string[100], idx = GetPlayerVirtualWorld(playerid)-100;
    format(string, sizeof(string), bzPATH, idx); // Formats the File path
    INI_ParseFile(string, "LoadBizStream_%s", .bExtra = true, .extra = idx); // Openes the file and loads everything in it. (initializing it)
    if(BizInfo[idx][bStreamAble] == 1)
    {
        PlayAudioStreamForPlayer(playerid, BizInfo[idx][bStream]);
    }
    else
    {
        StopAudioStreamForPlayer(playerid);
    }
    foreach(Player, i)
    {
        if(GetPlayerState(i) == 9)
        {
            if(Specid[i] == playerid)
            {
                SetPlayerInterior(i, newinteriorid);
                return 1;
            }
        }
    }
    return 1;
}
I made this code before sometime, it works great yet it outputing this crash detection?
Reply
#2

it is because your Player Virtual world is 0 and when you take 100, you get -100, and index -100 in array is not valid
Reply
#3

Quote:
Originally Posted by CoaPsyFactor
Посмотреть сообщение
it is because your Player Virtual world is 0 and when you take 100, you get -100, and index -100 in array is not valid
Thanks for the explanation.
Well, great! I made some edits to my code and now it works without outputing the error.
Reply
#4

I'm glad it helped
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)