Posts: 762
Threads: 157
Joined: Feb 2009
Reputation:
0
Im making a "crane" where you can sell certain cars fro cash, and i wanted to make it so the worse damage for the car the less you get paid.
I wanted to do something like: for every damage of 10, you lose 1K or something like that but im not sure how i do that math code.
Thanks for Any Help!
Posts: 156
Threads: 3
Joined: Jan 2008
Reputation:
0
You can do it like this:
final_price = ( undamaged_car_price * ( car_health / max_car_health ) )
if undamaged_car_price is 100000$, and if car is damaged 40% (car_health=600) then it is
final_price = ( 100000 * ( 600 / 1000 ) ) = ( 100000 * 0.6 ) = 60000$
It is not realistic because more the car is damaged, and less it will cost money, not proportionally, i think, if car is damaged only 20% then price should be ~60% of undamaged car price, and if damage is 50% then price should be ~25% of undamaged car price.. Need think about this but it is too late in now : ))
Posts: 762
Threads: 157
Joined: Feb 2009
Reputation:
0
thanks guys but which method do i use? lol they both sound good...
Posts: 651
Threads: 15
Joined: Nov 2007
Reputation:
0
new
const perGain = 10000,//10k
const modDamage = 100,//default vehicle health is 1000.0
const defaultPrice = 0
Float:Vechp;
GetVehicleHealth(GetPlayerVehicleID(playerid),Vech p);
new
const earnCash = perGain*(Vechp/modDamage)+defaultPrice;
GivePlayerMoney(playerid,earnCash);
printf("earn %d",earnCash);
Converse thought.
Edited some type error
Posts: 762
Threads: 157
Joined: Feb 2009
Reputation:
0
so if that gives error.... which one is best? i got 3 suggestions for 3 diff ways.... anyone think 1 will work better than the other? or should i just pick a random suggestion...
Posts: 55
Threads: 4
Joined: Jan 2009
Reputation:
0
well how do you plan on having the person sell their car? Checkpoint, text command?