Jump to content

[V|REL/WIP] Fuel Script


sakis25

Recommended Posts

 

 

NEW VERSION 0.4 IS NOW AVAILABLE!

I was about to release version 0.3 yesterday but then I got a message from haws1290 who send me over the code for the blips on the map. Then I saw Daxwolf's post with his locations on the map who also helped me a lot.

A big thanks to those guys and the rest of the community who helped with this mod.

 

What's new in this version:

- Added 14 new petrol stations, 23 in total (thanks to Daxwolf)

- Added blips with the available petrol stations (thanks to haws1290)

- When you run low on gas all the petrol stations are shown on the map, also fuel bar turns red

- Added a darker background behind the fuel bar

- Bug fixes

So what's next:

- Make it possible to refill your car using the jerry can. At the moment I can't find a way to check what weapon is the player currently holding so I can't make it work yet.

- Also I can't check if the player is in a car or bycicle or boat etc. So all the vehicles you are driving will drain fuel.

 

those work :)

 

Great find!

Hope Sakis use them for the mod :lol:

 

 

see my previous post :D

Link to comment
Share on other sites

headscript

@headscript I tried "IS_THIS_MODEL_A_BICYCLE(Hash model)" but it always returns "false" even when I'm on a bicycle. Can you try it and see if it works?

 

@Xilandro thank you for the code. I'll try it latter.

 

Note to mods: Please edit the title of this thread and remove the "0.1" because it causes confusion.

i use it like thatVEHICLE.IS_THIS_MODEL_A_TRAIN(ENTITY.GET_ENTITY_MODEL(v)))

v is the vehicle object

Link to comment
Share on other sites

Thanks for v0.4, I will try it tomorrow. Here is my opinions;

 

- bicycles don't have a serious bug. Even if fuel goes empty, you can still drive your bicycle. :)

 

- about boats; you can add a sea petrol station in the future after openIV be able to edit rpf files.

 

- You can take help from other modders on this forum about jerry can, there was a "Gravity Gun" mod. So, developer of this mod knows how to check what weapon is the player currently holding(He scripted the Stun Gun)

 

- Can you extend a little more fuel's end time? It depletes after 3-4 miles and this is not realistic.

 

- Lastly, you can change your script like that: Player parks her/his car to near of fuel station, gets off from car and presses "e" near fuel and fuels up car. Pressing "e" in the car isn't realistic, you can change that if you like this idea.

 

To put it in a nutshell, thanks for the script. I hope you can find someone who can help about detecting vehicles and weapons :)

Link to comment
Share on other sites

 

@headscript I tried "IS_THIS_MODEL_A_BICYCLE(Hash model)" but it always returns "false" even when I'm on a bicycle. Can you try it and see if it works?

 

@Xilandro thank you for the code. I'll try it latter.

 

Note to mods: Please edit the title of this thread and remove the "0.1" because it causes confusion.

i use it like thatVEHICLE.IS_THIS_MODEL_A_TRAIN(ENTITY.GET_ENTITY_MODEL(v)))

v is the vehicle object

 

 

Thank you! Now it works!

I will add this check in the next version.

Link to comment
Share on other sites

 

@headscript I tried "IS_THIS_MODEL_A_BICYCLE(Hash model)" but it always returns "false" even when I'm on a bicycle. Can you try it and see if it works?

 

@Xilandro thank you for the code. I'll try it latter.

 

Note to mods: Please edit the title of this thread and remove the "0.1" because it causes confusion.

i use it like thatVEHICLE.IS_THIS_MODEL_A_TRAIN(ENTITY.GET_ENTITY_MODEL(v)))

v is the vehicle object

 

 

"IS_THIS_MODEL_A_BICYCLE" and "IS_THIS_MODEL_A_BIKE" both return bike. Check for bicycle is not working.

Link to comment
Share on other sites

Great updates man, keep up the good work. Just some feedback for you. You may want to readjust the coordinates of Gas Station 6. I had to almost drive into the front door before it would begin refueling. Also I felt that it waited until the last minute before the icons would appear for the gas station not giving you enough time to really make it in some cases. So I personally adjusted this line to 0.04 and it was perfect for me:

if (carGas<0.02) then		if (lowFuel==false) then 		lowFuel=true		GUI.loadBlips()		end
Link to comment
Share on other sites

