Jump to content

Bad 'Ped' Pointer / ERROR


KiffShark

Recommended Posts

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?

Link to comment

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...)

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...