Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. Los Santos Drug Wars
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Blood Money
      2. Frontier Pursuits
      3. Find Lobbies & Outlaws
      4. Help & Support
    3. Crews

    1. Grand Theft Auto Series

      1. Bugs*
      2. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    6. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    7. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Announcements

    2. Support

    3. Suggestions

UltimateFuelScript Source Code


pedro2555
 Share

Recommended Posts

In my opinion this is the best fuel mod made so far for GTA IV. I do had ideias to continue but will not release any more updates on this project.

 

Before it gets deleted, I left here the source file for the project.

 

It was developed under Visual Studio 2012. You will also need SlimDX SDK installed. This is a development version, so it has references not needed, make sure to delete them before any release. Most of the code is fully commented, but some comments might not relate to the actual code, due to later changes.

 

And BTW anyone is free to release this on their own.

 

---- EDIT ----

 

code added to allow script communication (there's a post down below explaining usage)

fixed bug with fuel station names

 

A compiled version can be found here

 

The source code is a now available as a VS2012 project in here

Edited by pedro2555
Link to comment
Share on other sites

thx for sharing turn.gif

You're welcome. I think you even contributed to this. This line I believe:

 

'drainPerSecond = (currVeh.Metadata.Drain * (.2f + ((currVeh.Speed * .2f) / 5.0f))) / 100.0f;'

 

 

Link to comment
Share on other sites

  • 3 weeks later...

Hi,

I really, really miss the saving car feature you had in Ultimate Fuel Script V1.2. Can you release the code for that or make it into a separate scrip alltogether? It would be of tremendous help! Thanks!

 

As it is, your version 1.2 crashes for me sometimes when I press CTRL+Z to save all the cars by saying "Error in script Fuel_Script_RC2.Fuel" and after that the whole game just freezes over.

PS: It once crashes when I pressed Shift+Z once as well but the game didn't freeze and I was able to keep playing, however the script hasn't worked for the rest of that session.

 

In the ScriptHookDotNet log is says:

2013-02-12 02:12:26 - Error during Tick in script 'Fuel_Script_RC2.Fuel':

GTA.NonExistingObjectException: Invalid call to an object that doesn't exist anymore!

at GTA.Blip.GetAttachedItem()

at Fuel_Script_RC2.Fuel._KeyDown(Object sender, KeyEventArgs e)

at GTA.Script.ProcessEvents()

at GTA.Script.DoTick()

at GTA.ScriptThread.OnTick()

 

But the car still exists as I am obviously driving it! Do I have to run these scripts while standing still? Maybe changing the object's coordinates is what ticks it off?

 

Off-topic: How the hell do you bring up the console in Scripthook 5.1 ? I can't seem to find any info on that as the "`" key doesn't work. I have a feeling that reloading the script everytime it crashes might fix the problem.

Edited by IFlip92
Link to comment
Share on other sites

Hi,

I really, really miss the saving car feature you had in Ultimate Fuel Script V1.2. Can you release the code for that or make it into a separate scrip alltogether? It would be of tremendous help! Thanks!

 

As it is, your version 1.2 crashes for me sometimes when I press CTRL+Z to save all the cars by saying "Error in script Fuel_Script_RC2.Fuel" and after that the whole game just freezes over.

PS: It once crashes when I pressed Shift+Z once as well but the game didn't freeze and I was able to keep playing, however the script hasn't worked for the rest of that session.

 

In the ScriptHookDotNet log is says:

2013-02-12 02:12:26 - Error during Tick in script 'Fuel_Script_RC2.Fuel':

GTA.NonExistingObjectException: Invalid call to an object that doesn't exist anymore!

at GTA.Blip.GetAttachedItem()

at Fuel_Script_RC2.Fuel._KeyDown(Object sender, KeyEventArgs e)

at GTA.Script.ProcessEvents()

at GTA.Script.DoTick()

at GTA.ScriptThread.OnTick()

 

But the car still exists as I am obviously driving it! Do I have to run these scripts while standing still? Maybe changing the object's coordinates is what ticks it off?

 

Off-topic: How the hell do you bring up the console in Scripthook 5.1 ? I can't seem to find any info on that as the "`" key doesn't work. I have a feeling that reloading the script everytime it crashes might fix the problem.

Feel sad for removing it, but it was not working properly and still it is not that good. You can still make use of that code on CarAlarm Mod. I might add that function to this script, since lots of people loved that, but not really sure if i want to do it.

 

Fuel Script RC (Release Candidate) was a test version, so that code is not with us any more. Version 2 makes use of an improved version of RC's code.

 

'The car exists, but not as an attached item to a blip, that's the tricky part.'

 

I might introduce the save car feature again, as a last thing.

 

You can always reload scripts, but all data will be lost (car fuel data). To open the console, well, I'am from Portugal, and in a Portuguese keyboard is a key that doesn't exist in english that triggers the console. (ç - is this one, changing to English keyboard gives me a colon -> ; ) And yes reloading does the trick.

 

 

Link to comment
Share on other sites

I found a way to do it. The way you open the console in Scripthook 5.1 is by pressing SHIFT + ' on my keyboard from the UK. Basically the key has a @ as its uppercase character and ' as its lowercase character and it's 1 key away from Enter (just instructing people who may read this in the future). I get the console up and I type in ReloadScripts and it works again till it will eventually crashes again. If I press CTRL + Z at any point when it works, I believe it saves all the cars at that moment that I bliped and when you reload it, it still shows you your cars but I think the fuel data gets randomized again.

 

What I have done now is I use Ultimate Fuel Script V2 and Ultimate Fuel Script V1.2 together and I have 2 fuel gauges now lol.gif but at least I can make use of both of best worlds even though I pay double at the pumps whatsthat.gif (ain't that the truth?). I copied all the station data in each other's fuel .ini files so the prices, tank sizes etc. are the same.

Link to comment
Share on other sites

 

I found a way to do it. The way you open the console in Scripthook 5.1 is by pressing SHIFT + ' on my keyboard from the UK. Basically the key has a @ as its uppercase character and ' as its lowercase character and it's 1 key away from Enter (just instructing people who may read this in the future). I get the console up and I type in ReloadScripts and it works again till it will eventually crashes again. If I press CTRL + Z at any point  when it works, I believe it saves all the cars at that moment that I bliped and when you reload it, it still shows you your cars but I think the fuel data gets randomized again.

 

What I have done now is I use Ultimate Fuel Script V2 and Ultimate Fuel Script V1.2 together and I have 2 fuel gauges now  lol.gif but at least I can make use of both of best worlds even though I pay double at the pumps  whatsthat.gif  (ain't that the truth?). I copied all the station data in each other's fuel .ini files so the prices, tank sizes etc. are the same.

 

 

Version 0.820 BETA:

- added an ingame console (tilde key) and some commands for it. type "help" for infos.

 

 

LOL, just found that really funny man. I'am going to add the save car feature today, that's for sure !

 

And don't worry, I will avoid crashes. Yes you do pay double, but you can change both prices to half. And that's really weird, using both scripts. Lol, Oh man you have made my day, using both scripts ? That's fantastic. I will update this thread, hopefully today.

 

 

--- EDIT ---

 

Save function is already working, just some edges to polish. An update tomorow.

Edited by pedro2555
Link to comment
Share on other sites

You're the man! cool.gif

 

I rectifiy what I said before, if I copy the Station data from your latest V2 to V1.2, the V1.2 script doesn't work any more, maybe it's because I copied all the Boat and Heli refuel stations as well which V1.2 didn't have whatsthat.gif . So anyway, I am using both scripts as stock haha and it works. Only thing I've done is deleted the Gauge values from the V1.2 so the Gauge sits at the top left corner of the screen, while V2 sits underneath the Minimap as usual. I put the refuel key for V2 on X and the refuel key for V1.2 on "End" key and I refuel both at the pumps lol xD.

 

My major problem right now is that whenever I reload the scripts when the save car feature stops working, the cars I have saved respawn in the same location on top of each other, sometimes causing explosions haha. It's rather funny, because I have some cars parked and stored in gas stations!! I drive past and KaBoom!

Edited by IFlip92
Link to comment
Share on other sites

Ok, I really can't figure out a good way to save and, mostly, load, more than one car in between gameplays. So I challenge someone else to do it. I have, hopefully, prepared the script to be able to receive commands and send data back to another script. Let's see, is not that much :

 

Script GUID - 3583e09d-6c44-4820-85e9-93926307d4f8

 

The script has two methods you can bind to.

IMPORTANT:

Before binding any commands make sure to specify your script GUID in the FuelScript.ini file, under [MISC] -> GUID

 

Current vehicle fuel tank value

This value can be obtained by sending the command 'GetCurrentFuel' to the script and bind the command 'CurrentFuel' to your own application.

A C# example follows :

 

using System;   using System.Windows.Forms;   using GTA;   namespace GetCurrentFuel    {   	public class GetCurrentFuel : Script    	{     Guid fuelScriptGUID = new Guid("3583e09d-6c44-4820-85e9-93926307d4f8");     public GetCurrentFuel()     {     	SendScriptCommand(fuelScriptGUID, "GetCurrentFuel", null);     	BindScriptCommand("CurrentFuel", new ScriptCommandDelegate(Fuel));     }     private void Fuel(GTA.Script sender, GTA.ObjectCollection Parameter)     {     	float fuel = Parameter.Convert<float>(0);     }	   	}   }

 

 

Current vehicle fuel drain value

This value can be obtained by sending the command 'GetCurrentDrain' to the script and bind the command 'CurrentDrain' to your own application.

A C# example follows :

 

using System;   using System.Windows.Forms;   using GTA;   namespace GetCurrentDrain    {   	public class GetCurrentDrain : Script    	{     Guid fuelScriptGUID = new Guid("3583e09d-6c44-4820-85e9-93926307d4f8");     public GetCurrentDrain()     {     	SendScriptCommand(fuelScriptGUID, "GetCurrentDrain", null);     	BindScriptCommand("CurrentDrain", new ScriptCommandDelegate(Drain));     }     private void Drain(GTA.Script sender, GTA.ObjectCollection Parameter)     {     	float drainPerSecond = Parameter.Convert<float>(0);     }	   	}   }

 

 

If you don't know how to code, ask on the code requests topic.

Edited by pedro2555
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.