AMX Backtrace problem - 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: AMX Backtrace problem (
/showthread.php?tid=657856)
AMX Backtrace problem -
antixgaming - 16.08.2018
I have problem. I tried to search for it, but I couln't find any solutions.
When player die this happens in my console:
Код:
[debug] Run time error 4: "Array index out of bounds"
[debug] Attempted to read/write array element at index 65535 in array of size 1000
[debug] AMX backtrace:
[debug] #0 00038a48 in public OnPlayerDeath (0, 65535, 255) from SCRP.amx
This is the code from script:
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
taser[playerid] = false;
GiveTaserAgainTimer[playerid] = 0;
lastWeapon[playerid] = 0;
rp[killerid]++;
GameTextForPlayer(killerid, "~y~+1 RP", 3000, 6);
if(bounted[playerid] > 499)
{
if(playerid != killerid)
{
GivePlayerCash(killerid, bounted[playerid]);
SCM(playerid, COLOR_LIGHTRED, "Ubijen si! Tvoja cijena za glavu je ukinuta.");
SCM(killerid, COLOR_LIGHTBLUE, "Ubio si igraca s cijenom za njegovu/njezinu glavu.");
bounted[playerid] = 0;
}
}
if(robbing == 1)
{
KillTimer(robbingtimer);
robbing = 0;
new string[128], name[MAX_PLAYER_NAME];
GetPlayerName(killerid, name, sizeof(name));
format(string, sizeof(string), "[VIJESTI]: Banka je spaљena od pljackanja. Pomogao u tome: %s (%i)", name,killerid);
SendClientMessageToAll(COLOR_YELLOW, string);
}
if(Player[playerid][police] == 1)
{
if(playerid != killerid)
{
SetPlayerWantedLevel(killerid, 4);
SCM(killerid, COLOR_LIGHTRED, "Ubio si policajca! Dobio si wanted level 4!");
}
}
zaposlen[playerid] = 0;
DisablePlayerCheckpoint(playerid);
if(gTime[playerid][firsttime] == 1)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
format(thisfile,sizeof(thisfile),mydata,name);
dini_IntSet(thisfile,"firsttime",1);
}
return 1;
}
Thanks for anyone who knows right solution.
Re: AMX Backtrace problem -
jlalt - 16.08.2018
You have to check if killer id is valid [ not self kill ] then do actions on killerid..
PHP код:
public OnPlayerDeath(playerid, killerid, reason)
{
taser[playerid] = false;
GiveTaserAgainTimer[playerid] = 0;
lastWeapon[playerid] = 0;
if(killerid != 65535)
{
rp[killerid]++;
GameTextForPlayer(killerid, "~y~+1 RP", 3000, 6);
}
if(bounted[playerid] > 499)
{
if(killerid != 65535/* && playerid != killerid*/)
{
GivePlayerCash(killerid, bounted[playerid]);
SCM(playerid, COLOR_LIGHTRED, "Ubijen si! Tvoja cijena za glavu je ukinuta.");
SCM(killerid, COLOR_LIGHTBLUE, "Ubio si igraca s cijenom za njegovu/njezinu glavu.");
bounted[playerid] = 0;
}
}
if(robbing == 1)
{
KillTimer(robbingtimer);
robbing = 0;
if(killerid != 65535)
{
new string[128], name[MAX_PLAYER_NAME];
GetPlayerName(killerid, name, sizeof(name));
format(string, sizeof(string), "[VIJESTI]: Banka je spaљena od pljackanja. Pomogao u tome: %s (%i)", name,killerid);
SendClientMessageToAll(COLOR_YELLOW, string);
}
}
if(Player[playerid][police] == 1)
{
if(killerid != 65535/* && playerid != killerid*/)
{
SetPlayerWantedLevel(killerid, 4);
SCM(killerid, COLOR_LIGHTRED, "Ubio si policajca! Dobio si wanted level 4!");
}
}
zaposlen[playerid] = 0;
DisablePlayerCheckpoint(playerid);
if(gTime[playerid][firsttime] == 1)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
format(thisfile,sizeof(thisfile),mydata,name);
dini_IntSet(thisfile,"firsttime",1);
}
return 1;
}
Re: AMX Backtrace problem -
antixgaming - 16.08.2018
Thanks! Thank you very much!