Float 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: Float problem (
/showthread.php?tid=541624)
Float problem -
IceBilizard - 13.10.2014
Hello everyone today i am confused with a task i have fuel system in my server the max fuel is 100 and its working perfect but i want to make random fuel for vehicles like 15-80% fuel example if you sit in a car the car have 36 fuel and if you sit in another car the car must have different amount of fuel like 40% so i am confused with make that system here is my code if you can help me to make it.
pawn Code:
// MAX-Fuel
#define FuelMax 100.0
pawn Code:
new Float:Gas[MAX_VEHICLES] = {FuelMax, ...}; // This is for give fuel to vehicles
Thanks for help in advance.
Re: Float problem -
AnnaSB - 13.10.2014
pawn Code:
OnGameModeInit()
{
// ...
for (new i = 0; i < MAX_VEHICLES; i++) Gas[i] = 1.0 * (random(65) + 15);
// ...
}
OnVehicleSpawn(vehicleid)
{
Gas[vehicleid] = 1.0 * (random(65) + 15);
// ...
}
Edit: You also need a timer to respawn all unoccupied vehicles with an interval (ex. 60000ms = 10m) to prevent out-of-fuel vehicles from being abandoned forever; I'll leave that to yourself.
Hope I helped ^^
Re: Float problem -
IceBilizard - 14.10.2014
Thanks a-lot man it worked

+rep for you
Re: Float problem -
AngeloBrand98 - 05.09.2017
i also need this script, but when i paste the code above, the gamemode on my server become Unknown
Re: Float problem -
AngeloBrand98 - 05.09.2017
Up, i really need this, i want make every vehicles have an random Fuel from 10% to 95%. Thanks
~~ Up! Up! Up! ~~