victortp Posted June 8, 2013 Share Posted June 8, 2013 Olá. Gostaria de pedir a ajuda de vocês para criar um comando que tenha tempo para usar. Ex: o player digita "/comando" e só pode usar o comando novamente depois de 1 minuto. No caso gostaria pra dar alguns items como: addCommandHandler("kitarmas", true) giveWeapon(source, 4, 200, true) giveWeapon(source, 24, 200, true) end Link to comment
manawydan Posted June 8, 2013 Share Posted June 8, 2013 voce poderia usar setTimer para modificar uma variavel! voce esta criando um resource vip ou algo assim? Link to comment
Moderators DNL291 Posted June 8, 2013 Moderators Share Posted June 8, 2013 (edited) Como dito por manawydan, você pode usar a função setTimer e uma variável para definir um valor booleano que irá permitir/negar o uso do comando. Use uma tabela para definir a boolean para para permitir o uso de cada jogador, se for variável irá afetar todos os jogadores. Além disso, o seu código não vai funcionar porque tem erros. local kitarmasCommand = {} local tempo = 60000 addCommandHandler("kitarmas", function(source) if (kitarmasCommand[source] and kitarmasCommand[source] == false) then outputChatBox("Aguarde 1 minuto para usar este comando novamente", source, 225, 0, 0) return end giveWeapon(source, 4, 200, true) giveWeapon(source, 24, 200, true) setTimer( function() kitarmasCommand[source] = false end, tempo, 1 ) end ) addEventHandler("onPlayerQuit", root, function() if kitarmasCommand[source] then kitarmasCommand[source] = nil end end ) Edited June 9, 2013 by Guest Link to comment
victortp Posted June 9, 2013 Author Share Posted June 9, 2013 @manawydan Sim pretendo mudar isso pra event e colocar na GUI @DNL291 Não funcionou pra mim esse script Link to comment
Moderators DNL291 Posted June 9, 2013 Moderators Share Posted June 9, 2013 O evento onPlayerQuit estava faltando ')' para fechar a função addEventHandler. Tente novamente com o código que eu editei acima. Link to comment
victortp Posted June 9, 2013 Author Share Posted June 9, 2013 @DNL291 Agora está funcionando, mas o timer não.. tipo, ta podendo usar várias vezes seguidas ;s Link to comment
Vision Posted June 9, 2013 Share Posted June 9, 2013 Tenta esse local kitarmasCommand = { } local tempo = 60000 addCommandHandler ( "kitarmas", function ( source ) if ( kitarmasCommand [ source ] ) then return outputChatBox ( "Aguarde 1 minuto para usar este comando novamente", source, 225, 0, 0 ) end giveWeapon ( source, 4, 200, true ) giveWeapon ( source, 24, 200, true ) kitarmasCommand [ source ] = true setTimer ( function ( ) kitarmasCommand [ source ] = false end , tempo, 1 ) end ) addEventHandler ( "onPlayerQuit", root, function ( ) if ( kitarmasCommand [ source ] ) then kitarmasCommand [ source ] = nil end end ) 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