Mr.K Posted January 8, 2010 Share Posted January 8, 2010 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
Mr.K Posted January 8, 2010 Author Share Posted January 8, 2010 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
Jumba' Posted January 8, 2010 Share Posted January 8, 2010 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
Jumba' Posted January 8, 2010 Share Posted January 8, 2010 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
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