SA-MP Forums Archive
Crash detect with OnPlayerInteriorChange - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Crash detect with OnPlayerInteriorChange (/showthread.php?tid=549411)



Crash detect with OnPlayerInteriorChange - maximthepain - 06.12.2014

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?


Re: Crash detect with OnPlayerInteriorChange - CoaPsyFactor - 06.12.2014

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


Re: Crash detect with OnPlayerInteriorChange - maximthepain - 06.12.2014

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.


Re: Crash detect with OnPlayerInteriorChange - CoaPsyFactor - 06.12.2014

I'm glad it helped