Jump to content

Fuel Script... [ HELP / CODE ]


xScatta

Recommended Posts

Why it is wrong?

CODE:

fuelTimers = {} 
  
function aFuel() 
    if not ( getElementData(source,"fuel") ) then 
    setElementData(source,"fuel",25) 
    end 
end 
  
function dropFuel(player,seat,jacked,vehicle,timer) 
    if getElementData(source,"fuel") then if  
      getVehicleController(source) then if 
          getVehicleEngineState(source)== true 
       then 
       vehicle = source 
       timer = setTimer ( function (vehiclex) local vehiclex = vehicle if getVehicleController(vehiclex) then if getVehicleEngineState(vehiclex)==true then if getElementData(vehiclex,"fuel")~= 0 then local vehiclex = vehicle setElementData(vehiclex,"fuel",getElementData(vehiclex,"fuel")-1)end end end end, 1000, 0 ) 
       fuelTimers[vehicle] = timer 
       addEventHandler("onVehicleExit",getRootElement(),killFuelTimer) 
end 
end 
end 
end 
  
function killFuelTimer() 
if source == fuelTimers[vehicle] then 
killTimer(fuelTimers[vehicle]) 
end 
end 
  
function testFuel(playerSource) 
    if isPedInVehicle(playerSource) then 
        if getVehicleController(getPedOccupiedVehicle(playerSource))== playerSource then 
            if getElementData(getPedOccupiedVehicle(playerSource),"fuel") then 
                if getElementData(getPedOccupiedVehicle(playerSource),"fuel")==0 then 
                    setVehicleEngineState(getPedOccupiedVehicle(playerSource),false) 
                    outputChatBox("Nie masz paliwa w samochodzie",playerSource) 
                    else 
                    outputChatBox("Masz paliwo w samochodzie",playerSource) 
                end 
                else outputChatBox("Ten pojazd nie ma paliwa w sobie",playerSource) 
            end 
        end 
    end 
end 
  
addCommandHandler("tf",testFuel) 
addEventHandler("onVehicleStartEnter",getRootElement(),aFuel) 
addEventHandler("onVehicleEnter",getRootElement(),dropFuel) 

Link to comment
fuelTimers = { } 
  
function aFuel ( ) 
    if ( not getElementData ( source, "fuel" ) ) then 
        setElementData ( source, "fuel", 25 ) 
    end 
end 
  
function dropFuel ( player, seat, jacked ) 
    if getElementData ( source, "fuel" ) then 
        if getVehicleController ( source ) then 
            if ( getVehicleEngineState ( source ) == true ) then 
                fuelTimers [ source ] = setTimer ( 
                    function ( vehiclex ) 
                        if getVehicleController ( vehiclex ) then 
                            if ( getVehicleEngineState ( vehiclex ) == true ) then 
                                if ( getElementData ( vehiclex, "fuel" ) ~= 0 ) then 
                                    setElementData ( vehiclex, "fuel", getElementData ( vehiclex, "fuel" ) - 1 ) 
                                end 
                            end 
                        end 
                    end 
                    ,1000, 0, source 
                ) 
            end 
        end 
    end 
end 
  
function killFuelTimer ( _, seat ) 
    if ( seat == 0 ) then 
        if isTimer ( fuelTimers [ source ] ) then 
            killTimer ( fuelTimers [ source ] ) 
        end 
    end 
end 
addEventHandler ( "onVehicleExit", getRootElement(), killFuelTimer ) 
  
function testFuel ( playerSource ) 
    if isPedInVehicle ( playerSource ) then 
        local vehicle = getPedOccupiedVehicle ( playerSource ) 
        if ( getVehicleController ( vehicle ) == playerSource ) then 
            if getElementData ( vehicle, "fuel" ) then 
                if ( getElementData ( vehicle, "fuel" ) == 0 ) then 
                    setVehicleEngineState ( vehicle, false ) 
                    outputChatBox ( "Nie masz paliwa w samochodzie", playerSource ) 
                else 
                    outputChatBox ( "Masz paliwo w samochodzie", playerSource ) 
                end 
            else 
                outputChatBox ( "Ten pojazd nie ma paliwa w sobie", playerSource ) 
            end 
        end 
    end 
end 
addCommandHandler ( "tf", testFuel ) 
addEventHandler ( "onVehicleStartEnter", getRootElement(), aFuel ) 
addEventHandler ( "onVehicleEnter", getRootElement(), dropFuel ) 

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