EW1611 Posted July 27, 2019 Share Posted July 27, 2019 esse é o script, a primeira parte, do spawn do veiculo funciona, a segunda ja não local Marker1 = createMarker (119.86518859863, -1832.1979980469, 5, "cylinder", 1.25, 0, 250, 0, 50) local Marker2 = createMarker (127.06451416016, -1848.4306640625, 5, "cylinder", 3, 0, 250, 0, 50) veh = {} function Vehicle1 ( hitPlayer, getPlayerVehicle ) if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(hitPlayer)), aclGetGroup("Mecanico")) then if isElement(Veh1) then destroyElement(Veh1) end local Veh1 = createVehicle(525, 132.57461547852, -1815.671875, 5.795524597168, 0, 0, 270) warpPedIntoVehicle ( hitPlayer, Veh1 ) else outputChatBox ("Você não é um Mecanico", hitPlayer, 0, 0, 0) end end addEventHandler( "onMarkerHit", Marker1, Vehicle1) function Vehicle2 (hitPlayer) if isElementWithinMarker(player, Marker2) then player = nil if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(hitPlayer)), aclGetGroup("Mecanico")) then if isPedInVehicle(veh[player]) then destroyElement(vehicle) else outputChatBox("Você não esta em um veículo", hitPlayer, 0, 0, 0) end end end end addEventHandler("onMarkerHit", Marker2, Vehicle2) no console aparece isto WARNING: Oficina-Mecanica\spawn.Lua:20: Bad argument @ 'isElementWithinMarker' [Expected element at argument 1, got nil] Link to comment
DNL291 Posted July 27, 2019 Share Posted July 27, 2019 Você não vai precisar de isElementWithinMarker no evento "onMarkerHit". Use hitPlayer em vez de player e veh[hitPlayer] em vez de vehicle, também verifique se o hitPlayer é um elemento player com getElementType. Além disso, o vehicle não está sendo adicionado na table 'veh' na função Vehicle1. 1 Link to comment
EW1611 Posted July 27, 2019 Author Share Posted July 27, 2019 (edited) Como poderia verificar se o elemento é player? digo, com ql codigo Edited July 27, 2019 by EW1611 Link to comment
DNL291 Posted July 27, 2019 Share Posted July 27, 2019 if getElementType(hitPlayer) == "player" then 1 Link to comment
EW1611 Posted July 27, 2019 Author Share Posted July 27, 2019 (edited) continua n funcionando '-' local Marker1 = createMarker (119.86518859863, -1832.1979980469, 5, "cylinder", 1.25, 0, 250, 0, 50) local Marker2 = createMarker (127.06451416016, -1848.4306640625, 5, "cylinder", 3, 0, 250, 0, 50) veh = {} function Vehicle1 ( hitPlayer, getPlayerVehicle ) if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(hitPlayer)), aclGetGroup("Mecanico")) then if isElement(Veh1) then destroyElement(Veh1) end local Veh1 = createVehicle(525, 132.57461547852, -1815.671875, 5.795524597168, 0, 0, 270) warpPedIntoVehicle ( hitPlayer, Veh1 ) else outputChatBox ("Você não é um Mecanico", hitPlayer, 0, 0, 0) end end addEventHandler( "onMarkerHit", Marker1, Vehicle1) function Vehicle2 ( hitPlayer ) if getElementType( hitPlayer ) == "player" then if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(hitPlayer)), aclGetGroup("Mecanico")) then if isPedInVehicle( veh[hitPlayer] ) then destroyElement( veh[hitPlayer] ) veh[hitPlayer] = nil else outputChatBox("Você não esta em um veículo", hitPlayer, 0, 0, 0) end end end end addEventHandler("onMarkerHit", Marker2, Vehicle2) [13:41:59] WARNING: Oficina-Mecanica\spawn.Lua:23: Bad argument @ 'destroyElement' [Expected element at argument 1, got nil] Edited July 27, 2019 by EW1611 Link to comment
DNL291 Posted July 27, 2019 Share Posted July 27, 2019 Troque isPedInVehicle por getPedOccupiedVehicle(hitPlayer) e verifique se é o mesmo element que veh[hitPlayer]. Link to comment
EW1611 Posted July 27, 2019 Author Share Posted July 27, 2019 (edited) continua não funcionando, local Marker1 = createMarker (119.86518859863, -1832.1979980469, 5, "cylinder", 1.25, 0, 250, 0, 50) local Marker2 = createMarker (127.06451416016, -1848.4306640625, 5, "cylinder", 3, 0, 250, 0, 50) veh = {} function Vehicle1 ( hitPlayer, getPlayerVehicle ) if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(hitPlayer)), aclGetGroup("Mecanico")) then if isElement(Veh1) then destroyElement(Veh1) end local Veh1 = createVehicle(525, 132.57461547852, -1815.671875, 5.795524597168, 0, 0, 270) warpPedIntoVehicle ( hitPlayer, Veh1 ) else outputChatBox ("Você não é um Mecanico", hitPlayer, 0, 0, 0) end end addEventHandler( "onMarkerHit", Marker1, Vehicle1) function Vehicle2 (hitPlayer) if getElementType(hitPlayer) == "player" then if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(hitPlayer)), aclGetGroup("Mecanico")) then if getPedOccupiedVehicle(hitPlayer) then destroyElement(veh[hitPlayer]) veh[hitPlayer] = nil else outputChatBox("Você não esta em um veículo", hitPlayer, 0, 0, 0) end end end end addEventHandler("onMarkerHit", Marker2, Vehicle2) Edited July 27, 2019 by EW1611 Link to comment
DNL291 Posted July 27, 2019 Share Posted July 27, 2019 Assim: function Vehicle2 (hitPlayer) if getElementType(hitPlayer) == "player" then if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(hitPlayer)), aclGetGroup("Mecanico")) then local vehicle = getPedOccupiedVehicle(hitPlayer) if vehicle and veh[hitPlayer] and vehicle == veh[hitPlayer] then destroyElement(veh[hitPlayer]) veh[hitPlayer] = nil else outputChatBox("Você não esta em um veículo", hitPlayer, 0, 0, 0) end end end end addEventHandler("onMarkerHit", Marker2, Vehicle2) Na função Vehicle1 você deve trocar Veh1 por veh[hitPlayer]. 1 Link to comment
EW1611 Posted July 27, 2019 Author Share Posted July 27, 2019 agora, a partir da função getElementType, fica tudo branco, como se não fosse um script Link to comment
EW1611 Posted July 27, 2019 Author Share Posted July 27, 2019 Deu certo, muito obrigado 1 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