Doongogar Posted February 28, 2023 Share Posted February 28, 2023 porque nenhum dos dois esta funcionando? function destruirKombiMorte() local driver = getVehicleOccupant(vehicle) if driver and isElement(driver) and getElementType(driver) == "player" and getPedOccupiedVehicleSeat(driver) == 0 then if getElementData(vehicle, "kombiEntregas") == true then destroyElement(vehicle) end end end addEventHandler("onPlayerWasted", getRootElement(), destruirKombiMorte) function destruiKombiExit(player, seat) if seat == 0 then local vehicle = getPedOccupiedVehicle(player) if vehicle then if getElementData(vehicle, "kombiEntregas") == true then destroyElement(vehicle) end end end end addEventHandler("onVehicleExit", getRootElement(), destruiKombiExit) Link to comment
FelipeX Posted February 28, 2023 Share Posted February 28, 2023 4 hours ago, SciptNovato said: porque nenhum dos dois esta funcionando? function destruirKombiMorte() local driver = getVehicleOccupant(vehicle) if driver and isElement(driver) and getElementType(driver) == "player" and getPedOccupiedVehicleSeat(driver) == 0 then if getElementData(vehicle, "kombiEntregas") == true then destroyElement(vehicle) end end end addEventHandler("onPlayerWasted", getRootElement(), destruirKombiMorte) function destruiKombiExit(player, seat) if seat == 0 then local vehicle = getPedOccupiedVehicle(player) if vehicle then if getElementData(vehicle, "kombiEntregas") == true then destroyElement(vehicle) end end end end addEventHandler("onVehicleExit", getRootElement(), destruiKombiExit) No onVehicleExit já vem o elemento do veiculo no evento, sempre será "source", então não é necessario o getPedOccupiedVehicle. No onVehicleExit EU ACHO que não tem como fazer a verificação se ele esta dentro do carro, por ele ja esta morto, por isso eu setei o elemento numa tabela junto com o assento. --[[ █▀▀▀█ █▀▀▀ ▀▀█▀▀ █▀▀█ █▀▀█ █▀▀▀ █░░░ █▀▀▀ █▀▄▀█ █▀▀▀ █▄░▒█ ▀▀█▀▀ █▀▀▀█ ▀▀▀▄▄ █▀▀▀ ░▒█░░ █▄▄█ █▄▄▀ █▀▀▀ █░░░ █▀▀▀ █▒█▒█ █▀▀▀ █▒█▒█ ░▒█░░ █░░▒█ █▄▄▄█ █▄▄▄ ░▒█░░ █░▒█ █░▒█ █▄▄▄ █▄▄█ █▄▄▄ █░░▒█ █▄▄▄ █░░▀█ ░▒█░░ █▄▄▄█ ]]-- local theVehicle = { Element = nil, Seat = 0 } -- Cria a tabela addEventHandler("onVehicleEnter", root, function(theP) if source then -- Se tiver o veiculo, então: theVehicle = { Element = source, Seat = getPedOccupiedVehicleSeat(theP) } -- Coloca o element do carro e o assento. end end) --[[ █▀▀▄ █▀▀▀ █▀▀▀█ ▀▀█▀▀ █▀▀█ █░▒█ ▀█▀ █▀▀█ █░▄▀ █▀▀▀█ █▀▄▀█ █▀▀█ ▀█▀ █░▒█ █▀▀▀ ▀▀▀▄▄ ░▒█░░ █▄▄▀ █░▒█ ░█░ █▄▄▀ █▀▄░ █░░▒█ █▒█▒█ █▀▀▄ ░█░ █▄▄▀ █▄▄▄ █▄▄▄█ ░▒█░░ █░▒█ ▀▄▄▀ ▄█▄ █░▒█ █░▒█ █▄▄▄█ █░░▒█ █▄▄█ ▄█▄ ]]-- local destruiKombiExit = function(thePlayer, seat) if seat == 0 and getElementData(source, "kombiEntregas") == true then -- Verificação desejada destroyElement(source) -- Destruir carro end end addEventHandler("onVehicleExit", getRootElement(), destruiKombiExit) --[[ █▀▀▄ █▀▀▀ █▀▀▀█ ▀▀█▀▀ █▀▀█ █░▒█ ▀█▀ █▀▀█ ░░ █▀▄▀█ █▀▀▀█ █▀▀█ █▀▀█ █▀▀▀ █▀▀█ █░▒█ █▀▀▀ ▀▀▀▄▄ ░▒█░░ █▄▄▀ █░▒█ ░█░ █▄▄▀ ▀▀ █▒█▒█ █░░▒█ █▄▄▀ █▄▄▀ █▀▀▀ █▄▄▀ █▄▄▀ █▄▄▄ █▄▄▄█ ░▒█░░ █░▒█ ▀▄▄▀ ▄█▄ █░▒█ ░░ █░░▒█ █▄▄▄█ █░▒█ █░▒█ █▄▄▄ █░▒█ ]]-- local destruirKombiMorte = function () if theVehicle.Seat == 0 then -- Se o assento for o p1, então: if getElementData(theVehicle.Element, "kombiEntregas") == true then destroyElement(theVehicle.Element) -- Destroi o elemento Carro. end end end addEventHandler("onPlayerWasted", root, destruirKombiMorte) 1 Link to comment
Doongogar Posted March 1, 2023 Author Share Posted March 1, 2023 o element data ja estava sendo setado como true ao criar o veiculo, obrigado Link to comment
Recommended Posts