/sethp command shows 1203102301 health.
#1

Hello, I created a /sethp command, it works fine, it just shows my HP has been set to 3284234928, while it gives the right amount of HP.

Код:
CMD:sethp(playerid, params[])
{
	static
		userid,
	    Float:amount;

	if (PlayerData[playerid][pAdmin] < 2)
	    return SendErrorMessage(playerid, "You don't have permission to use this command.");

	if (sscanf(params, "uf", userid, amount))
		return SendSyntaxMessage(playerid, "/sethp [PlayerName/PlayerID] [0-100]");

	if (userid == INVALID_PLAYER_ID)
	    return SendErrorMessage(playerid, "You have specified an invalid player.");

	SetPlayerHealth(userid, amount);
	SendBlueColorMessage(playerid, "> You have set %s's Health to %d.", ReturnName(userid, 0), amount);
	SendBlueColorMessage(userid, "> Admin %s has set your Health to %d.", ReturnName(playerid, 0), amount);
	return 1;
}
What did I do wrong?
Reply
#2

Because you're using the wrong specifier.


When using %f, you'll get the entire float amount, e.g "97.319495", to avoid this you can use %.0f for no decimals, %.1f for 1 decimal (e.g. 97.3)
Reply
#3

Thanks worked!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)