/stats > deaths never changes
#1

---------- fixed

When I type /stats my deaths is 1 but when i do /kill and after i respawn do /stats again its still 1

How do I fix this?
Reply
#2

public OnPlayerDeath(playerid, killerid, reason)
{
PlayerInfo[playerid][pAlive] = 0;
PlayerInfo[killerid][pKills]++;
PlayerInfo[playerid][pDeaths]++;
return 1;
}

killerid if you do /kill is INVALID_PLAYER_ID and it's out of bounds of the array.

So do:


public OnPlayerDeath(playerid, killerid, reason)
{
PlayerInfo[playerid][pAlive] = 0;
if (IsPlayerConnected(killerid)) //
PlayerInfo[killerid][pKills]++;
PlayerInfo[playerid][pDeaths]++;
return 1;
}
Reply
#3

I copy from SA-MP Wiki,

pawn Код:
Image:32px-Circle-style-warning.png     Important Note: You MUST check whether killerid equals INVALID_PLAYER_ID before using it in an array, as it will cause the script to stop. See example above.


Image:32px-Ambox_warning_orange.png     Note: You do not need to check whether killerid is INVALID_PLAYER_ID before using it in SendDeathMessage. INVALID_PLAYER_ID is a valid killerid ID parameter in that function.
Source: https://sampwiki.blast.hk/wiki/OnPlayerDeath

I don't think it will solve it. But it's neccesary.
Reply
#4

It seems that the onplayerdeath callback does not get triggered when you die. I had the same problem and in order to solve this I united the gamemode with the reg/log filterscript. In gamemode the onplayerdeath works fine.
Reply
#5

Thanks guys, indeed killerid is unknown in /kill
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)