Jump to content

[ajuda] porque não esta destriundo o veiculo?


Recommended Posts

porque meu codigo não esta destruindo o veiculo quando o player que spawnou sai dele?  

veiculo = {}
function spawnVeh(source)
   if getPedOccupiedVehicle(source) == false then 
      if getElementData(source, "Eletricista") == true then
         if getElementModel(source) == 11 then 
            veiculo[source] = createVehicle(config.veh, 2458.3537597656,-2078.1528320312,13.546875)
            warpPedIntoVehicle(source, veiculo[source])
            setElementRotation(veiculo[source], 0,0,180)
            setVehicleLocked(veiculo[source],true)
            setVehicleDamageProof(veiculo[source], true)
           
         end
      end
   else 
      outputChatBox("você já esta em um veiculo")
   end 
end
addEvent("spawnCar", true)
addEventHandler("spawnCar", root, spawnVeh)

function onSair(source)
      if getPedOccupiedVehicle(source) == false then 
      destroyElement ( veiculo[source] )
      veiculo[source] = nil
      end
end
addEventHandler("onPedVehicleExit", getRootElement(), onSair)

 

Edited by Lord Henry
Link to comment
  • Other Languages Moderators
function onSair(thePed) -- Nunca use source como parâmetro de função.
    if isElement(veiculo[thePed]) then -- Verifique se o veículo do jogador existe. Se existir, destrói ele.
        destroyElement(veiculo[thePed])
        veiculo[thePed] = nil
    end
end
addEventHandler("onVehicleExit", root, onSair) -- Não use onPedVehicleExit pois ele não funciona para players, só com NPCs.

 

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