justn Posted April 25, 2014 Share Posted April 25, 2014 (edited) Hey, i'm working on a fuel system but it doesn't work , can someone fix please ? thanks.. No errors in debugscript fuelNumber = 100 for i, vehicle in ipairs(getElementsByType("vehicle")) do setElementData(vehicle,"fuel",tonumber(fuelNumber)) end function decreaseFuel(seat, door) setTimer(function() if ( seat == 0 ) and ( door == 0 ) then local veh = getPedOccupiedVehicle(localPlayer) if ( veh ) then setElementData(veh,"fuel",tonumber(fuelNumber)-1) addEventHandler("onClientRender",getRootElement(),onFuelRender) end end end,1000,0) end addEventHandler("onClientVehicleEnter",getRootElement(),decreaseFuel) function onFuelRender() if isPedInVehicle ( localPlayer ) then dxDrawText("Vehicle Fuel: "..tonumber(fuelNumber).."%", 312, 718, 561, 742, tocolor(255, 255, 255, 255), 1.50, "default-bold", "left", "top", false, false, true, false, false) end end Edited April 27, 2014 by Guest Link to comment
Booo Posted April 25, 2014 Share Posted April 25, 2014 https://community.multitheftauto.com/index.php?p= ... ils&id=119 --- viewtopic.php?t=63033&f=91 https://forum.multitheftauto.com/viewtopic.php?f=91&t=56407 Link to comment
3B00DG4MER Posted April 25, 2014 Share Posted April 25, 2014 https://community.multitheftauto.com/index.php?p= ... ils&id=119 --- viewtopic.php?t=63033&f=91 https://forum.multitheftauto.com/viewtopic.php?f=91&t=56407 We SAID fix not give us link of resource Link to comment
Booo Posted April 25, 2014 Share Posted April 25, 2014 We SAID fix not give us link of resource fix it then .!! Link to comment
3B00DG4MER Posted April 25, 2014 Share Posted April 25, 2014 We SAID fix not give us link of resource fix it then .!! Look at his Signature and Mine Link to comment
-.Paradox.- Posted April 25, 2014 Share Posted April 25, 2014 Try this, maybe it'll work (not tested) Client function onFuelRender() local fuel = getElementData(localPlayer, "fuel") or 0 if isPedInVehicle ( localPlayer ) and fuel then dxDrawText("Vehicle Fuel: "..tonumber(fuel).."%", 312, 718, 561, 742, tocolor(255, 255, 255, 255), 1.50, "default-bold", "left", "top", false, false, true, false, false) end end addEventHandler("onClientRender", root, onFuelRender) Server: fuelNumber = 100 function fuel () for i, vehicle in ipairs(getElementsByType("vehicle")) do setElementData(vehicle,"fuel",tonumber(fuelNumber)) end end addEventHandler("onPlayerJoin", root, fuel) function decreaseFuel(seat, door) setTimer( function() if ( seat == 0 ) and ( door == 0 ) then local veh = getPedOccupiedVehicle(localPlayer) if ( veh ) and getVehicleController( localPlayer ) then setElementData(veh,"fuel",tonumber(fuelNumber)-1) triggerClientEvent(localPlayer,"onClientRender", root) end end end end,1000,0) addEventHandler("onClientVehicleEnter",getRootElement(),decreaseFuel) Link to comment
tosfera Posted April 25, 2014 Share Posted April 25, 2014 Nikolai, why did you give every vehicle the value '100' when someone joins the server ( onPlayerJoin ). This means that whenever someone joins the server, every vehicle will be refilled on the client side. You can better make it server sided and give the data on the onResourceStart. Don't forget to use the resourceRootElement ( getThisResource() ) to make sure it only does it when that resource starts, which is also a bad thing if they want to save the fuel into a database. 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