Argent Posted November 6, 2022 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
Moderators Lord Henry Posted November 7, 2022 Moderators 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. Eu te ajudei ou achou meu comentário útil? Não esqueça de deixar um Thanks! Minhas contribuições para a comunidade: LordHenry - MTA Wiki Profile Inscreva-se no meu canal do YouTube: Lord Henry - Entertainment Discord Oficial do MTA: https://mtasa.com/discord Blacklist e Whitelist de Scripters: Planilha Por favor, não me envie mensagens privadas solicitando suporte. Crie um tópico no fórum em vez disso.
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