SA-MP Forums Archive
Invalid memory access OnPlayerGiveDamage - 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: Invalid memory access OnPlayerGiveDamage (/showthread.php?tid=542475)



Invalid memory access OnPlayerGiveDamage - liinor - 19.10.2014

Pretty often server gets spammed of this error . It should fixed so it wont be freezing or crashing my server / slowing down.
Quote:

[12:35:09] [debug] Run time error 5: "Invalid memory access"
[12:35:09] [debug] AMX backtrace:
[12:35:09] [debug] #0 0024985c in public OnPlayerGiveDamage (0x00000003, 0x00000005, 0x411e6667, 0x0000001e, 0x00000004) from NytLoppuHelvetti.amx

pawn Код:
Public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid, bodypart)
{

    new damagesveh = GetPlayerVehicleID(damagedid);
    if(GetPlayerBySeatID(damagesveh, 0) != -1 && IsPlayerInAnyVehicle(damagedid))
    {
    new noobid=GetPlayerBySeatID(damagesveh,0);
    if(GetPVarInt(noobid, "fundisablingreason") == playerid) SetPVarInt(noobid, "disableFun",60);
    SetPVarInt(noobid, "disableFun",60);
    SetPVarInt(noobid, "fundisablingreason",playerid);
    if(GetPVarInt(noobid, "autofix") == 1) {
    SendClientMessage(noobid,0xFF0000FF,"* AUTOFIX OFF");
    SetPVarInt(noobid, "autofix", 0);
    }
   
    }
    SetPVarInt(damagedid, "disableFun",60);
    SetPVarInt(damagedid, "fundisablingreason",playerid);
    SetPVarInt(playerid, "disableFun",60);
    SetPVarInt(playerid, "fundisablingreason",damagedid);

   
   if(GetPVarInt(playerid, "autofix") == 1) {
   SendClientMessage(playerid,0xFF0000FF,"* AUTOFIX OFF");
   SetPVarInt(playerid, "autofix", 0);
   }
return 1;
}
pawn Код:
stock GetPlayerBySeatID(vehicleid,seatid)
    {
    new seatanswer=0;
    foreach (new i : Player)
    {
   
    if(IsPlayerConnected(i) && GetPlayerVehicleID(i) == vehicleid && GetPlayerVehicleSeat(i) == seatid)
    {
    seatanswer=i;
    }
    }
    return seatanswer;
    }