SA-MP Forums Archive
[HELP] negative index -1 - 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: [HELP] negative index -1 (/showthread.php?tid=520509)



[HELP] negative index -1 - Luca12 - 19.06.2014

Hello I was get the error array index of bounds accesing element at negative index -1 that is in this command. thanks

pawn Код:
CMD:p(playerid,params[])
{
    new x = -1;
    foreach(Player,i)
    {
        if(RazgovaraSa[i] && i != playerid) x = i;
    }
    new ime[128],string[128];
    RPIme(playerid,ime);
    SCM(x,COLOR_GRAD2,"Javio se.");
    format(string,sizeof(string),"%s se javio na mobitel.",ime);
    RazgovaraSa[playerid] = ZoveGa[playerid];
    RazgovaraSa[ZoveGa[playerid]] = PozivZa[ZoveGa[playerid]];
    ProxDetector(10.0,playerid,string,LJUBICASTA,LJUBICASTA,LJUBICASTA,LJUBICASTA,LJUBICASTA);
    NaplatiPoziv[RazgovaraSa[playerid]] = SetTimerEx("UzmiZaPoziv",Min(1),true,"d",RazgovaraSa[playerid]);
    SetPlayerSpecialAction(playerid,SPECIAL_ACTION_USECELLPHONE);
    return 1;
}



Re: [HELP] negative index -1 - Rittik - 19.06.2014

Increase the limit of elements in that array.


Re: [HELP] negative index -1 - Konstantinos - 19.06.2014

Use debug info (-d3) for getting the exact line caused it, all I can do at the moment is guessing:
pawn Код:
RazgovaraSa[ZoveGa[playerid]]
PozivZa[ZoveGa[playerid]]
// or
NaplatiPoziv[RazgovaraSa[playerid]]
so either ZoveGa[playerid] or RazgovaraSa[playerid] is -1.


Re: [HELP] negative index -1 - Luca12 - 19.06.2014

Is it a way to fix this I mean the line which you give me.Thanks.Konstantinos that is problem crashdetect won't show me the line I debug for few times it just says that error and in which command is it I use know crashedetect 4.13.1 and only this I get in server.log


[12:00:04] [debug] Run time error 4: "Array index out of bounds"
[12:00:04] [debug] Accessing element at negative index -1
[12:00:04] [debug] AMX backtrace:
[12:00:04] [debug] #0 000ee91c in public cmd_p (0x00000002, 0x0184fd54) from GURP.amx


Re: [HELP] negative index -1 - Konstantinos - 19.06.2014

https://github.com/Zeex/samp-plugin-...ith-debug-info


Re: [HELP] negative index -1 - Luca12 - 19.06.2014

yes I try all of that and I never cant' get the line where is that error I try everything always I get where is the problem I mean like some public or command and the name of error for exaple runtime error 3 etc but never the line.


Re: [HELP] negative index -1 - Konstantinos - 19.06.2014

You also need to re-compile your scripts after creating pawn.cfg (to pawno folder and "-d3" init) file.


Re: [HELP] negative index -1 - Luca12 - 19.06.2014

yes I do that this morning and nothing always get that what I post here. Thanks