mahteus1 Posted December 25, 2018 Posted December 25, 2018 (edited) Markertrab = createMarker(2275.962890625, -1766.6162109375, 13.546875 -1, "cylinder",2.0 ,1, 255, 0, 255) veh[ThePlayer] = () function Trab(ThePlayer) if isElementWithinMarker(ThePlayer, Markertrab) then if veh[ThePlayer] and isElement( veh[ThePlayer] ) then destroyElement ( veh[ThePlayer] ) veh(ThePlayer) = nil end x,y,z = getElementPosition(ThePlayer) Trabalho = true veh[ThePlayer] = createVehicle(431,2266.1005859375, -1751.3544921875, 13.3828125) setPedSkin ( ThePlayer, 431 ) outputChatBox("#00ff00=========================================",ThePlayer,0,0,0,true ) outputChatBox("#ff00ffLeve O Véiculo Até o Blip Em Seu Radar!!!",ThePlayer,0,0,0,true ) outputChatBox("#00ff00=========================================",ThePlayer,0,0,0,true ) end end addEventHandler( "onMarkerHit", Markertrab, Trab ) Edited December 25, 2018 by jhxp
MTA Team jhxp Posted December 25, 2018 MTA Team Posted December 25, 2018 Please use code tag <> and mark your code as Lua next time. Also make sure to post in the correct section. One of the [VCP] leaders // honorary member of the =PCP= gang. Do not PM me your MTA:SA Client / Server support questions, Lua scripting questions, unban requests or server toplist concerns - please ask them here: MTA:SA Support subforum, here: Scripting subforum, here: Ban appeals or here: Servers instead. For other inquiries - please expect delays in replies when messaging me.
Moderators Lord Henry Posted December 25, 2018 Moderators Posted December 25, 2018 Markertrab = createMarker(2275.962890625, -1766.6162109375, 13.546875 -1, "cylinder",2.0 ,1, 255, 0, 255) veh[ThePlayer] = () -- ERRO, uma tabela é declarada com {} e não com parênteses. function Trab(ThePlayer) if isElementWithinMarker(ThePlayer, Markertrab) then if veh[ThePlayer] and isElement( veh[ThePlayer] ) then destroyElement ( veh[ThePlayer] ) veh(ThePlayer) = nil end x,y,z = getElementPosition(ThePlayer) -- Essas variáveis provavelmente devem ser locais. Trabalho = true -- Qual a utilidade disso? veh[ThePlayer] = createVehicle(431,2266.1005859375, -1751.3544921875, 13.3828125) setPedSkin ( ThePlayer, 431 ) outputChatBox("#00ff00=========================================",ThePlayer,0,0,0,true ) -- Declare as cores nos parâmetros RGB em vez de código #hex. outputChatBox("#ff00ffLeve O Veiculo Até o Blip Em Seu Radar!!!",ThePlayer,0,0,0,true ) outputChatBox("#00ff00=========================================",ThePlayer,0,0,0,true ) end end addEventHandler( "onMarkerHit", Markertrab, Trab ) Comentei o que vi de problemas no código. Corrija-os. 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.
mahteus1 Posted December 25, 2018 Author Posted December 25, 2018 fiz todas alteraçoes mas n funcionou, quebrando a cabeça com isso ;(
Moderators Lord Henry Posted December 25, 2018 Moderators Posted December 25, 2018 Como ficou seu código? 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.
DNL291 Posted December 25, 2018 Posted December 25, 2018 Fiz o código mostrando os erros e outro com a correção, leia as linhas comentadas por favor: Markertrab = createMarker(2275.962890625, -1766.6162109375, 13.546875 -1, "cylinder",2.0 ,1, 255, 0, 255) -- use variáveis localmente sempre que puder veh[ThePlayer] = () -- "ThePlayer" será nulo e depois de "=" deve ser {} function Trab(ThePlayer) -- faltou verificar se o elemento que colidiu com a marker é mesmo um jogador if isElementWithinMarker(ThePlayer, Markertrab) then -- função inútil, a função já será chamada no evento "onMarkerHit" if veh[ThePlayer] and isElement( veh[ThePlayer] ) then destroyElement ( veh[ThePlayer] ) veh(ThePlayer) = nil -- forma errada de indexar a tabela; deve ser veh[ThePlayer] como está na linha acima -- além disso, você não vai precisar setar nil aqui já que será definido logo abaixo um valor nesse endereço end x,y,z = getElementPosition(ThePlayer) Trabalho = true -- troque com um: setElementData(ThePlayer, "Trabalho", true, false) veh[ThePlayer] = createVehicle(431,2266.1005859375, -1751.3544921875, 13.3828125) setPedSkin ( ThePlayer, 431 ) -- você está setando o mesmo ID do veículo como skin, esse id de skin não existe -- além disso, setPedSkin é uma função obsoleta, deve ser setElementModel outputChatBox("#00ff00=========================================",ThePlayer,0,0,0,true ) outputChatBox("#ff00ffLeve O Véiculo Até o Blip Em Seu Radar!!!",ThePlayer,0,0,0,true ) outputChatBox("#00ff00=========================================",ThePlayer,0,0,0,true ) end end addEventHandler( "onMarkerHit", Markertrab, Trab ) Corrigido: local Markertrab = createMarker(2275.962890625, -1766.6162109375, 13.546875 -1, "cylinder",2.0 ,1, 255, 0, 255) local veh = {} function Trab(ThePlayer, md) if getElementType(ThePlayer) == "player" and isPedInVehicle(ThePlayer) ~= true and md then if veh[ThePlayer] and isElement( veh[ThePlayer] ) then destroyElement ( veh[ThePlayer] ) end local x,y,z = getElementPosition(ThePlayer) setElementData(ThePlayer, "Trabalho", true, false) veh[ThePlayer] = createVehicle(431, x, y, z + 1) --setElementModel ( ThePlayer, um_id_de_skin_valido_aqui ) outputChatBox("#00ff00=========================================",ThePlayer,0,0,0,true ) outputChatBox("#ff00ffLeve O Véiculo Até o Blip Em Seu Radar!!!",ThePlayer,0,0,0,true ) outputChatBox("#00ff00=========================================",ThePlayer,0,0,0,true ) end end addEventHandler( "onMarkerHit", Markertrab, Trab ) Lembre-se antes de testar, ative o debug mode: /debugscript 3 Se não funcionar e não mostrar erros no debug, mostre aqui o seu arquivo meta.xml. Please do not PM me with scripting related question nor support, use the forums instead.
mahteus1 Posted January 3, 2019 Author Posted January 3, 2019 (edited) local Markertrab = createMarker(2275.962890625, -1766.6162109375, 13.546875 -1, "cylinder",2.0 ,1, 255, 0, 255) local veh = {} function Trab(ThePlayer, md) if getElementType(ThePlayer) == "player" and isPedInVehicle(ThePlayer) ~= true and md then if veh[ThePlayer] and isElement( veh[ThePlayer] ) then destroyElement ( veh[ThePlayer] ) end local x,y,z = getElementPosition(ThePlayer) setElementData(ThePlayer, "Trabalho", true, false) veh[ThePlayer] = createVehicle(431, x, y, z + 1) setElementModel ( ThePlayer, 146 ) outputChatBox("#00ff00=========================================",ThePlayer,0,0,0,true ) outputChatBox("#ff00ffLeve O Véiculo Até o Blip Em Seu Radar!!!",ThePlayer,0,0,0,true ) outputChatBox("#00ff00=========================================",ThePlayer,0,0,0,true ) end end addEventHandler( "onMarkerHit", Markertrab, Trab ) <meta> <script src="ggg.lua" type="server"/> </meta> https://imgur.com/a/PH5pDSm Edited January 3, 2019 by mahteus1
DNL291 Posted January 5, 2019 Posted January 5, 2019 (edited) O código não parece ter erros, pode ser um símbolo pelo código causando isso. Tenta copiando por aqui: https://pastebin.com/nnrVBEiJ Edit: @mahteus1 Edited January 9, 2019 by DNL291 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