SA-MP Forums Archive
Server crashes when a player gets killed. - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Server crashes when a player gets killed. (/showthread.php?tid=199208)



Server crashes when a player gets killed. - twinki - 14.12.2010

Hello guys,i got a problem with my script.The server crashes when i shoot the player the 3th time...When he should die the server crash.Ill put here my OnPlayerDeath:
public OnPlayerDeath(playerid, killerid, reason)
{
SetPlayerScore(killerid,GetPlayerScore(killerid)+1 );
ECash[playerid] += 2;
SendClientMessage(killerid, "a message...");
SetPlayerScore(playerid,GetPlayerScore(playerid)-1);
ECash[playerid] -= 1;
SendClientMessage(playerid, "another message...");
return 1;
}
Thanks.


Re: Server crashes when a player gets killed. - Lynn - 14.12.2010

Try chaning
pawn Код:
ECash[playerid] += 2;
to
pawn Код:
ECash[killerid] += 2;



Re: Server crashes when a player gets killed. - Mauzen - 14.12.2010

is you ECash array big enough? It should be
new ECash[MAX_PLAYERS];
for example. If the array index is out of bounds (new ECash[2], ECash[12] +=2) this could crash the server.


Re: Server crashes when a player gets killed. - twinki - 14.12.2010

Quote:
Originally Posted by Lynn
Посмотреть сообщение
Try chaning
pawn Код:
ECash[playerid] += 2;
to
pawn Код:
ECash[killerid] += 2;
Ive tried that but still i get the same errors:
new.pwn(401) : error 035: argument type mismatch (argument 2)
new.pwn(404) : error 035: argument type mismatch (argument 2)


Re: Server crashes when a player gets killed. - Mauzen - 14.12.2010

Are the error lines the SendCcientMessage stuff? I guess so, you are missing the color parameter there.

change
SendClientMessage(killerid, "a message...");
to
SendClientMessage(killerid, 0xFF3333FF, "a message...");

in both cases

0xFF3333FF is a color code, change it to whatever color you would like, this is red now. There are infos about this in the wiki and the forum.


Re: Server crashes when a player gets killed. - twinki - 14.12.2010

Quote:
Originally Posted by Mauzen
Посмотреть сообщение
Are the error lines the SendCcientMessage stuff? I guess so, you are missing the color parameter there.

change
SendClientMessage(killerid, "a message...");
to
SendClientMessage(killerid, 0xFF3333FF, "a message...");

in both cases

0xFF3333FF is a color code, change it to whatever color you would like, this is red now. There are infos about this in the wiki and the forum.
Yeah seems like i forgot the colours,i did it in rush .Thanks guys,i dont get the errors now,ill test it and see if now it works fine.
edit:Oke,it fixed now,i needed to remove the part where the killer gets the score and the ECash,but anyone has any idea where to add the thingy which give's to the killer the score and ecash?Thanks


Re: Server crashes when a player gets killed. - twinki - 14.12.2010

Up with this