vehicle fuel help - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: vehicle fuel help (
/showthread.php?tid=446117)
vehicle fuel help -
SMW - 24.06.2013
just to the point, is there something wrong with my code ?
pawn Код:
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 && !IsVIPcar(i) || !IsASepedah(GetVehicleModel(i)) || !isGarbageCar(i) || !isDMVCar(i)){
if(VehicleFuel[i] > 0) VehicleFuel[i]--;
else SetVehicleParamsEx(i,0,lights,alarm,doors,bonnet,boot,objective);
}
}
}
}
i tried to make some vehicle from script have infinite fuel, but the vehicle i wanted infinite fuel, they keep their fuel decreased,
sorry for bad english ..
Re: vehicle fuel help -
SMW - 24.06.2013
bump..
Re: vehicle fuel help -
horsemeat - 24.06.2013
I believe this will not work because if the players car is not a VIP it will continue checking the next one and it will not be a IsASepedah so it will continue on to the code the only way this would work is if that one car was all of the statements
Re: vehicle fuel help -
Pillhead2007 - 24.06.2013
You Can Try This
, Not Tested But Should Work
PHP код:
new Fuel[MAX_VEHICLES];
new Text:FuelTxt[MAX_PLAYERS];
forward FuelUpdate();
main()
{
for(new i=0;i<MAX_PLAYERS;i++)
{
//--[Fuel]
FuelTxt[playerid] = TextDrawCreate(0,410,"Fuel:%i%");
TextDrawBackgroundColor(FuelTxt[playerid],0x00000033);
TextDrawFont(FuelTxt[playerid],3);
TextDrawLetterSize(FuelTxt[playerid],0.399999,1.700000);
TextDrawColor(FuelTxt[playerid],0xFFFFFFFF);
TextDrawSetShadow(FuelTxt[playerid],3);
}
}
public OnGameModeInit()
{
//--[Fuel]
for(new i=0;i<MAX_VEHICLES;i++)
{
Fuel[i] = 100;
}
return 1;
}
public FuelUpdate()
{
for(new i=0;i<MAX_PLAYERS;i++)
{
new vehicleid = GetPlayerVehicleID(i);
new engine,lights,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
if(GetPlayerVehicleSeat(i) == 0)
{
if(vehicleid == VIP)///(VIP = CreateStaticVehicle)///---[change]
{
VehicleFuel[vehicleid]++;
}
else
{
VehicleFuel[vehicleid]--;
if(VehicleFuel[vehicleid]<= 0)
{
VehicleFuel[vehicleid] = 0;
SetVehicleParamsEx(vehicleid,0,lights,alarm,doors,bonnet,boot,objective);
VehicleInfo[vehicleid][vEngine] = 0;
GameTextForPlayer(i,"~w~You Are Out Of ~r~Fuel~w~!",5000,4);
}
}
}
new string[125];
format(string,sizeof string,"Fuel:%i%",VehicleFuel[vehicleid]);
TextDrawSetString(FuelTxt[i],string);
}
return 1;
}