SA-MP Forums Archive
Help: Error CrashDetect. - 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: Error CrashDetect. (/showthread.php?tid=657839)



Help: Error CrashDetect. - bookknp - 16.08.2018

Hello guys, i need help... i compile perfectly with pawn, but crashdetect report this error. why??

PHP код:
[debugRun time error 4"Array index out of bounds"
[debug]  Attempted to read/write array element at negative index -1
[debugAMX backtrace:
[
debug#0 003c795c in public OnPlayerUpdate (playerid=2) at C:\Users\1320703\Desktop\GTA3\Server2\gamemodes\KoN.pwn:22859 
PHP код:
if (ud == KEY_UP)
{
 if(
GetPlayerState(playerid) != PLAYER_STATE_ONFOOT) return 1;
    new 
slot = -1;
    new 
Float:xFloat:yFloat:z;
    for(new 
0MAX_OBJi++)
        if(
dGunData[i][ObjData][0] > && IsValidObject(dGunData[i][ObjData][0]))
        {
            
GetObjectPos(dGunData[i][ObjData][0], xyz);
            if(
IsPlayerInRangeOfPoint(playerid2.0xyz))
            {
                
slot i;
                break;
            }
        }
    
    
    
DestroyObject(dGunData[slot][ObjData][0]);    // <--------------- 22859 Line Error
    
GivePlayerWeapon(playeriddGunData[slot][ObjData][1], dGunData[slot][ObjData][2]);
    
dGunData[slot][ObjData][0] = 0;
    new 
buffer[50];
    
format(buffersizeof(buffer), "%s"GunNames[dGunData[slot][ObjData][1]]);




Re: Help: Error CrashDetect. - Calisthenics - 16.08.2018

If no object found, slot would be -1. Put the last 5 lines in an if statement (slot != -1)


Re: Help: Error CrashDetect. - bookknp - 16.08.2018

Quote:
Originally Posted by Calisthenics
Посмотреть сообщение
If no object found, slot would be -1. Put the last 5 lines in an if statement (slot != -1)
very thx friend +rep