Argent Posted November 6, 2022 Share Posted November 6, 2022 (edited) 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 November 7, 2022 by Lord Henry Link to comment
Other Languages Moderators Lord Henry Posted November 7, 2022 Other Languages Moderators Share Posted November 7, 2022 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
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