Strange issue: SetPlayerScore(playerid); - 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: Strange issue: SetPlayerScore(playerid); (
/showthread.php?tid=591035)
Strange issue: SetPlayerScore(playerid); -
Galletziz - 07.10.2015
Okey i have this strange issue with this function, i show my code:
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
SendDeathMessage(killerid, playerid, reason);
SetPlayerScore(playerid,GetPlayerScore(playerid)-1);
if(killerid != INVALID_PLAYER_ID){SetPlayerScore(killerid,GetPlayerScore(killerid)+1);}
return 1;
}
but when i try to test it and i suicide myself with a granade ( for example ) when the player dies the score still the same, why?
Re: Strange issue: SetPlayerScore(playerid); -
jihadmeneer - 07.10.2015
Try this.
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
new newscore = GetPlayerScore(playerid) --;
SendDeathMessage(killerid, playerid, reason);
SetPlayerScore(playerid, newscore);
if(killerid != INVALID_PLAYER_ID){SetPlayerScore(killerid,GetPlayerScore(killerid)+1);}
return 1;
}
Re: Strange issue: SetPlayerScore(playerid); -
iggy1 - 07.10.2015
Quote:
Originally Posted by jihadmeneer
Код:
GetPlayerScore(playerid) --;
|
That's not even valid code.
OP, problem might be that when you kill yourself - killerid will probably be INVALID_PLAYER_ID (as far as i can remember). So if you want to test it properly, just call OnPlayerDeath with your ID.
Код:
//Inside some command
OnPlayerDeath(NOT_PLAYERID, playerid, 0);
This is assuming it's the killer score that isn't changing. Your code should work btw.
EDIT: Also if it doesn't send INVALID_KILLER_ID, but instead your ID - you will just be decresing the score (playerid: your id) then increasing it (killerid: also your id) so it will have no effect.
Re: Strange issue: SetPlayerScore(playerid); -
Galletziz - 07.10.2015
Quote:
Originally Posted by iggy1
That's not even valid code.
OP, problem might be that when you kill yourself - killerid will probably be INVALID_PLAYER_ID (as far as i can remember). So if you want to test it properly, just call OnPlayerDeath with your ID.
Код:
//Inside some command
OnPlayerDeath(NOT_PLAYERID, playerid, 0);
This is assuming it's the killer score that isn't changing. Your code should work btw.
EDIT: Also if it doesn't send INVALID_KILLER_ID, but instead your ID - you will just be decresing the score (playerid: your id) then increasing it (killerid: also your id) so it will have no effect.
|
Thanks, solved.