Big Smoker Posted December 31, 2021 Posted December 31, 2021 BOA TARDE, Desde já desejo um FELIZ ANO NOVO A TODOS DA COMUNIDADE. Venho pedir a ajuda de voces, ja tentei e tudo e o erro ainda continua. Eu coloquei um Timer quando o "ped" sai de uma ColShope e ele executa este element. So que ele nao reconhece o Element e da o ERRO OBRIGADO Bad argument @ 'setElementData' [Expected element at argument 1] function ZombieExit2(element) if isElement(element) and getElementType(element) == "ped" then local spawn_ztype = tonumber(getElementData(element,"spawn_ztype")) if spawn_ztype == 9 or spawn_ztype == 11 or spawn_ztype == 2 or spawn_ztype == 3 or spawn_ztype == 4 or spawn_ztype == 5 or spawn_ztype == 6 or spawn_ztype == 7 or spawn_ztype == 8 or spawn_ztype == 10 or spawn_ztype == 20 then setElementData(element,"zombieExit",element) setTimer(function(element) setElementData(element,"zombieTimer",getElementData(element)) end,40000,1,element) end end end addEventHandler ( "onColShapeLeave", ColCuboid2, ZombieExit2 )
angeluni Posted January 3, 2022 Posted January 3, 2022 (edited) Qual dos setElementData deu erro? o dentro do setTimer? se for tira o element dos parametros da função e cria uma variavel antes do setTimer, ped = element e usa ela como referencia eu tentaria assim: function ZombieExit2(element) if isElement(element) and getElementType(element) == "ped" then local spawn_ztype = tonumber(getElementData(element,"spawn_ztype")) if spawn_ztype == 9 or spawn_ztype == 11 or spawn_ztype == 2 or spawn_ztype == 3 or spawn_ztype == 4 or spawn_ztype == 5 or spawn_ztype == 6 or spawn_ztype == 7 or spawn_ztype == 8 or spawn_ztype == 10 or spawn_ztype == 20 then setElementData(element,"zombieExit",element) ped = element setTimer(function() setElementData(ped,"zombieTimer",getElementData(ped)) end,40000,1) end end end addEventHandler ( "onColShapeLeave", ColCuboid2, ZombieExit2 ) espero que te ajude de alguma forma, vlw Edited January 3, 2022 by angeluni
Moderators Lord Henry Posted January 3, 2022 Moderators Posted January 3, 2022 @BruXo Isso ocorreu pois você gerou conflito de variáveis. No seu setTimer, você passa o element por parâmetro e usa ele mesmo dentro da função, mas dentro da função ele não existe. Apenas utilize outra variável dentro do setTimer que não seja igual aquela que você está passando. setTimer(function(theElement) -- 2) local theElement = element setElementData(theElement, "zombieTimer", getElementData(theElement)) -- 3) Use o theElement dentro do setTimer. end, 40000, 1, element) -- 1) Passou o element por parâmetro aqui. 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.
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