18.03.2015, 17:09
Well, it IS working, but now The plan I had is I'd make the fuel drop proportional to the speed of the car, naturally, this hasn't worked out well, as I moved the function above into it's own function for getting speed, so now it's producing some odd numbers....
Whenever the timer clicks to lower fuel, I have it set to print the formula I'm using to calculate the fuel drop, which is below, and then print the resulting fuel, except the number it's returning is really odd, the latest one was this:
1070836887
And when it subtracted that from the vehicle's fuel (in litres) no matter how many L of fuel the vehicle had (the Roadtrain has 200, the Infernus has 50L, both were affected in the exact same way.) The fuel drops to 0 right away, but when I look at the output, I get this:
B>b>
So, a little confused here, here's the relevant code snips:
And:
Whenever the timer clicks to lower fuel, I have it set to print the formula I'm using to calculate the fuel drop, which is below, and then print the resulting fuel, except the number it's returning is really odd, the latest one was this:
1070836887
And when it subtracted that from the vehicle's fuel (in litres) no matter how many L of fuel the vehicle had (the Roadtrain has 200, the Infernus has 50L, both were affected in the exact same way.) The fuel drops to 0 right away, but when I look at the output, I get this:
B>b>
So, a little confused here, here's the relevant code snips:
pawn Код:
public FuelTimer() {
foreach(Player,i) {
if(IsFueling[i]) continue;
new veh = GetPlayerVehicleID(i);
if(GetPlayerVehicleSeat(i) == 0) {
printf("%d",(GetVehSpeed(veh) * 3 / 100));
Fuel[veh] -= (GetVehSpeed(veh) * 3 / 100);//This and the one above and below are the calculation lines
print(Fuel[veh]);
if(Fuel[veh] < 1 || !IsAPushBike(veh)) {
Fuel[veh] = 0;
new engine,lights,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(veh,engine,lights,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(veh,0,0,alarm,doors,bonnet,boot,objective); }}
CallLocalFunction("Speedometer","i",i); }
return 1; }
pawn Код:
Float:GetVehSpeed(vehID) {
new Float:speed[3],Float:sSpeed;
GetVehicleVelocity(vehID, speed[0], speed[1], speed[2]);
sSpeed = floatsqroot((speed[0]*speed[0])+(speed[1]*speed[1])+(speed[2]*speed[2]))* 181.5;
return sSpeed; }