SA-MP Forums Archive
Command broken, don't know why. - 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: Command broken, don't know why. (/showthread.php?tid=373014)



Command broken, don't know why. - Trekkx - 28.08.2012

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?


Re: Command broken, don't know why. - Jefff - 29.08.2012

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


Re: Command broken, don't know why. - Trekkx - 29.08.2012

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)