KiffShark Posted November 19, 2012 Posted November 19, 2012 Well I don't know if this should be in "Resources" (maybe..) but it's about the script... In the past it works ok but since last update; there aren't gas station markers and possibility of refill... Console give me ERROR at the line "local vehicle = getPedOccupiedVehicle(p);" with "Bad 'ped' pointer @ 'getPedOccupiedVehicle'(1)" function fuelUse(p) local vehicle = getPedOccupiedVehicle(p); -- HEREEEE if vehicle then setTimer(fuelUse,1000,1,p); if getVehicleType(vehicle) ~= 'Automobile' and getVehicleType(vehicle) ~= 'Bike' and getVehicleType(vehicle) ~= 'Monster Truck' and getVehicleType(vehicle) ~= 'Quad' then return end if getVehicleController(vehicle) ~= p then return end --### if getVehicleEngineState(vehicle) == false then return end --### local fuel = getCarFuel(vehicle) if fuel == 0 then setVehicleEngineState(vehicle,false); return end --### --[[local speedX, speedY, speedZ = getElementVelocity(vehicle); vel = (speedX^2 + speedY^2 + speedZ^2)^(0.5)+(math.random(100,1000)/25000);]] local newX,newY,newZ = getElementPosition(vehicle); local oldX = getElementData(vehicle,'oldX') or newX; local oldY = getElementData(vehicle,'oldY') or newY; local oldZ = getElementData(vehicle,'oldZ') or newZ; local vel = (getDistanceBetweenPoints2D(oldX,oldY,newX,newY)/70)+(math.random(100,1000)/50000); local oldX = setElementData(vehicle,'oldX',newX); local oldY = setElementData(vehicle,'oldY',newY); local oldZ = setElementData(vehicle,'oldZ',newZ) --if vel < 0.01 then return end --### local remainingFuel = takeCarFuel(vehicle,vel); if remainingFuel < 0.001 then remainingFuel = 0; outputChatBox('Your car has ran out of fuel.',v); setVehicleEngineState(vehicle,false); end end end I don't say that it is all problems of the resource, but I'd like to fix sted by step... Some idea? https://www.youtube.com/PinkSharkGaming
Castillo Posted November 19, 2012 Posted November 19, 2012 What executes "fuelUse" function? San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
KiffShark Posted November 19, 2012 Author Posted November 19, 2012 this (?) function startFuelUse(p,seat,jacked) if getVehicleType(source) ~= 'Automobile' and getVehicleType(source) ~= 'Bike' and getVehicleType(source) ~= 'Monster Truck' and getVehicleType(source) ~= 'Quad' then return end if seat ~= 0 then return end if getCarFuel(source) <= 0 then setVehicleEngineState(source,false); end setTimer(fuelUse,1000,1,p); end addEventHandler("onVehicleEnter",getRootElement(),startFuelUse) and I have another problem, I want use the exported function of this resource (getCarFuel (type=server)) in a other resource (client file..) (If asking for 2 things in same thread is bad, forget that I've done it...) https://www.youtube.com/PinkSharkGaming
Castillo Posted November 19, 2012 Posted November 19, 2012 Why do you get the vehicle again if you can use 'source' as vehicle? San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
KiffShark Posted November 19, 2012 Author Posted November 19, 2012 because I'm noob so I don't know optimize script so good xDD https://www.youtube.com/PinkSharkGaming
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