Fuel system problem -
swieberdevos - 30.03.2011
This is my script:
pawn Код:
new VehicleFuel[MAX_VEHICLES];
public OnGameModeInit()
for(new i = 0; i < MAX_VEHICLES; i++)
{
VehicleFuel[i] = 150;
}
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
vtimer = SetTimerEx("VehMeterStuff",500,true,"i",playerid);
return 1;
}
public VehMeterStuff(playerid)
{
new Float:x,Float:y,Float:z;
new vehicleid = GetPlayerVehicleID(playerid);
new engine, lights, alarm, doors, bonnet, boot, objective;
if(IsPlayerInAnyVehicle(playerid))
{
GetVehicleVelocity(vehicleid,x,y,z);
if(floatround(floatsqroot(((x*x)+(y*y))+(z*z))*250.666667) > 1)
{
VehicleFuel[vehicleid] -= 1;
}
if(VehicleFuel[vehicleid] == 141 || 160) { format(fuelstr,sizeof(fuelstr),"iiiiiiiiiiiii"); }
if(VehicleFuel[vehicleid] == 131 || 140) { format(fuelstr,sizeof(fuelstr),"iiiiiiiiiiii."); }
if(VehicleFuel[vehicleid] == 121 || 130) { format(fuelstr,sizeof(fuelstr),"iiiiiiiiiii.."); }
if(VehicleFuel[vehicleid] == 111 || 120) { format(fuelstr,sizeof(fuelstr),"iiiiiiiiii..."); }
if(VehicleFuel[vehicleid] == 101 || 110) { format(fuelstr,sizeof(fuelstr),"iiiiiiiii...."); }
if(VehicleFuel[vehicleid] == 91 || 100) { format(fuelstr,sizeof(fuelstr),"iiiiiiiii....."); }
if(VehicleFuel[vehicleid] == 81 || 90) { format(fuelstr,sizeof(fuelstr),"iiiiiiiii......"); }
if(VehicleFuel[vehicleid] == 71 || 80) { format(fuelstr,sizeof(fuelstr),"iiiiiiii......."); }
if(VehicleFuel[vehicleid] == 61 || 70) { format(fuelstr,sizeof(fuelstr),"iiiiiii........"); }
if(VehicleFuel[vehicleid] == 51 || 60) { format(fuelstr,sizeof(fuelstr),"iiiiii........."); }
if(VehicleFuel[vehicleid] == 41 || 50) { format(fuelstr,sizeof(fuelstr),"iiiii.........."); }
if(VehicleFuel[vehicleid] == 31 || 40) { format(fuelstr,sizeof(fuelstr),"iiii..........."); }
if(VehicleFuel[vehicleid] == 21 || 30) { format(fuelstr,sizeof(fuelstr),"iii............"); }
if(VehicleFuel[vehicleid] == 11 || 20) { format(fuelstr,sizeof(fuelstr),"ii............."); }
if(VehicleFuel[vehicleid] == 1 || 10) { format(fuelstr,sizeof(fuelstr),"i.............."); }
if(VehicleFuel[vehicleid] == 0)
{
format(fuelstr,sizeof(fuelstr),"...............");
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vehicleid, false, lights, false, doors, bonnet, boot, objective);
TextDrawSetString(VehMeter[playerid], "~w~You have ~r~no~w~ fuel. In order to drive further you have to ~r~refuel~w~ the vehicle!");
KillTimer(vtimer);
}
TextDrawShowForPlayer(playerid, VehMeter[playerid]);
format(str,sizeof(str),"Speed: %d km/h~n~State: Perfect~n~Fuel: %s~n~.....",floatround(floatsqroot(((x*x)+(y*y))+(z*z))*250.666667),fuelstr);
TextDrawSetString(VehMeter[playerid], str);
}
return true;
}
My problem is that the fuel instantly says when entering the vehicle: i..............
Re: Fuel system problem -
Medal Of Honor team - 30.03.2011
Код:
My problem is that the fuel instantly says when entering the vehicle: i..............
then what?
Re: Fuel system problem -
park4bmx - 30.03.2011
loL nice probblem u got there
More INFO would be nice
Re: Fuel system problem -
KaleOtter - 30.03.2011
Well I either doesn't really understand your problem, but maybe you should also kill the timer in OnPlayerExitVehicle.
Or better in OnPlayerStateChange.
Re: Fuel system problem -
swieberdevos - 31.03.2011
When the fuel is 150 (full) *setting full at ongamemodeinit* and i enter a vehicle it says:
fuel: i..............
it should be as written in the script..
Re: Fuel system problem -
swieberdevos - 31.03.2011
Anyone please?
Re: Fuel system problem -
-Rebel Son- - 31.03.2011
Do you want it to have full fuel when you first enter a vehicle?
Re: Fuel system problem -
swieberdevos - 31.03.2011
Ye, but this is done on ongamemodeinit already..
Re: Fuel system problem -
-Rebel Son- - 31.03.2011
Do it on, OnPlayerentervehicle.
Re: Fuel system problem -
swieberdevos - 31.03.2011
Then it would be set the whole time to 150.. I just want it once when the server starts.