SA-MP Forums Archive
Vehicle health = Money - 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: Vehicle health = Money (/showthread.php?tid=631348)



Vehicle health = Money - Mikueh - 27.03.2017

Hello!

How can I give the player money which is the exact same amount as the vehicle health?

Код:
new Float:health;
new veh = GetPlayerVehicleID(playerid);
GetVehicleHealth(veh, health);
GivePlayerMoney(playerid, health * 10);
That's what I've got so far, but it's gives me a tag mismatch warning for the GivePlayerMoney line, and also, in-game the money just goes, infinite, I guess... The numbers just goes up and up. So it would be like if the vehicle have like 980HP the player will get $9800.

Thank you for the help!


Re: Vehicle health = Money - ikkentim - 27.03.2017

GivePlayerMoney adds to the current player's balance. You need to reset their money first. Also, health is a float, and you need to pass an integer on to GivePlayerMoney.


Re: Vehicle health = Money - GoldenLion - 27.03.2017

Health is a float, you need to round it first to make an integer from it using floatround. Like this:
Код:
new Float:health;
new veh = GetPlayerVehicleID(playerid);
GetVehicleHealth(veh, health);
GivePlayerMoney(playerid, floatround(health) * 10);



Re: Vehicle health = Money - Mikueh - 27.03.2017

Ooooh, I see, thank you very much!


Re: Vehicle health = Money - ikkentim - 27.03.2017

Quote:
Originally Posted by GoldenLion
Посмотреть сообщение
Health is a float, you need to round it first to make an integer from it using floatround. Like this:
Код:
new Float:health;
new veh = GetPlayerVehicleID(playerid);
GetVehicleHealth(veh, health);
GivePlayerMoney(playerid, floatround(health) * 10);
This will still make the money counter go up and up, you need to reset the money first using ResetPlayerMoney(playerid).


Re: Vehicle health = Money - Mikueh - 28.03.2017

Quote:
Originally Posted by ikkentim
Посмотреть сообщение
This will still make the money counter go up and up, you need to reset the money first using ResetPlayerMoney(playerid).
Ahm, I dunno, it's works perfecly for me...