Ez egy nagyon alapvetõ üzemanyag rendszer, de ha ügyes vagy kicsit, meg lehet csinálni komolyra.
[pawn]
#include <a_samp>
forward SpeedoUpdate();
forward FuelUpdate();
new Text:box[MAX_PLAYERS],Text:fuel[MAX_PLAYERS];
new VehicleFuel[MAX_VEHICLES];
public OnFilterScriptInit()
{
SetTimer(\"SpeedoUpdate\",100,1);
SetTimer(\"FuelUpdate\",10000,1);
ManualVehicleEngineAndLights();
for(new i = 1;i<MAX_VEHICLES;i++)
{
VehicleFuel = 100 + random(50);
}
return 1;
}
public OnPlayerConnect(playerid)
{
box[playerid] = TextDrawCreate(618,389,\"_\");
TextDrawLetterSize(box[playerid],0.5,3.999996);
TextDrawUseBox(box[playerid],1);
TextDrawBoxColor(box[playerid],0x00000060);
TextDrawTextSize(box[playerid],473,0);
fuel[playerid] = TextDrawCreate(478,413,\"_\");
TextDrawLetterSize(fuel[playerid],0.37,1.099999);
TextDrawSetOutline(fuel[playerid],1);
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
TextDrawDestroy(box[playerid]);
TextDrawDestroy(fuel[playerid]);
return 1;
}
public OnVehicleSpawn(vehicleid)
{
VehicleFuel[vehicleid] = 100 + random(50);
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext,\"/refuel\",true))
{
if(IsPlayerInAnyVehicle(playerid)) VehicleFuel[GetPlayerVehicleID(playerid)] = 100 + random(50);
return 1;
}
return 0;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
new vehicleid = GetPlayerVehicleID(playerid);
if(newkeys & KEY_ACTION)
{
new engine,lights,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
if(engine == 1) SetVehicleParamsEx(vehicleid,0,lights,alarm,doors,bonnet,boot,objective);
else
{
if(VehicleFuel[vehicleid] > 0) SetVehicleParamsEx(vehicleid,1,lights,alarm,doors,bonnet,boot,objective);
}
}
if(newkeys & KEY_CROUCH)
{
new engine,lights,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
if(lights == 1) SetVehicleParamsEx(vehicleid,engine,0,alarm,doors,bonnet,boot,objective);
else SetVehicleParamsEx(vehicleid,engine,1,alarm,doors,bonnet,boot,objective);
}
}
return 1;
}
public SpeedoUpdate()
{
for(new i = 0;i<MAX_PLAYERS;i++)
{
if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i))
{
new string[24],vehicleid = GetPlayerVehicleID(i);
TextDrawShowForPlayer(i,box);
TextDrawShowForPlayer(i,fuel);
format(string,sizeof(string),\"Fuel: %dL\",VehicleFuel[vehicleid]);
TextDrawSetString(fuel,string);
}
if(!IsPlayerInAnyVehicle(i))
{
TextDrawHideForPlayer(i,box);
TextDrawHideForPlayer(i,fuel);
}
}
}
public FuelUpdate()
{
for(new i = 1;i<MAX_VEHICLES;i++)
{
if(GetVehicleModel(i))
{
new engine,lights,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(i,engine,lights,alarm,doors,bonnet,boot,objective);
if(engine == 1)
{
if(VehicleFuel > 0) VehicleFuel--;
else SetVehicleParamsEx(i,0,lights,alarm,doors,bonnet,boot,objective);
}
}
}
}
[/pawn]