Vehicle health = Money
#1

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!
Reply
#2

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.
Reply
#3

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);
Reply
#4

Ooooh, I see, thank you very much!
Reply
#5

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).
Reply
#6

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...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)