Dinho Posted July 28, 2017 Posted July 28, 2017 (edited) Olá eu estou tentando colocar temporizador nesse script de vida/colete mais não consigo code commando = { } tempo = 20000 --Extra Gesundheit einkaufen! function buyhealth ( thePlayer ) if (commando[playerSource]) then return outputChatBox ( "Aguarde 15 segundos para user o comando novamente", playerSource, 255, 0, 0, true ) end local money = getPlayerMoney ( thePlayer ) if money >= 250 then outputChatBox ('#ffffff[#00FF00Vida#ffffff] ' .. getPlayerName(thePlayer) .. '#ffffff Comprou Uma [#00FF00/vida#ffffff] Por #00FF00R$: 500', root, 255, 255, 255, true) commando[playerSource] = true setTimer( function() commando[playerSource] = false local thePlayerhealth = getElementHealth ( thePlayer ) setElementHealth ( thePlayer, 569 ) takePlayerMoney ( thePlayer, 500 ) else outputChatBox("A Vida Custa 500$!",thePlayer, 255, 0, 0) end, tempo, 1) end addCommandHandler ( "vida", buyhealth ) Edited July 28, 2017 by Dinho
Moderators Lord Henry Posted August 1, 2017 Moderators Posted August 1, 2017 (edited) Você precisa fechar a função do timer antes de sair do escopo dele. No caso, você interrompeu o timer com um ELSE e depois tentou fechar o timer depois do ELSE. Eu teria feito assim: commando = { } tempo = 20000 function buyhealth ( thePlayer ) if (commando[playerSource]) then --Existe algum motivo para usar playerSource em vez de thePlayer? return outputChatBox ( "Aguarde 15 segundos para usar o comando novamente", playerSource, 255, 0, 0, true ) end local money = getPlayerMoney ( thePlayer ) if money >= 250 then --Aqui deveria ser 500 ou vc quer permitir que o jogador fique devendo $250? outputChatBox ("[#00FF00Vida#ffffff] " .. getPlayerName(thePlayer) .. "#ffffff Comprou Uma [#00FF00/vida#ffffff] Por #00FF00R$: 500", root, 255, 255, 255, true) commando[playerSource] = true local thePlayerhealth = getElementHealth ( thePlayer ) --Alguma utilidade em guardar a vida numa variável que não está sendo usada? setElementHealth ( thePlayer, 569 ) --Até onde eu sei, um jogador não pode ter mais do que 200 de vida. takePlayerMoney ( thePlayer, 500 ) setTimer( function() commando[playerSource] = false end, tempo, 1) else outputChatBox ("A Vida Custa 500$!", thePlayer, 255, 0, 0) end end addCommandHandler ( "vida", buyhealth ) Edited August 1, 2017 by Lord Henry 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