[debug] Accessing element at 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: [debug] Accessing element at negative index -1 (
/showthread.php?tid=624080)
[debug] Accessing element at negative index -1 -
TaylorShade - 10.12.2016
From server log:
Код:
[17:17:36] [debug] Run time error 4: "Array index out of bounds"
[17:17:36] [debug] Accessing element at negative index -1
[17:17:36] [debug] AMX backtrace:
[17:17:36] [debug] #0 0056cb98 in BussinesMoney (bussinesID=45, ammount=120, id=-1) at C:\Users\xxx\Desktop\mode\Server\gamemodes\xFG.pwn:17583
[17:17:36] [debug] #1 0056e084 in BussinesJobMoney (jobID=10, ammount=120) at C:\Users\xxx\Desktop\mode\Server\gamemodes\xFG.pwn:17759
[17:17:36] [debug] #2 006a355c in ?? (... <1 argument>) at C:\Users\xxx\Desktop\mode\Server\gamemodes\xFG.pwn:34472
[17:17:36] [debug] #3 0000ef38 in public OnPlayerEnterCheckpoint (playerid=74) at C:\Users\xxx\Desktop\mode\Compiler\include\YSI\y_hooks/impl.inc:1146
BusinessMoney:
Код:
stock BussinesMoney( bussinesID, ammount, id ) {
if( bussinesID == -1 ) return 1;
if(PlayerInfo[ id ][ xOnlineSati ] < 3 && id != -1) return 1;
if( ammount < 0 || ammount > 99999999 ) return 1;
if( BussinesInfo[ bussinesID ][ bReket ] == -1 ) {
BussinesInfo[ bussinesID ][ bMoney ] += ammount;
SaveBussines( bussinesID );
}
else if( BussinesInfo[ bussinesID ][ bReket ] != -1 ) {
new dvajesposto = (ammount/100)*20;
new osamdesetposto = (ammount/100)*80;
BussinesInfo[ bussinesID ][ bMoney ] += osamdesetposto;
SaveBussines( bussinesID );
OI[ BussinesInfo[ bussinesID ][ bReket ] ][ oSafeMoney ] += dvajesposto;
SaveBussines( BussinesInfo[ bussinesID ][ bReket ] );
}
return 1;
}
BusinessJobMoney
Код:
stock BussinesJobMoney( jobID, ammount ) {
new bussinesID = -1;
for (new i = 1; i < MAX_BUSSINES; i++ ) {
if( BussinesInfo[ i ][ bType ] == VRSTA_POSAO ) {
if( BussinesInfo[ i ][ bJobID ] == jobID ) {
bussinesID = i;
break;
}
}
}
if( bussinesID == -1 ) return 1;
BussinesMoney( bussinesID, ammount, -1 );
return 1;
}
Re: [debug] Accessing element at negative index -1 -
Konstantinos - 10.12.2016
Swap them:
pawn Код:
if( id != -1 && PlayerInfo[ id ][ xOnlineSati ] < 3) return 1;
If
id is -1 then the
xOnlineSati check won't be performed.