SA-MP Forums Archive
receives score when playerid dies in the vehicle per killerid (OnPlayerDeath) - 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: receives score when playerid dies in the vehicle per killerid (OnPlayerDeath) (/showthread.php?tid=654759)



receives score when playerid dies in the vehicle per killerid (OnPlayerDeath) - PaulCrouseVS - 05.06.2018

How would I do it? in onplayerdeath...

I've tried with this:

Код:
public OnPlayerDeath(playerid, killerid, reason){
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER){ //this
DateM[killerid][cKills] += 1;
DateM[playerid][cDeaths] += 1;}

if(killerid != INVALID_PLAYER_ID){
DateM[killerid][cKills]+= 1;
switch(DateM[killerid][cKills]){
case 2:{ //2 kills
DateM[killerid][cLevel]++;
SetPlayerScore(killerid, (GetPlayerScore(killerid)+ DateM[killerid][cLevel]));}
}
}
return 1;}
but nothing


Re: receives score when playerid dies in the vehicle per killerid (OnPlayerDeath) - Sew_Sumi - 05.06.2018

You start using killerid, before you've checked if killerid is invalid... That's a good way to cause your server to crash...

Код:
DateM[killerid][cKills] += 1;
DateM[playerid][cDeaths] += 1;}

if(killerid != INVALID_PLAYER_ID){