Postado Abril 29, 2018 7 anos Gente eu andei estudando bastante sobre lua, e estou aprendendo aos poucos ! Porem eu estava tentando fazer uma coisa e acabei de n conseguindo, coisa simples... local items = { [1] = 2293, -- item id [2] = 2294, } function onUse(cid, item, fromPosition, itemEx, toPosition) if item:getId() == 1945 then item:transform(1946) elseif item:getId() == 1946 then cid:getPosition():sendMagicEffect(CONST_ME_POFF) item:transform(1945) end if cid:getMoney() >= 100 then cid:removeMoney(100) if math.random(1, 100) > 50 then cid:addItem(items[math.random(1, #items)], 1) Game.broadcastMessage("O jogador '"..cid:getName().."' Acabou de ganhar um.", MESSAGE_STATUS_WARNING) else cid:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You Lose") end else cid:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You don't have a money.") end return true end Gostaria de apenas pegar esse: Game.broadcastMessage("O jogador '"..cid:getName().."' Acabou de ganhar um ", MESSAGE_STATUS_WARNING) E colocar como resultado o item tipo: Game.broadcastMessage("O jogador '"..cid:getName().."' Acabou de ganhar um : "..item:getName()..".", MESSAGE_STATUS_WARNING) Porem esse ai ele retorna o item no qual estou clicando (no caso uma lever) Oque eu devo fazer para retornar o nome do item que o jogador ganhou na tabela items?TFS 1.3 Editado Abril 29, 2018 7 anos por tataboy67 (veja o histórico de edições) Meus trabalhos: [Movements] TFS 1.1+ Area Hardcore [Movements] TFS 1.1+ Tile Party [Action] TFS 1.1+ Bau diário [Action] TFS 1.1+ Guild Dungeon Lever [Talkactions] TFS 0.3.6 / 0.4 Quest Hunt por Tempo Contato: Discord: Tataboy67#4934
Postado Abril 29, 2018 7 anos Solução Eai mano blz, ve se é isso que você precisa: local items = { [1] = {2160,'Crystal Coin'}, -- item id [2] = {2390,'Magic LongSword'}, } function onUse(cid, item, fromPosition, target, toPosition, isHotkey) if item:getId() == 1945 then item:transform(1946) elseif item:getId() == 1946 then cid:getPosition():sendMagicEffect(CONST_ME_POFF) item:transform(1945) end if cid:removeMoney(100) then if math.random(1, 100) > 50 then local randItem = math.random(1, #items) cid:addItem( items[randItem][1],1) Game.broadcastMessage("O jogador '"..cid:getName().."' Acabou de ganhar um : "..items[randItem][2]..".", MESSAGE_STATUS_WARNING) else cid:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You Lose") end else cid:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You don't have a money.") end return true end
Postado Abril 29, 2018 7 anos local items = { [1] = 2293, -- item id [2] = 2294, } function onUse(player, item, fromPosition, target, toPosition, isHotkey) if item:getId() == 1945 then if not player:removeMoney(100) then player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You don't have a money.") return true end if math.random(1, 100) > 50 then local item = items[math.random(1, #items)] player:addItem(item, 1) Game.broadcastMessage("O jogador '"..player:getName().."' Acabou de ganhar um : "..item:getName()..".", MESSAGE_STATUS_WARNING) else player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You Lose") end item:transform(1946) player:getPosition():sendMagicEffect(CONST_ME_POFF) elseif item:getId() == 1946 then item:transform(1945) end return true end
Postado Abril 29, 2018 7 anos Autor . Editado Abril 29, 2018 7 anos por tataboy67 (veja o histórico de edições) Meus trabalhos: [Movements] TFS 1.1+ Area Hardcore [Movements] TFS 1.1+ Tile Party [Action] TFS 1.1+ Bau diário [Action] TFS 1.1+ Guild Dungeon Lever [Talkactions] TFS 0.3.6 / 0.4 Quest Hunt por Tempo Contato: Discord: Tataboy67#4934
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.