SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 08/09/2019, 02:39 AM   #11
Jonny
Huge Clucker
 
Jonny's Avatar
 
Join Date: Nov 2009
Location: Italy
Posts: 280
Reputation: 38
Default Re: Fuel problem

This into the timer, the other things are just for testing purposes, she made an example to show the way it works putting all the speeds with the relative decrease

Code:
VehicleFuelLiters[vehicleid]-=0.003*GetVehSpeed(vehicleid);//You can edit this to your liking
__________________
Jonny is offline   Reply With Quote
Old 08/09/2019, 06:16 AM   #12
Symon
Gangsta
 
Symon's Avatar
 
Join Date: Apr 2019
Location: Italy
Posts: 885
Reputation: 85
Default Re: Fuel problem

Ah ok quindi ci aggiungo solo quello al timer? Il resto solo per testing?

ENG: Ok so i should add just that in the timer?
Symon is offline   Reply With Quote
Old 08/09/2019, 10:23 AM   #13
Plastikmensch
Huge Clucker
 
Join Date: Aug 2016
Posts: 272
Reputation: 27
Default Re: Fuel problem

Yes.
Replace this:
Code:
if(GetVehSpeed(vehicleid) > 0 && GetVehSpeed(vehicleid) <= 30) 
{
    VehicleFuelLiters[vehicleid] -= 0.1;
}
else if(GetVehSpeed(vehicleid) > 30 && GetVehSpeed(vehicleid) <= 90)
{
    VehicleFuelLiters[vehicleid] -= 0.2;
}
else if(GetVehSpeed(vehicleid) > 90 && GetVehSpeed(vehicleid) <= 150)
{
    VehicleFuelLiters[vehicleid] -= 0.4;
}
else if(GetVehSpeed(vehicleid) > 150 && GetVehSpeed(vehicleid) <= 221)
{
    VehicleFuelLiters[vehicleid] -= 0.6;
}
else if(GetVehSpeed(vehicleid) > 221)
{
    VehicleFuelLiters[vehicleid] -= 0.9;
}
With this:
Code:
VehicleFuelLiters[vehicleid]-=0.003*GetVehSpeed(vehicleid);//You can edit this to your liking
The other stuff was as darkdrago said for testing, if you want to change 0.003.

To explain a bit more:
Code:
//for testing, you can use this:
for(new i;i<300;i+=10)
{
   printf("speed: %i, fuel decrease: %f",i,0.003*i);
}
This is optional.
You can put this in OnGameModeInit, change 0.003 to let's say 0.004, start the server, close it and look at the console or in server_log.txt for the prints.
If you are happy with the result, change 0.003 in this line:
Code:
VehicleFuelLiters[vehicleid]-=0.003*GetVehSpeed(vehicleid);//You can edit this to your liking
Plastikmensch is offline   Reply With Quote
Old 08/09/2019, 10:46 AM   #14
Symon
Gangsta
 
Symon's Avatar
 
Join Date: Apr 2019
Location: Italy
Posts: 885
Reputation: 85
Default Re: Fuel problem

Thank you!
Symon is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
fuel system problem all vehicles use same fuel(enum variables, timers) grymtn Scripting Help 7 09/04/2017 08:16 PM
[FilterScript] Fuel System [Fuel/Speed/Vehicle Name/Health] reddromero Filterscripts 5 10/05/2014 02:50 AM
Custom Fuel system taking 2 fuel instead of 1. ricardo178 Scripting Help 6 27/04/2013 10:16 AM
Problem's with fuel ivanVU Scripting Help 10 30/09/2012 08:53 PM
Fuel[i] -= 1; (Insted of taking 1, takes all fuel) HondaCBR Scripting Help 2 15/04/2012 01:03 PM


All times are GMT. The time now is 05:24 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.