GasStation & Fuel system (SQL) 1.1.0

License Agreement
Creative Commons <by>
Min. required GT-MP Version
0.1.7

Creates and loads gasstations from a database, and includes fuel deduction for vehicles.

Hello o/


This will allow you to create gasstations around San Andreas and load them in at server start using a SQL database. A step by step how to set it up is included. This will serve as a foundation for a larger system that could potentially include stuff like gas prices, custom tank capacities & and some sort of wallet system. You're not forced to turn off the engine at the moment, as all of those small features would turn the script towards some sort of roleplay gamemode. You'll have to expand upon it yourself to make it fit your needs.

You can control how often fuel is deducted from vehicles as well as the default fuel value whenever you spawn in a new vehicle.

Only a few commands comes along with this script:


Command Description
/creategas [name] Creates a new gasstation here and now, at your current position, ready to use. A query for the database also gets created so it saves and loads in the next time the server starts.
/fill If you're near any gasstation you'll begin to fill up your tank, if there's room for more of course.
/setfuel [amount] A simple command only added in for testing purposes. Use it only once you're inside a vehicle to set it's fuel to test out /fill.
/spawnCar [vehicleName] [color1] [color2] Used only to spawn in a vehicle to try out the fuel system. All vehicles spawned using this command will be given the default fuel value defined inside the 'GasStationHandler'.cs


A simple UI element is also included to display your fuel, down next to the map. Another idea for expanding could be fuel types based on the vehicle class etc. There's not really any limitation as to what can be done. Any feedback is appreciated as well as bug reports should you find any.

Share

  • Doesn't really work...
    I've got it started but if i want to create a Gas Station:
    17:46:22.778 | Error | ScriptingEngine | EXCEPTION IN RESOURCE FuelSystem INSIDE SCRIPTENGINE GasStationHandler System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.BadImageFormatException: Could not resolve field token 0x04000001
    at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
    at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00038] in <8f2c484307284b51944a1a13a14c0266>:0
    --- End of inner exception stack trace ---
    at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00053] in <8f2c484307284b51944a1a13a14c0266>:0
    at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <8f2c484307284b51944a1a13a14c0266>:0
    at GrandTheftMultiplayer.Server.Models.ScriptingEngine+<>c__DisplayClass22_0.‫‭​‮‏‮‪‌‫‌‫​‍‏‏‮‬‎‎‮‎‫‏‪‎‮ (System.Reflection.MethodBase , System.Object , System.Object[] ) [0x00000] in <edc1ee69ca2d4312a128c9364e7696c4>:0
    at GrandTheftMultiplayer.Server.Models.ScriptingEngine+<>c__DisplayClass22_0.<InvokeVoidMethod>b__0 () [0x000ba] in <edc1ee69ca2d4312a128c9364e7696c4>:0
    at GrandTheftMultiplayer.Server.Models.ScriptingEngine.MainThreadLoop () [0x001d7] in <edc1ee69ca2d4312a128c9364e7696c4>:0