My car jacker command is jacked up.
#1

K so I'm not really new to scripting however I'm not the best.

I'm editing the GF script just for practice and this is part of the car jacker job when a person brings a car back to the drop off this is what figures their money.

Basically I want the script to find out how much HP the car has, then take the max they can earn for level 1 and divide it by how much HP the car has (Say the car has 1000 HP so it would take 5000 / 1000 = Div)
Then I want it to take the max price of the car and subtract the damage that's been done to it (5000 - div [Which in this case is 5] + 5 [For the 5 that it is off from the 5000/1000])

So the pay out price in this scenario would be $5,000.

But in the game it's only giving me $5

Help?


Код:
  		new veh = GetPlayerVehicleID(playerid);
			new Float:health;
  			new HP = GetVehicleHealth(veh, health);
  			new Div = 5000 / HP;
  			new price = 5000 - Div + 5;
			format(string, sizeof(string), "You sold a car for $%d, your reload time is 20 minutes.", price);
		    SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
			GivePlayerMoney(playerid, price);
			PlayerInfo[playerid][pCarTime] = 0;
Reply
#2

When you do GetVehicleHealth(veh, health);, the vehicle health is stored in the variable 'health', therefor there is no need for HP.
Try doing
new Div = 5000 / health;
Reply
#3

Quote:
Originally Posted by dice7
When you do GetVehicleHealth(veh, health);, the vehicle health is stored in the variable 'health', therefor there is no need for HP.
Try doing
new Div = 5000 / health;
I tried it and I got an error on the line with new Div.

C:\Users\User\Desktop\gamemodes\gf.pwn(3462) : warning 213: tag mismatch

Also it gives me -$100305596045994659.
Reply
#4

Probably because the 'health' is a float and 'div' is an integer.

pawn Код:
new HP = floatround(health, floatround_round); //Rounds to the nearest integer.
new Div = 5000 / HP;
Reply
#5

Quote:
Originally Posted by dice7
Probably because the 'health' is a float and 'div' is an integer.

pawn Код:
new HP = floatround(health, floatround_round); //Rounds to the nearest integer.
new Div = 5000 / HP;
Thank you, it worked!

Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)