30.03.2011, 17:45
(
Последний раз редактировалось swieberdevos; 31.03.2011 в 12:40.
)
This is my script:
My problem is that the fuel instantly says when entering the vehicle: i..............
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;
}