Jump to content

[HELP] Respawn Vehicle on playerExit


opnaiC

Recommended Posts

Posted
function bmxS() 
local player = getPedOccupiedVehicle ( thePlayer ) 
local bmx = { [510]=true } 
   if bmx[getElementModel(source)] then 
   local = setTimer(respawnVehicle, 5000, 1, source) 
   else 
   for timerKey, timerValue in ipairs(timers) do 
   killTimer(5000) 
   end 
end 
end 
addEventHandler("onVehicleExit", root, bmxS) 

My function isnt working. When a player leaves the vehicle it should respawn, but when he is entering it again it shouldnt.

Posted
local bmx = { [510]=true } 
  
function bmxS(player, seat) 
    local model = getElementModel (source) 
    if bmx[model] then  
        setTimer(respawnVehicle, 5000, 1, source) 
    end  
end 
addEventHandler("onVehicleExit", root, bmxS) 

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted
local bmx = { [510]=true } 
  
function bmxS(player, seat) 
    local model = getElementModel (source) 
    if bmx[model] then  
        setTimer(respawnVehicle, 5000, 1, source) 
    end  
end 
addEventHandler("onVehicleExit", root, bmxS) 

But how I can destroy the time when he enters again the vehicle

Posted
  
local bmx = { [510]=true } 
  
function bmxS(player, seat) 
    local model = getElementModel (source) 
    if bmx[model] then 
        timer = setTimer(respawnVehicle, 5000, 1, source) 
    end 
end 
addEventHandler("onVehicleExit", root, bmxS) 
  
function stopr () 
if bmx[model] then 
   elseif (isTimer(timer)) then killTimer(timer) 
end 
end 
addEventHandler("onVehicleEnter", root, stopr) 
  

Posted

you don't need to destroy it because the timesToExecute it's not 0 (infinite repetitions) , it will be destroyed after 5 seconds.

Anyways you can use smth like this if you use a timer > then 10 seconds.

local bmx = { [510]=true } 
local destroy = {} 
  
function bmxS(player, seat) 
    local model = getElementModel (source) 
    if eventName == "onVehicleExit" then  
        if bmx[model] then 
            destroy[source] = setTimer(respawnVehicle, 5000, 1, source) 
        end 
    elseif eventName == "onVehicleEnter" then  
        if isTimer (destroy[source]) then  
            killTimer(destroy[source]) 
        end  
    end  
end 
addEventHandler("onVehicleExit", root, bmxS) 
addEventHandler ("onVehicleEnter", root, bmxS) 

Edit: :fp: @swedishboy

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

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