Float problem
#1

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.
Reply
#2

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 ^^
Reply
#3

Thanks a-lot man it worked +rep for you
Reply
#4

i also need this script, but when i paste the code above, the gamemode on my server become Unknown
Reply
#5

Up, i really need this, i want make every vehicles have an random Fuel from 10% to 95%. Thanks

~~ Up! Up! Up! ~~
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)