Error in server log - 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: Error in server log (
/showthread.php?tid=660911)
Error in server log -
Spawe - 17.11.2018
Error:
PHP Code:
[debug] Run time error 4: "Array index out of bounds"
[00:53:59] [debug] AMX backtrace:
[00:53:59] [debug] #0 00040b8c in public OnPlayerDeath (0, 65535, 255) from TDM.amx
[00:53:59] [death] Spawe died 255
public OnPlayerDeath
PHP Code:
public OnPlayerDeath(playerid, killerid, reason)
{
SendDeathMessage(killerid, playerid, reason);
PlayerInfo[killerid][cDinero] += 400;
PlayerInfo[killerid][cKills] += 1;
{
SetPlayerScore(killerid,(GetPlayerScore(killerid))+1);
GivePlayerMoney(killerid, 400);
}
new string[50];
format(string, sizeof(string), "~g~+$400");
GameTextForPlayer(killerid, string, 3000, 1);
return 1;
}
Re: Error in server log -
BigETI - 17.11.2018
If you inspect your error message again, you will see that "killerid" has returned "65535", which is by definition an invalid player ID.
Re: Error in server log -
Spawe - 17.11.2018
Quote:
Originally Posted by BigETI
If you inspect your error message again, you will see that "killerid" has returned "65535", which is by definition an invalid player ID.
|
What is the solution in this case?
Re: Error in server log -
BigETI - 17.11.2018
Check if killerid is valid or not.
Re: Error in server log -
Spawe - 17.11.2018
Quote:
Originally Posted by BigETI
Check if killerid is valid or not.
|
I do not know how, it's that I'm new xd
Re: Error in server log -
CantBeJohn - 17.11.2018
Quote:
Originally Posted by Spawe
I do not know how, it's that I'm new xd
|
The SA:MP Wiki gives an example how, here:
https://sampwiki.blast.hk/wiki/OnPlayerDeath
Otherwise, instead of how it's done in the wiki. You can use "if(IsPlayerConnected(killerid))" to check if killerid is valid (a valid player that's connected on the server currently) or not.
Re: Error in server log -
Spawe - 17.11.2018
Thanks you bro <3