Postado Junho 12, 2014 10 anos Oi tudo bem galera do tk? Tentei criar um script para promover o player por talkactions --Made by llucas75-- local verifica = getPlayerVocation(cid) local verifica1 = getPlayerItemCount(cid, voc.item) local posplayer = getCreaturePosition(cid) local nome = getPlayerVocationName(cid) local voc = { [1] = {vocatual = 1, vocnova = 5, preco = 2, item = 2160, nome = "0 k"}, [2] = {vocatual = 2, vocnova = 6, preco = 2, item = 2160, nome = "0 k"}, [3] = {vocatual = 3, vocnova = 7, preco = 2, item = 2160, nome = "0 k"}, [4] = {vocatual = 4, vocnova = 8, preco = 2, item = 2160, nome = "0 k"} } function onSay(cid, words, param, channel) if verifica == voc.vocatual then if verifica1 >= voc.preco then doPlayerSetVocation(cid, verifica + 4) doPlayerSendTextMessage(cid,22, "Voce foi promovido para " ..voc.vocnova.. " .") doSendMagicEffect(posplayer, 13) doPlayerRemoveItem(cid, voc.item, voc.preco) else doPlayerSendTextMessage(cid,22, "Voce nao tem " ..voc.preco.. " " ..nome.. " para ser promovido para" ..voc.vocnova.. " .") return true end else doPlayerSendTextMessage(cid,22, "Voce ja possui todas as promotions.") return true end end Só que esta dando o seguinte erro(anexo) Pq voc é nulo? O que eu fiz de errado? rsrsrsrs Att:lucas
Postado Junho 13, 2014 10 anos funções que pegam algo do player não podem ficar fora do callback!local verifica = getPlayerVocation(cid)local verifica1 = getPlayerItemCount(cid, voc.item)local posplayer = getCreaturePosition(cid)local nome = getPlayerVocationName(cid) isso daqui tá sendo executado quando liga o server mas o cid é nulo já que tá sendo executado ao abrir o server.
Postado Junho 13, 2014 10 anos Autor Que inútil que eu sou de não saber isso -_- enfim o erro persiste.. 3/6/2014 11:49:38] [Error - TalkAction Interface] [13/6/2014 11:49:38] data/talkactions/scripts/promo.lua:onSay [13/6/2014 11:49:38] Description: [13/6/2014 11:49:38] data/talkactions/scripts/promo.lua:7: attempt to index global 'voc' (a nil value) [13/6/2014 11:49:38] stack traceback: [13/6/2014 11:49:38] data/talkactions/scripts/promo.lua:7: in function promo.lua --Made by llucas75-- function onSay(cid, words, param, channel) local verifica = getPlayerVocation(cid) local verifica1 = getPlayerItemCount(cid, voc.item) local posplayer = getCreaturePosition(cid) local nome = getPlayerVocationName(cid) local voc = { [1] = {vocatual = 1, vocnova = 5, preco = 2, item = 2160, nome = "0 k"}, [2] = {vocatual = 2, vocnova = 6, preco = 2, item = 2160, nome = "0 k"}, [3] = {vocatual = 3, vocnova = 7, preco = 2, item = 2160, nome = "0 k"}, [4] = {vocatual = 4, vocnova = 8, preco = 2, item = 2160, nome = "0 k"} } if verifica == voc.vocatual then if verifica1 >= voc.preco then doPlayerSetVocation(cid, verifica + 4) doPlayerSendTextMessage(cid,22, "Voce foi promovido para " ..voc.vocnova.. " .") doSendMagicEffect(posplayer, 13) doPlayerRemoveItem(cid, voc.item, voc.preco) else doPlayerSendTextMessage(cid,22, "Voce nao tem " ..voc.preco.. " " ..nome.. " para ser promovido para" ..voc.vocnova.. " .") return true end else doPlayerSendTextMessage(cid,22, "Voce ja possui todas as promotions.") return true end end Editado Junho 13, 2014 10 anos por llucas75 (veja o histórico de edições)
Postado Junho 13, 2014 10 anos vc ta chamando um item da table que ainda não existe. local verifica1 = getPlayerItemCount(cid, voc.item) a table tá ali embaixo \/ então é como se não existisse ainda. Deixa assim: --Made by llucas75-- local voc = { [1] = {vocatual = 1, vocnova = 5, preco = 2, item = 2160, nome = "0 k"}, [2] = {vocatual = 2, vocnova = 6, preco = 2, item = 2160, nome = "0 k"}, [3] = {vocatual = 3, vocnova = 7, preco = 2, item = 2160, nome = "0 k"}, [4] = {vocatual = 4, vocnova = 8, preco = 2, item = 2160, nome = "0 k"} } function onSay(cid, words, param, channel) local verifica = getPlayerVocation(cid) local verifica1 = getPlayerItemCount(cid, voc.item) local posplayer = getCreaturePosition(cid) local nome = getPlayerVocationName(cid) if verifica == voc.vocatual then if verifica1 >= voc.preco then doPlayerSetVocation(cid, verifica + 4) doPlayerSendTextMessage(cid,22, "Voce foi promovido para " ..voc.vocnova.. " .") doSendMagicEffect(posplayer, 13) doPlayerRemoveItem(cid, voc.item, voc.preco) else doPlayerSendTextMessage(cid,22, "Voce nao tem " ..voc.preco.. " " ..nome.. " para ser promovido para" ..voc.vocnova.. " .") return true end else doPlayerSendTextMessage(cid,22, "Voce ja possui todas as promotions.") return true end end
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.