• 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 [1.2] lottery row

Larb

New Member
Joined
Nov 26, 2016
Messages
85
Reaction score
1
Lua:
local decayItems = {
    [1945] = 1946, [1946] = 1945
}
local slots = {

    Position(32344, 32242, 7), Position(32345, 32242, 7), Position(32346, 32242, 7), Position(32347, 32242, 7), Position(32348, 32242, 7),
}

local itemtable = {
    [1] = {id = 37466, chance = 100},
    [2] = {id = 35221, chance = 95},
    [3] = {id = 35216, chance = 95},
    [4] = {id = 35219, chance = 95},
    [5] = {id = 36911, chance = 90},
    [6] = {id = 35041, chance = 85},
    [7] = {id = 35224, chance = 80},
    [8] = {id = 37571, chance = 80},
    [9] = {id = 36426, chance = 75},
    [10] = {id = 33983, chance = 70},
    [11] = {id = 35213, chance = 68},
    [12] = {id = 37470, chance = 65},
    [13] = {id = 34727, chance = 60},
    [15] = {id = 2469, chance = 55},
    [16] = {id = 2471, chance = 53},
    [17] = {id = 2523, chance = 52},
    [18] = {id = 2495, chance = 51},
    [14] = {id = 34699, chance = 45},
    [19] = {id = 34726, chance = 43},
    [20] = {id = 28663, chance = 42},
    [21] = {id = 2798, chance = 35},
    [22] = {id = 35147, chance = 26}
   
}
local function ender(cid, position)
   
    local player = Player(cid)
    local posicaofim = Position(32346, 32242, 7)
    local item = Tile(posicaofim):getTopDownItem()
    if item then
        local itemId = item:getId()
        posicaofim:sendMagicEffect(CONST_ME_TUTORIALARROW)
        player:addItem(itemId, 1)
    end
    local alavanca = Tile(position):getTopDownItem()
    if alavanca then
        alavanca:setActionId(18562)
    end
    if itemId == 36911 or itemId == 35041 then
        broadcastMessage("O player "..player:getName().." ganhou "..item:getName().."", MESSAGE_EVENT_ADVANCE)
    else  
        -- for _, pid in ipairs(getPlayersOnline()) do
            -- if pid ~= cid then
                player:say("O player "..player:getName().." ganhou "..item:getName().."", TALKTYPE_MONSTER_SAY)
            -- end
        -- end
    end
end

local function delay(position, aux)
    local item = Tile(position):getTopDownItem()
    if item then
        local slot = aux + 1
        item:moveTo(slots[slot])
    end  
end

local function exec(cid)

    local rand = math.random(1, 100)
    local aux, memo = 0, 0
    if rand >= 1 then
        for i = 1, #itemtable do
            local randitemid = itemtable[i].id
            local randitemchance = itemtable[i].chance
            if rand >= randitemchance then
                aux = aux + 1
                memo = randitemchance
            end
           
        end
    end

    Game.createItem(itemtable[aux].id, 1, slots[1])
    slots[1]:sendMagicEffect(CONST_ME_FIREWORK_RED)
    local item = Tile(slots[#slots]):getTopDownItem()
    if item then
        item:remove()
    end

    local maxslot = #slots-1
    local lastloop = 0
    for i = 1, maxslot do
       
        addEvent(delay, 60, slots[i], i)
    end
end
function onUse(player, item, fromPosition, itemEx, toPosition)
    if not player then
        return false
    end
    if not player:removeItem(2160, 5) then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "you dont have gold")
        return false
    end
   
    local playerid = player:getGuid()
    item:transform(decayItems[item.itemid])
    item:decay()  

    item:setActionId(18563)
   
    local loopsize = 60
   
    for i = 1, loopsize do
        addEvent(exec, i*500, playerid)
    end
    addEvent(ender, 31000, playerid, fromPosition)
   
    return true
end
Lua Script Error: [Main Interface]
in a timer event called from:
(Unknown scriptfile)
data/actions/scripts/custom/lotery.lua:86: attempt to index field '?' (a nil value)
stack traceback:
[C]: in function '__index'
data/actions/scripts/custom/lotery.lua:86: in function <data/actions/scripts/custom/lotery.lua:70>
someone can help me solve this error in the script and that the prize be more difficult
TFS 1.2
 
Back
Top