TeixeiraRB Posted January 10, 2018 Share Posted January 10, 2018 Tudo bem? Queria saber como faço para quando o player sair do servidor destruir o veiculo q foi criado quando ele passo pelo marker. Exemplo to fazendo um script de trabalho ai quero q quando o player passa pelo marker vai spawna o veiculo certo? isso eu ja sei fazer mas exemplo a net dele cair so que o veiculo vai fica do servidor ainda entao queria q quando ele sair do sv ia destruir. Link to comment
Other Languages Moderators Lord Henry Posted January 10, 2018 Other Languages Moderators Share Posted January 10, 2018 Use isso: onPlayerQuit destroyElement 1 Link to comment
KaMi Posted January 10, 2018 Share Posted January 10, 2018 10 hours ago, TeixeiraRB said: Tudo bem? Queria saber como faço para quando o player sair do servidor destruir o veiculo q foi criado quando ele passo pelo marker. Exemplo to fazendo um script de trabalho ai quero q quando o player passa pelo marker vai spawna o veiculo certo? isso eu ja sei fazer mas exemplo a net dele cair so que o veiculo vai fica do servidor ainda entao queria q quando ele sair do sv ia destruir. function quitcar(player) local veh = getPedOccupiedVehicle(player) destroyElement(veh) end addEventHandler ( "onPlayerQuit", getRootElement(), quitcar ) 1 Link to comment
Other Languages Moderators Lord Henry Posted January 10, 2018 Other Languages Moderators Share Posted January 10, 2018 1 hour ago, <~KaMiKaZe~> said: function quitcar(player) local veh = getPedOccupiedVehicle(player) destroyElement(veh) end addEventHandler ( "onPlayerQuit", getRootElement(), quitcar ) Vai gerar erro se o jogador que sair não estiver em um veículo. Coloque um verificador para evitar isso. function quitcar (thePlayer) local veh = getPedOccupiedVehicle(thePlayer) if veh then destroyElement(veh) end end addEventHandler ("onPlayerQuit", getRootElement(), quitcar) 1 Link to comment
TeixeiraRB Posted January 10, 2018 Author Share Posted January 10, 2018 Eita. vlw ai obg Link to comment
TeixeiraRB Posted January 10, 2018 Author Share Posted January 10, 2018 Ta dando erro Lord Henry Erro: Markers.lua:18: Bad argument @ 'getPedOccuipedVehicle' [Expected ped at argument 1, got string 'Quit' ] Spawna = createMarker (-314.8583984375, 1546.0322265625, 75.5625 -1, "cylinder", 2, 255 ,0 ,0, 255) veh = {} function Pegar(thePlayer) if isElementWithinMarker(thePlayer, Spawna) then if hilux and isElement( hilux ) then destroyElement ( hilux ) hilux = nil end x,y,z = getElementPosition(thePlayer) Islamico = true hilux = createVehicle(422,-282.26953125, 1529.451171875, 75.359375, 0, 0, 61.878692626953) warpPedIntoVehicle( thePlayer, hilux ) end end addEventHandler( "onMarkerHit", Spawna, Pegar ) function sair(thePlayer) local hilux = getPedOccupiedVehicle(thePlayer) if hilux then destroyElement ( hilux ) end end addEventHandler ("onPlayerQuit", getRootElement(), sair) Link to comment
DNL291 Posted January 10, 2018 Share Posted January 10, 2018 (edited) Parameters string quitType, string reason, element responsibleElement O parâmetro tá errado, tire thePlayer e substitua por source. Edit: Você pode usar a variável hilux pra obter o veículo. Ou também esta função: function destroyPlayerVehicles( p ) local vehicles = getElementsByType( "vehicle" ) for _,v in pairs(vehicles) do local syncer = getElementSyncer(v) if p and syncer == p then destroyElement(v) end end end Edited January 10, 2018 by DNL291 Link to comment
TeixeiraRB Posted January 10, 2018 Author Share Posted January 10, 2018 Ta dando mesmo erro Link to comment
DNL291 Posted January 10, 2018 Share Posted January 10, 2018 Então você ainda não corrigiu, se está o mesmo erro é porque a string QuitType está no lugar do jogador. Coloque source como eu disse. Link to comment
Other Languages Moderators Lord Henry Posted January 11, 2018 Other Languages Moderators Share Posted January 11, 2018 (edited) 21 hours ago, TeixeiraRB said: Ta dando erro Lord Henry Erro: Markers.lua:18: Bad argument @ 'getPedOccuipedVehicle' [Expected ped at argument 1, got string 'Quit' ] Spawna = createMarker (-314.8583984375, 1546.0322265625, 75.5625 -1, "cylinder", 2, 255 ,0 ,0, 255) veh = {} function Pegar(hitElement) if hitElement and getElementType (hitElement) == "player" then if veh[hitElement] and isElement(veh[hitElement]) then destroyElement (veh[hitElement]) veh[hitElement] = nil end local x, y, z = getElementPosition (hitElement) -- Isso não tem utilidade. Islamico = true -- Isso também não. veh[hitElement] = createVehicle(422,-282.26953125, 1529.451171875, 75.359375, 0, 0, 61.878692626953) warpPedIntoVehicle(hitElement, veh[hitElement]) end end addEventHandler("onMarkerHit", Spawna, Pegar) function sair (quitType, reason, responsible) local hilux = getPedOccupiedVehicle(source) if hilux then destroyElement (hilux) end end addEventHandler ("onPlayerQuit", getRootElement(), sair) Edited January 11, 2018 by Lord Henry 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