[HELP] Fuel problem!! - 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: [HELP] Fuel problem!! (
/showthread.php?tid=623885)
[HELP] Fuel problem!! -
catal4n - 07.12.2016
Alright, hello dear scripters, i had a big problem about my fuel system. The fact is fuel is going down even if the engine is on or off also if a driver is in or not. Here are the codes for fuel. Any ideas or any help? Thanks i will rep you guys if you help me fixing this. Have a nice day.
Код:
forward FuelTimer();
public FuelTimer()
{
for(new vehid=0; vehid < MAX_VEHICLES; vehid++)
{
new enginec, lightsc, alarmc, doorsc, bonnetc, bootc, objectivec;
GetVehicleParamsEx(vehid, enginec, lightsc, alarmc, doorsc, bonnetc, bootc, objectivec);
if(enginec && Fuel[vehid])
{
FuelVar[vehid] ++;
if(GetVehicleSpeed(vehid, 0) != 0 && FuelVar[vehid] >= 72/2)
{
FuelVar[vehid] = 0;
Fuel[vehid] --;
}
else if(GetVehicleSpeed(vehid, 0) == 0 && FuelVar[vehid] >= 108/2)
{
FuelVar[vehid] = 0;
Fuel[vehid] --;
}
}
}
return 1;
}
Re: [HELP] Fuel problem!! -
Logic_ - 07.12.2016
Show us your engine command or how you close the engine?
EDIT: Also,
https://sampwiki.blast.hk/wiki/SetVehicleParamsEx
since 0.3a you will have to reapply this function when OnVehicleStreamIn is called.
EDIT 2:
Optimized version of the code can be...
PHP код:
// top of the script
native IsValidVehicle(vehicleid);
// somewhere in the script
forward FuelTimer();
public FuelTimer()
{
for(new vehid, veh = GetVehiclePoolSize(); vehid <= veh; vehid++)
{
if(IsValidVehicle(vehid))
{
new enginec, lightsc, alarmc, doorsc, bonnetc, bootc, objectivec;
GetVehicleParamsEx(vehid, enginec, lightsc, alarmc, doorsc, bonnetc, bootc, objectivec);
if(enginec)
{
if(Fuel[vehid] > 0)
{
if(GetVehicleSpeed(vehid, 0) != 0)
{
FuelVar[vehid] ++;
if(FuelVar[vehid] >= 72/2)
{
FuelVar[vehid] = 0;
Fuel[vehid] --;
}
else if(FuelVar[vehid] >= 108/2)
{
FuelVar[vehid] = 0;
Fuel[vehid] --;
}
}
}
}
}
}
return 1;
}
Re: [HELP] Fuel problem!! -
catal4n - 07.12.2016
Код:
C:\Users\eMachines\Desktop\SAMP\GAMEMODES FOR UGRP\CGRP\gamemodes\G-RP1.pwn(102745) : error 017: undefined symbol "GetVehiclePoolSize"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
1 Error.
Re: [HELP] Fuel problem!! -
catal4n - 07.12.2016
Instead of
Код:
for(new vehid, veh = GetVehiclePoolSize(); vehid <= veh; vehid++)
i used
Код:
for(new vehid=0; vehid < MAX_VEHICLES; vehid++)
And now it works thank you very much.