Command broken, don't know why.
#1

This is my code:

Код:
CMD:heal(playerid, params[])
{
	new Float:health, Float:tbhealedhealth, Float:healprice, Float:healtime, string[128];
	GetPlayerHealth(playerid, Float:health);
	tbhealedhealth = 100-health;
	healprice = tbhealedhealth*10;
	healtime = tbhealedhealth*100;
	
	format(string, sizeof(string), "health: %d | tbhealedhealth: %d | healprice: %d | healtime: %d", health, tbhealedhealth, healprice, healtime);
	SendClientMessage(playerid, -1, string);
	
	/*if(IsPlayerInRangeOfPoint(playerid, 5, HealPos1X, HealPos1Y, HealPos1Z))
	{
	    if(health < 100)
	    {
	        SendClientMessage(playerid, GREY, "test");
		}
	}*/
	return 1;
}
Obv it isn't going to output that message when I'm done scripting... But it was just put there to test to see if the values work. Thing is, they don't, and I have no idea why. Health becomes something like 12332435 or something crazy. Everything else is 0.

I have no idea why. Help?
Reply
#2

pawn Код:
tbhealedhealth = 100-health; // 100 - 100 = ?
healprice = tbhealedhealth*10; // tbhealedhealth * 10 = 0 * 10 = ?
healtime = tbhealedhealth*100; // 0*100 = ?
and health: %d replace to health: %.4f
Reply
#3

Quote:
Originally Posted by Jefff
Посмотреть сообщение
pawn Код:
tbhealedhealth = 100-health; // 100 - 100 = ?
healprice = tbhealedhealth*10; // tbhealedhealth * 10 = 0 * 10 = ?
healtime = tbhealedhealth*100; // 0*100 = ?
and health: %d replace to health: %.4f
Thanks, will check if it works. That code is to calculate how much health is to be healed, as that is needed to calculate the time the player will spend in hospital (health to be healed in seconds) and the cost (health to be healed * 10 in dollars)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)