heres an idea instead of a straight line you could put a nice minimalistic curved line

 

or it could simply be lines I I I I I I I I I (O)

fuel-gauge.jpg

Edited by ZZCOOL
  • Like 1
Link to comment
Share on other sites

What line (s) is fuel consumption rate on?

 

This one:

function GUI.updateGas() 	if(carGas > 0) then		carGas = carGas -(carspeed/600000) <<<------This value here		GUI.time = 0	else		carGas = 0	endend

higher = longer. I set mine to about 2,600,000. I can get almost entirely around the perimeter of the map on about a half a tank, which I think is realistic imo because you shouldn't be filling up 15 times a day. But play around with it and decide for yourself. I also didn't need to change the values @t9x89 mentioned about the markers popping up at the last second after I did this because the ones before worked well.

 

I also added to the blips under 'function GUI.loadBlips' so that they are the same size as the map marker and also recolored them red.

        UI.SET_BLIP_SCALE(g1, 0.8)	UI.SET_BLIP_SCALE(g2, 0.8)	UI.SET_BLIP_SCALE(g3, 0.8)	UI.SET_BLIP_SCALE(g4, 0.8)	UI.SET_BLIP_SCALE(g5, 0.8)	UI.SET_BLIP_SCALE(g6, 0.8)	UI.SET_BLIP_SCALE(g7, 0.8)	UI.SET_BLIP_SCALE(g8, 0.8)	UI.SET_BLIP_SCALE(g9, 0.8)		UI.SET_BLIP_SCALE(g10, 0.8)	UI.SET_BLIP_SCALE(g11, 0.8)	UI.SET_BLIP_SCALE(g12, 0.8)	UI.SET_BLIP_SCALE(g13, 0.8)	UI.SET_BLIP_SCALE(g14, 0.8)	UI.SET_BLIP_SCALE(g15, 0.8)	UI.SET_BLIP_SCALE(g16, 0.8)	UI.SET_BLIP_SCALE(g17, 0.8)	UI.SET_BLIP_SCALE(g18, 0.8)	UI.SET_BLIP_SCALE(g19, 0.8)	UI.SET_BLIP_SCALE(g20, 0.8)	UI.SET_BLIP_SCALE(g21, 0.8)	UI.SET_BLIP_SCALE(g22, 0.8)	UI.SET_BLIP_SCALE(g23, 0.8)		UI.SET_BLIP_COLOUR(g1, 1)	UI.SET_BLIP_COLOUR(g2, 1)	UI.SET_BLIP_COLOUR(g3, 1)	UI.SET_BLIP_COLOUR(g4, 1)	UI.SET_BLIP_COLOUR(g5, 1)	UI.SET_BLIP_COLOUR(g6, 1)	UI.SET_BLIP_COLOUR(g7, 1)	UI.SET_BLIP_COLOUR(g8, 1)	UI.SET_BLIP_COLOUR(g9, 1)		UI.SET_BLIP_COLOUR(g10, 1)	UI.SET_BLIP_COLOUR(g11, 1)	UI.SET_BLIP_COLOUR(g12, 1)	UI.SET_BLIP_COLOUR(g13, 1)	UI.SET_BLIP_COLOUR(g14, 1)	UI.SET_BLIP_COLOUR(g15, 1)	UI.SET_BLIP_COLOUR(g16, 1)	UI.SET_BLIP_COLOUR(g17, 1)	UI.SET_BLIP_COLOUR(g18, 1)	UI.SET_BLIP_COLOUR(g19, 1)	UI.SET_BLIP_COLOUR(g20, 1)	UI.SET_BLIP_COLOUR(g21, 1)	UI.SET_BLIP_COLOUR(g22, 1)	UI.SET_BLIP_COLOUR(g23, 1)
Edited by Daxwolf
  • Like 2
Link to comment
Share on other sites

heres an idea instead of a straight line you could put a nice minimalistic curved line

 

or it could simply be lines I I I I I I I I I (O)fuel-gauge.jpg

That would require actual textures and that is not possible at the moment. But in the future, yes good idea!

Link to comment
Share on other sites

headscript

 

heres an idea instead of a straight line you could put a nice minimalistic curved line

 

or it could simply be lines I I I I I I I I I (O)fuel-gauge.jpg

That would require actual textures and that is not possible at the moment. But in the future, yes good idea!

 

nah you can still draw rectangles :)

just the fuel icon is maybe impossible if u cant get weapon icons drawn

Link to comment
Share on other sites

 

 

heres an idea instead of a straight line you could put a nice minimalistic curved line

 

or it could simply be lines I I I I I I I I I (O)fuel-gauge.jpg

That would require actual textures and that is not possible at the moment. But in the future, yes good idea!

 

nah you can still draw rectangles :)

just the fuel icon is maybe impossible if u cant get weapon icons drawn

 

well i'd love lines thats the simplest cleanest way I I I I I I I I

Link to comment
Share on other sites

faztsquirrel

Hi! I modded your 0.2 version of the script and added the jerrycan feature. So the script is a bit outdated, but I hope it can help you add the feature too.

The interesting part of the code is:

if( get_key_pressed(Keys.L) and GAMEPLAY.GET_HASH_KEY(WEAPON.GET_SELECTED_PED_WEAPON(playerPed)) == 2821749192 and carGas < 0.14 ) then -- 2821749192 = jerrycan    if( ENTITY.DOES_ENTITY_EXIST(currentCar) ) then        local coords = ENTITY.GET_ENTITY_COORDS(currentCar, nil);        local coords2 = ENTITY.GET_ENTITY_COORDS(playerPed, nil);        if(GAMEPLAY.GET_DISTANCE_BETWEEN_COORDS(coords.x,coords.y,coords.z,coords2.x,coords2.y,coords2.z,false) < 4) then            local ammo = WEAPON.GET_AMMO_IN_PED_WEAPON(playerPed, WEAPON.GET_SELECTED_PED_WEAPON(playerPed))            if(ammo > 0) then                carGas = carGas+0.0002                local ammo = WEAPON.SET_PED_AMMO(playerPed, WEAPON.GET_SELECTED_PED_WEAPON(playerPed), ammo-5)            end        end    endend

The full script is available here: http://pastebin.com/c6KrGJYR

  • Like 3
Link to comment
Share on other sites

level232323

Made a

of the latest update if someone is interested guys.

My opinion is that it's a must have mod, i will never remove it :))

Link to comment
Share on other sites

RPhilMan1

I don't think this has been brought up before, but is there a way to "pay" a gas station once filling up? It would be neat to have a certain amount of money deducted for how much fuel was added.

Link to comment
Share on other sites

I don't think this has been brought up before, but is there a way to "pay" a gas station once filling up? It would be neat to have a certain amount of money deducted for how much fuel was added.

I think it can be done like this:

int cost = 80

int currentMoney = PED::GET_PED_MONEY(playerPed)

PED::SET_PED_MONEY(playerPed, currentMoney-cost)

 

but cost value should not be constant but taken from current level of fuel.

Link to comment
Share on other sites

Hi! I modded your 0.2 version of the script and added the jerrycan feature. So the script is a bit outdated, but I hope it can help you add the feature too.

 

The interesting part of the code is:

if( get_key_pressed(Keys.L) and GAMEPLAY.GET_HASH_KEY(WEAPON.GET_SELECTED_PED_WEAPON(playerPed)) == 2821749192 and carGas < 0.14 ) then -- 2821749192 = jerrycan    if( ENTITY.DOES_ENTITY_EXIST(currentCar) ) then        local coords = ENTITY.GET_ENTITY_COORDS(currentCar, nil);        local coords2 = ENTITY.GET_ENTITY_COORDS(playerPed, nil);        if(GAMEPLAY.GET_DISTANCE_BETWEEN_COORDS(coords.x,coords.y,coords.z,coords2.x,coords2.y,coords2.z,false) < 4) then            local ammo = WEAPON.GET_AMMO_IN_PED_WEAPON(playerPed, WEAPON.GET_SELECTED_PED_WEAPON(playerPed))            if(ammo > 0) then                carGas = carGas+0.0002                local ammo = WEAPON.SET_PED_AMMO(playerPed, WEAPON.GET_SELECTED_PED_WEAPON(playerPed), ammo-5)            end        end    endend

The full script is available here: http://pastebin.com/c6KrGJYR

 

You just made my day! Thank you.

I will add this in the next version.

Also I will make it so you will have to pay the gas station when you filling up. Like @RPhilMan1 mentioned.

Link to comment
Share on other sites

I'm just returning to the forums. I haven't yet looked at the scripthook; (I intend to) but has anyone interest to research trying to use the dials in the dash? They seem to work becasuse I get cars with varying amounts of fuel This would be good technology for this mod. Is the (your) code open so I can study it?

Link to comment
Share on other sites

I would find it cool if someone can make some places for boats and planes.

Link to comment
Share on other sites

I have some problems about the money check in the script.

Here is a code that I found:

    if (PED::IS_PED_MODEL(playerPed, GAMEPLAY::GET_HASH_KEY("player_zero")))    {        model = 0;    }    if (PED::IS_PED_MODEL(playerPed, GAMEPLAY::GET_HASH_KEY("player_one")))    {        model = 1;    }    if (PED::IS_PED_MODEL(playerPed, GAMEPLAY::GET_HASH_KEY("player_two")))    {        model = 2;    }    char statNameFull[32];    sprintf_s(statNameFull, "SP%d_TOTAL_CASH", model);    Hash hash = GAMEPLAY::GET_HASH_KEY(statNameFull);    int val;    STATS::STAT_GET_INT(hash, &val, -1);

Any chance to convert this to LUA?

Link to comment
Share on other sites

headscript

I don't see any problem in converting it to lua, I'm currently on the way home I can write you a solution then

    local model = 0	if (PED.IS_PED_MODEL(playerPed, GAMEPLAY.GET_HASH_KEY("player_zero"))) then        model = 0    elseif (PED.IS_PED_MODEL(playerPed, GAMEPLAY.GET_HASH_KEY("player_one"))) then                                        model = 1                                         	elseif (PED.IS_PED_MODEL(playerPed, GAMEPLAY.GET_HASH_KEY("player_two"))) then        model = 2    end   local statname = "SP"..model.."d_TOTAL_CASH"   local hash = GAMEPLAY.GET_HASH_KEY(statname)   local val = STATS.STAT_GET_INT(hash, 0, -1)
Edited by headscript
Link to comment
Share on other sites

SiLexBone

Hey I'm new on the forum.

Actually I wanted to suggest places for refilling boats and planes. For planes for example near the stationary gas tanks, for example in sandy shore on the smallest airfield. For Helicopters may be where Michael and Franklin have their personal landing field (there is also a stationary gas tank near the building) or just when landing on the helipad. And MAY BE in future have gas trucks (mobile gas tanks) to have refulled the plane or heli. About this it would be nice to have a mod to attach boat trailers, mobile gas tanks etc. on a truck.... If someone know how to do this... :catspider:

I'm new to LUA scripting so i'm gonna have myself a look on it but I promise nothing :lol:

 

 

EDIT: here are the coordinates for the little gas station next to the sandy shore airfield if someone is interested. I added them already myself. You can easily refuel planes and choppers here. @sakis25 if you need more coordinates for refuelling places I can help you may be. :panic:

 

--24    if (coords.x>1780 and coords.x<1790 and coords.y > 3325 and coords.y < 3335) then        refillCar =true    end
Edited by SiLexBone
Link to comment
Share on other sites

 

I don't see any problem in converting it to lua, I'm currently on the way home I can write you a solution then

    local model = 0	if (PED.IS_PED_MODEL(playerPed, GAMEPLAY.GET_HASH_KEY("player_zero"))) then        model = 0    elseif (PED.IS_PED_MODEL(playerPed, GAMEPLAY.GET_HASH_KEY("player_one"))) then                                        model = 1                                         	elseif (PED.IS_PED_MODEL(playerPed, GAMEPLAY.GET_HASH_KEY("player_two"))) then        model = 2    end   local statname = "SP"..model.."d_TOTAL_CASH"   local hash = GAMEPLAY.GET_HASH_KEY(statname)   local val = STATS.STAT_GET_INT(hash, 0, -1)

 

Thanks for the help. But val returns "false" for some reason and not the amount of cash for the current character.

Link to comment
Share on other sites

There is maybe a wrong gaz station

 

There is nothing there :

X: 733.987

Y: -1034.14

Z: 20.9476

 

The station is more at :

X: 817.062

Y: -1030.2

Z: 25.8636

Edited by s2nz0
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
  • 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.