pedro2555 Posted January 21, 2013 Share Posted January 21, 2013 (edited) 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 March 12, 2013 by pedro2555 Link to comment Share on other sites More sharing options...
julionib Posted January 22, 2013 Share Posted January 22, 2013 thx for sharing Link to comment Share on other sites More sharing options...
pedro2555 Posted January 22, 2013 Author Share Posted January 22, 2013 thx for sharing 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 More sharing options...
IFlip92 Posted February 12, 2013 Share Posted February 12, 2013 (edited) 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 February 12, 2013 by IFlip92 Link to comment Share on other sites More sharing options...
pedro2555 Posted February 12, 2013 Author Share Posted February 12, 2013 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 More sharing options...
IFlip92 Posted February 12, 2013 Share Posted February 12, 2013 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 but at least I can make use of both of best worlds even though I pay double at the pumps (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 More sharing options...
pedro2555 Posted February 12, 2013 Author Share Posted February 12, 2013 (edited) 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 but at least I can make use of both of best worlds even though I pay double at the pumps (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 February 12, 2013 by pedro2555 Link to comment Share on other sites More sharing options...
IFlip92 Posted February 14, 2013 Share Posted February 14, 2013 (edited) You're the man! 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 . 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 February 15, 2013 by IFlip92 Link to comment Share on other sites More sharing options...
pedro2555 Posted February 15, 2013 Author Share Posted February 15, 2013 (edited) 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 February 21, 2013 by pedro2555 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now