Ir para conteúdo

Featured Replies

Postado

Boa Tarde Galerinha do Tk 

estou com um evento dice aki no meu servidor mas esta dando erro, 

nao sei se e porque configurei errado mas ele nao teleporta o player devolta pro templo nem da para ir novamente

 

 

local talkState = {}
local focus, old_focus = 0, 0 
local dice_pos = {x=1224,y=1166,z=7,stackpos=255}
local player_pos = {x=1223,y=1168,z=7}
local nme = "Dice"

function msgcontains(txt, str) 
    return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)')) 
end 
 
function onCreatureSay(cid, type, msg) 
    local msg = string.lower(msg) 
    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid 

    local function rollDice(cid,ammount)
        local value = math.random(5792, 5797)

        local item = getThingFromPos(dice_pos)
        if item and item.uid and item.uid > 0 and item.itemid >= 5792 and item.itemid <= 5797 then

            doTransformItem(item.uid, value)

        end
        doSendMagicEffect(dice_pos, CONST_ME_CRAPS)
        local rolled = value - 5791
        doCreatureSay(getNpcId(), getCreatureName(getNpcId()) .. ' rolled a ' .. rolled .. '.', TALKTYPE_ORANGE_1)
        if rolled == ammount then
            local backpack = doCreateItemEx(10521)
               doAddContainerItem(backpack,12575,3)
               doAddContainerItem(backpack,12396,3)
               doAddContainerItem(backpack,7440,1)
               doAddContainerItem(backpack,12733,1)
               doPlayerAddItemEx(cid,backpack)
               doSendMagicEffect(getThingPos(cid),29)
               doCreatureSay(cid,gm(cid,nme,1),TALKTYPE_ORANGE_1)
           else
               doCreatureSay(cid,gm(cid,nme,2),TALKTYPE_ORANGE_1)
               doSendMagicEffect(getThingPos(cid),CONST_ME_POFF)
           end
           addEvent(function()
               doPlayerSetStorageValue(cid,722522,-1)
               doTeleportThing(cid,{x=154,y=50,z=7})
           end,2000)
    end

 
    if isInArray({1,2,3,4,5,6},tonumber(msg)) and focus == cid then
        local storage = getPlayerStorageValue(cid,722522)
        if storage == -1 then
            doPlayerSetStorageValue(cid,722522,1)
            rollDice(cid,tonumber(msg))
        end
    end 
end

function onThink()

    local player = getTopCreature(player_pos)
    if player and player.uid and player.uid > 0 and isPlayer(player.uid) then
        if focus ~= player.uid then
            focus = player.uid
            selfSay(gm(cid,nme,3).." "..getCreatureName(player.uid)..".")
            addEvent(function()
                if isPlayer(player.uid) then
                    doSendMagicEffect(getThingPos(player.uid),CONST_ME_POFF)
                    doPlayerSetStorageValue(player.uid,722522.-1)
                    doTeleportThing(player.uid,{x=154,y=50,z=7})
                end
            end,10000)
        end
    end
end

 

olha o erro quando falo com o npc 

 

[Error - NpcScript Interface]
data/npc/scripts/killuaDiceEvent.lua:onThink
Description:
data/npc/scripts/killuaDiceEvent.lua:62: attempt to call global 'gm' (a nil value)
stack traceback:
        data/npc/scripts/killuaDiceEvent.lua:62: in function <data/npc/scripts/killuaDiceEvent.lua:56>

 

 

 

  • Respostas 5
  • Visualizações 1.4k
  • Created
  • Última resposta

Top Posters In This Topic

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.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Conteúdo Similar

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo