Jump to content

Need help, fuel script


Mr.K

Recommended Posts

when I enter to the vehicle as the driver, fuel changes to random,how to do that the fuel level will be loaded from a file?

function vehicleEnter(player, seat, jacked)

if(getElementData(vehicle, "fuel") == false) then

if seat == 0 then

fuel = math.random(70, 100)

setElementData(source, "fuel", tonumber(fuel))

end

end

if(getLocalPlayer()==player) then

guiSetVisible(fBar, true)

guiSetVisible(fLabel, true)

end

end

addEventHandler("onClientVehicleEnter", getRootElement(), vehicleEnter)

Link to comment

when I enter to the vehicle as the driver, fuel changes to random,how to do that the fuel level will be loaded from a file?

function vehicleEnter(player, seat, jacked)

if(getElementData(vehicle, "fuel") == false) then

if seat == 0 then

fuel = math.random(70, 100)

setElementData(source, "fuel", tonumber(fuel))

end

end

if(getLocalPlayer()==player) then

guiSetVisible(fBar, true)

guiSetVisible(fLabel, true)

end

end

addEventHandler("onClientVehicleEnter", getRootElement(), vehicleEnter)

Link to comment

Save it in an xml file and retrieve the amount of fuel from the file.

http://robhol.net/guide/basics/?p=11

The guide should help you understand how to retrieve data from an XML file.

Altough, I recommend saving the amount of fuel in a xml file, and when the gamemode starts, save it to each vehicle using 'setElementData', that way it'lll be easier to script a decreasing amount of fuel + retrieving the amount of fuel in the vehicle. I hope that made sense :/

Link to comment

Save it in an xml file and retrieve the amount of fuel from the file.

http://robhol.net/guide/basics/?p=11

The guide should help you understand how to retrieve data from an XML file.

Altough, I recommend saving the amount of fuel in a xml file, and when the gamemode starts, save it to each vehicle using 'setElementData', that way it'lll be easier to script a decreasing amount of fuel + retrieving the amount of fuel in the vehicle. I hope that made sense :/

Link to comment

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...