• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua dice script error

viking

Member
Joined
Aug 20, 2015
Messages
323
Reaction score
22
yIVHthn.png


Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

function onCreatureAppear(cid)                npcHandler:onCreatureAppear(cid)            end
function onCreatureDisappear(cid)            npcHandler:onCreatureDisappear(cid)            end
function onCreatureSay(cid, type, msg)            npcHandler:onCreatureSay(cid, type, msg)        end
function onThink()                    npcHandler:onThink()                    end

function creatureSayCallback(cid, type, msg)
    if(not npcHandler:isFocused(cid)) then
        return false
    end

    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid


    local coins = {[2148] = 1, [2152] = 100, [2160] = 10000}

function countMoneyOnPos(pos)
local money = 0
for stack = 1, 255  do
  pos.stackpos = stack
  local item = getThingFromPos(pos)
  if item and item.uid > 0 then
   if coins[item.itemid] then
    money = money + coins[item.itemid] * item.type
   end
  end
end
return money
end



local posCoal = {x = 32000, y = 31899, z = 7} -- POSIÇÃO DO COAL, ONDE O GOLD DEVE ESTAR
local posNpc = {x = 32000, y = 31898, z = 7} -- POSIÇÃO DO NPC
local pos = getPosByDir(getThingPos(cid), Creature(cid):getDirection(), 1) -- Creature(cid):getDirection()NÃO ALTERAR

    if msgcontains(msg, 'l') or msgcontains(msg, 'L') or msgcontains(msg, 'low') or msgcontains(msg, 'Low') then
        if countMoneyOnPos(pos) > 0 then
            if math.random(1, 6) <= 3 then
            doPlayerAddMoney(cid, countMoneyOnPos(pos)*1)
                doSendMagicEffect(posNpc, 26)
                doSendMagicEffect(posNpc, 28)
                doCreatureSay(getNpcId(), getCreatureName(cid)..' tirou o numero '..math.random(1, 3)..', parabéns!', TALKTYPE_ORANGE_1)
            else
                doSendMagicEffect(posNpc, 2)
                doSendMagicEffect(posNpc, 26)
                doCreatureSay(getNpcId(), getCreatureName(cid)..' tirou o numero '..math.random(4, 6)..', tente novamente!', TALKTYPE_ORANGE_1)
            end
                            for stack = 1, 255  do
                  pos.stackpos = stack
                  local item = getThingFromPos(pos)
                  if item and item.uid > 0 then
                   if coins[item.itemid] then
                    doRemoveItem(item.uid)
                   end
                  end
                 end
        else
            doCreatureSay(getNpcId(), getCreatureName(cid)..', coloque uma quantia de gold no recipiente para começar a apostar!', TALKTYPE_ORANGE_1)
        end
    
    elseif msgcontains(msg, 'h') or msgcontains(msg, 'H') or msgcontains(msg, 'high') or msgcontains(msg, 'High') then
        if countMoneyOnPos(pos) > 0 then
            if math.random(1, 6) <= 3 then
                doPlayerAddMoney(cid, countMoneyOnPos(pos)*1)
                doSendMagicEffect(posNpc, 26)
                doSendMagicEffect(posNpc, 28)
                doCreatureSay(getNpcId(), getCreatureName(cid)..' tirou o numero '..math.random(4, 6)..', parabéns!', TALKTYPE_ORANGE_1)
            else
                doSendMagicEffect(posNpc, 2)
                doSendMagicEffect(posNpc, 26)
                doCreatureSay(getNpcId(), getCreatureName(cid)..' tirou o numero '..math.random(1, 3)..', tente novamente!', TALKTYPE_ORANGE_1)
            end
                            for stack = 1, 255  do
                  pos.stackpos = stack
                  local item = getThingFromPos(pos)
                  if item and item.uid > 0 then
                   if coins[item.itemid] then
                    doRemoveItem(item.uid)
                   end
                  end
                 end
        else
            doCreatureSay(getNpcId(), getCreatureName(cid)..', coloque uma quantia de gold no recipiente para começar a apostar!', TALKTYPE_ORANGE_1)
        end
    end
return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

local posCoal = {x = 32000, y = 31899, z = 7} -- POSIÇÃO DO COAL, ONDE O GOLD DEVE ESTAR
local posNpc = {x = 32000, y = 31898, z = 7} -- POSIÇÃO DO NPC
local pos = getPosByDir(getThingPos(cid), Creature(cid):getDirection(), 1)
 
You really need to start learning things man.. Every time i come on all i see is your avatar in the new posts section lol.

You are missing a function from your global.lua. Try searching for the function.
 
Add this function to your lib file or global.lua.
Code:
local function getPosByDir(pos, dir)
    if(dir == NORTH) then
        pos.y = pos.y-1
    elseif(dir == SOUTH) then
        pos.y = pos.y + 1
    elseif(dir == WEST) then
        pos.x = pos.x-1
    elseif(dir == EAST) then
        pos.x = pos.x+1
    end
    return pos
end

You are missing a function from your global.lua. Try searching for the function.
#6.
https://otland.net/threads/rules-for-the-support-board.217087/
 
Back
Top