Placeholder problem - 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: Placeholder problem (
/showthread.php?tid=320567)
Placeholder problem -
Gumica - 23.02.2012
pawn Код:
COMMAND:sethp(playerid, params[])
{
new user, amount;
if(sscanf(params, "ui", user, amount)) return SendClientMessage(playerid, 0x924161FF, "USAGE: /sethp <player id/name> <amount>");
new string[180], name[MAX_PLAYER_NAME], Float:health;
SetPlayerHealth(user, amount);
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "Your health has been set to %f from %s", health, name);
SendClientMessage(user, 0x924161FF, string);
return 1;
}
I can't get player's health at line:
pawn Код:
format(string, sizeof(string), "Your health has been set to %f from %s", health, name);
Can someone explain me how I can get this working, pls?
Re: Placeholder problem - T0pAz - 23.02.2012
pawn Код:
GetPlayerHealth(playerid, health);
under GetPlayerName. You've forget to get the player's health as a result the var value is 0.0.
Re: Placeholder problem -
Gumica - 23.02.2012
Quote:
Originally Posted by T0pAz
pawn Код:
GetPlayerHealth(playerid, health);
under GetPlayerName. You've forget to get the player's health as a result the var value is 0.0.
|
Well, when I set HP to player it puts incorrect numbers of health, I meant result does not match with HP. it shows 95.045454567444 when I use /sethp 0 1.
Re: Placeholder problem - T0pAz - 23.02.2012
It's because health are
float's on gta sa and your setting the value as an
integer. Use the
Float: tag on amount and change the sscanf specifier to
f.
Re: Placeholder problem -
Gumica - 23.02.2012
Quote:
Originally Posted by T0pAz
It's because health are float's on gta sa and your setting the value as an integer. Use the Float: tag on amount and change the sscanf specifier to f.
|
Everything works fine, thank you very much for this I hope I learned it :P