+[T]rakin Posted March 11, 2019 Posted March 11, 2019 Um amigo meu pediu para fazer um script de trabalho simples para ele blz desde de quando comecei a fazer trabalho sempre usava o mesmo codigo e nunca dava erro agora não sei porque está dando erro. Erro : Bad argument @ 'isElementWithinMarker' [Expected element at argument 1] server-side Marker_Inicio = createMarker(2494.508, -1750.817, 13.481 -1, "cylinder", 2, 255, 255, 255, 120) Blip_Inicio = createBlipAttachedTo(Marker_Inicio, 42) Marker_Fim = createMarker(2478.646, -1728.972, 13.383 -1, "cylinder", 2, 255, 255, 255, 120) Blip_Fim = createBlipAttachedTo(Marker_Fim, 19) veh = {} function Inicio (source) if isElementWithinMarker(source, Marker_Inicio) then if veh[source] and isElement(veh[source]) then destroyElement( veh[source] ) veh[source] = nil end veh[source] = createVehicle(422, 2481.013, -1747.164, 13.547, -0, 0, 2.78) warpPedIntoVehicle(source, veh[source]) end end addEventHandler("onMarkerHit", Marker_Inicio, Inicio) function Fim (source) if veh[source] and isElement(veh[source]) then destroyElement( veh[source] ) veh[source] = nil end end addEventHandler("onMarkerHit", Marker_Fim, Fim)
DNL291 Posted March 11, 2019 Posted March 11, 2019 (edited) Qual a utilidade da função isElementWithinMarker sendo a já tem o evento onMarkerHit? Tire essa função pois ela parece desnecessária e use um nome mais adequado para o parâmetro em vez de source. Edited March 11, 2019 by DNL291 1 Please do not PM me with scripting related question nor support, use the forums instead.
+[T]rakin Posted March 11, 2019 Author Posted March 11, 2019 (edited) 15 minutes ago, DNL291 said: Qual a utilidade da função isElementWithinMarker sendo a já tem o evento onMarkerHit? Tire essa função pois ela parece desnecessária e use um nome mais adequado para o parâmetro em vez de source. Quando tiro da erro no primeiro argumento no warpPedIntoVehicle. É porque eu aprendi assim e eu acabo me acostumando Ja tentei thePlayer e player e sempre dando erro desse argumentos. Edited March 11, 2019 by +[T]rakin
DNL291 Posted March 11, 2019 Posted March 11, 2019 Nunca é tarde pra perder os maus costumes. Sobre o erro em warpPedIntoVehicle, tente assim que deve funcionar: local Marker_Inicio = createMarker(2494.508, -1750.817, 13.481 -1, "cylinder", 2, 255, 255, 255, 120) local Blip_Inicio = createBlipAttachedTo(Marker_Inicio, 42) local Marker_Fim = createMarker(2478.646, -1728.972, 13.383 -1, "cylinder", 2, 255, 255, 255, 120) local Blip_Fim = createBlipAttachedTo(Marker_Fim, 19) local veh = {} function Inicio (thePlayer) if getElementType(thePlayer) == "player" and not (isPedInVehicle(thePlayer) then if veh[thePlayer] and isElement(veh[thePlayer]) then destroyElement( veh[thePlayer] ) veh[thePlayer] = nil end veh[thePlayer] = createVehicle(422, 2481.013, -1747.164, 13.547, -0, 0, 2.78) warpPedIntoVehicle(thePlayer, veh[thePlayer]) end end addEventHandler("onMarkerHit", Marker_Inicio, Inicio) function Fim (thePlayer) if veh[thePlayer] and isElement(veh[thePlayer]) then destroyElement( veh[thePlayer] ) veh[thePlayer] = nil end end addEventHandler("onMarkerHit", Marker_Fim, Fim) 1 Please do not PM me with scripting related question nor support, use the forums instead.
+[T]rakin Posted March 11, 2019 Author Posted March 11, 2019 Pegou perfeito mas provavelmente algum jogador vai passa com o carro no trabalho no Marker_Inicio e se isso acontece vai está dando erro no primeiro arguento do getElementType
Moderators Lord Henry Posted March 11, 2019 Moderators Posted March 11, 2019 Não vai. Pois dará false naquela condição e o script vai ignorar. 1 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.
+[T]rakin Posted March 11, 2019 Author Posted March 11, 2019 Beleza obrigado. Eu fiz um pouco mais complexo para fica sem erros e no jeito que meu amigo pediu. Thanks pelo support.
DNL291 Posted March 11, 2019 Posted March 11, 2019 getElementType aceita qualquer elemento no argumento ao contrário da warpPedIntoVehicle que só aceita o ped, então não vai dar erro. Mas se você mudar a ordem deixando primeiro a verificação isPedInVehicle certamente dará aquele mesmo erro que na função warpPedIntoVehicle. 1 Please do not PM me with scripting related question nor support, use the forums instead.
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