SA-MP Forums Archive
SetPlayerScore - 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: SetPlayerScore (/showthread.php?tid=468155)



SetPlayerScore - CesarLT - 06.10.2013

Hello everyone, I am having trouble with the score setting, is that possible to make, that once a player uses a command, 20 of his OWN score, (score counts for kills at my gm) will be taken?

And another thing, is is it possible that once a player uses a command, his health will be saved, and once he disables it, it will return to his own? (At the period, his health will be 9999999).

Thanks in advance.


Re: SetPlayerScore - efrim123 - 06.10.2013

Post your code please of the command and if you want it to take from the player score do this

pawn Код:
SetPlayerScore(playerid, GetPlayerScore(playerid) - 20);



Re: SetPlayerScore - -Prodigy- - 06.10.2013

To remove their score:
pawn Код:
SetPlayerScore(playerid, GetPlayerScore(playerid) - 20);
To save their HP:
pawn Код:
new Float: HP[2]; // Global or something

// when they use the cmd:
GetPlayerHealth(playerid, HP[0]);
GetPlayerArmour(playerid, HP[1]);

SetPlayerHealth(playerid, 99999999);
// when you want to give their health back
SetPlayerHealth(playerid, HP[0]);
SetPlayerArmour(playerid, HP[1]);



Re: SetPlayerScore - CesarLT - 06.10.2013

Quote:
Originally Posted by efrim123
Посмотреть сообщение
Post your code please of the command and if you want it to take from the player score do this

pawn Код:
SetPlayerScore(playerid, GetPlayerScore(playerid) - 20);
Quote:
Originally Posted by -Prodigy-
Посмотреть сообщение
To remove their score:
pawn Код:
SetPlayerScore(playerid, GetPlayerScore(playerid) - 20);
To save their HP:
pawn Код:
new Float: HP[2]; // Global or something

// when they use the cmd:
GetPlayerHealth(playerid, HP[0]);
GetPlayerArmour(playerid, HP[1]);

SetPlayerHealth(playerid, 99999999);
// when you want to give their health back
SetPlayerHealth(playerid, HP[0]);
SetPlayerArmour(playerid, HP[1]);
Thanks both , was really helpfull.


Re: SetPlayerScore - AnonScripter - 06.10.2013

or easy way is:
pawn Код:
new playerscore = GetPlayerScore(playerid);
SetPlayerScore(playerid, playerscore - 20);



Re: SetPlayerScore - EiresJason - 06.10.2013

That's exactly the same as:
pawn Код:
SetPlayerScore(playerid, GetPlayerScore(playerid) - 20);
Though I think the method above is more efficient as it creates 1 less variable.