• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Demon OAK

login12

void newbie scripter()
Joined
Feb 26, 2011
Messages
181
Reaction score
31
Location
Brazil
When people end the quest HIM dont get kick, and dont happening nothingg
someone can help me? i need him get kick and set storages like my script. LOOK:

Code:
local config = {
    demonOakIds = {8288, 8289, 8290, 8291},
    sounds = {
        'MY ROOTS ARE SHARP AS A SCYTHE! FEEL IT?!?',
        'CURSE YOU!',
        'RISE, MINIONS, RISE FROM THE DEAD!!!!',
        'AHHHH! YOUR BLOOD MAKES ME STRONG!',
        'GET THE BONES, HELLHOUND! GET THEM!!',
        'GET THERE WHERE I CAN REACH YOU!!!',
        'ETERNAL PAIN AWAITS YOU! NICE REWARD, HUH?!?!',
        'YOU ARE GOING TO PAY FOR EACH HIT WITH DECADES OF TORTURE!!',
        'ARGG! TORTURE IT!! KILL IT SLOWLY MY MINION!!'
    },
    bonebeastChance = 90,
    bonebeastCount = 4,
    waves = 10,
    questArea = {
        fromPosition = {x = 32706, y = 32345, z = 7},
        toPosition = {x = 32725, y = 32357, z = 7}
    },
    summonPositions = {
        {x = 32714, y = 32348, z = 7},
        {x = 32712, y = 32349, z = 7},
        {x = 32711, y = 32351, z = 7},
        {x = 32713, y = 32354, z = 7},
        {x = 32716, y = 32354, z = 7},
        {x = 32719, y = 32354, z = 7},
        {x = 32721, y = 32351, z = 7},
        {x = 32719, y = 32348, z = 7}
    },
    summons = {
        [8288] = {
            [5] = {'Braindeath', 'Braindeath', 'Blightwalker', 'Bonebeast', 'Blightwalker'},
            [10] = {'Betrayed Wraith', 'Betrayed Wraith', 'Lost Soul', 'Dark Torturer'}
        },
        [8289] = {
            [5] = {'Lich', 'Lich', 'Lich', 'Dark Torturer', 'Grim Reaper'},
            [10] = {'Dark Torturer', 'Blightwalker', 'Lost Soul', 'Grim Reaper'}
        },
        [8290] = {
            [5] = {'Banshee', 'Banshee', 'Blightwalker', 'Demon', 'Grim Reaper'},
            [10] = {'Grim Reaper', 'Dark Torturer', 'Blightwalker', 'Blightwalker'}
        },
        [8291] = {
            [5] = {'Giant Spider', 'Blightwalker', 'Demon', 'Hand of Cursed Fate', 'Dark Torturer'},
            [10] = {'Undead Dragon', 'Hand of Cursed Fate', 'Demon', 'Dark Torturer'}
        }
    }
}

local function getRandomSummonPosition()
    return config.summonPositions[math.random(#config.summonPositions)]
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if not isInArray(config.demonOakIds, itemEx.itemid) then
        return true
    end

    local player = Player(cid)

    local totalProgress = 0
    for i = 1, #config.demonOakIds do
        totalProgress = totalProgress + math.max(0, player:getStorageValue(config.demonOakIds[i]))
    end

    local isDefeated = totalProgress == (#config.demonOakIds * (config.waves + 1))
    if (config.killAllBeforeCut or isDefeated)
            and isMonsterInArea(config.questArea.fromPosition, config.questArea.toPosition, true) then
        player:sendTextMessage(MESSAGE_INFO_DESCR, 'You need to kill all monsters first.')
        return true
    end

    if isDefeated then
        player:teleportTo(DEMON_OAK_KICK_POSITION)
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Tell Oldrak about your great victory against the demon oak.')
        player:setStorageValue(1010, 1)
        player:setStorageValue(1013, 3)
        player:setStorageValue(9872, 1)
        return true
    end

    local progress = math.max(player:getStorageValue(itemEx.itemid), 1)
    if progress >= config.waves + 1 then
        toPosition:sendMagicEffect(CONST_ME_POFF)
        return true
    end

    local isLastCut = totalProgress == (#config.demonOakIds * (config.waves + 1) - 1)
    local summons = config.summons[itemEx.itemid]
    if summons and summons[progress] then
        -- Summon a single demon on the last hit
        if isLastCut then
            Game.createMonster('Demon', getRandomSummonPosition(), false, true)

        -- Summon normal monsters otherwise
        else
            for i = 1, #summons[progress] do
                Game.createMonster(summons[progress][i], getRandomSummonPosition(), false, true)
            end
        end

    -- if it is not the 5th or 10th there is only a chance to summon bonebeasts
    elseif math.random(100) >= config.bonebeastChance then
        for i = 1, config.bonebeastCount do
            Game.createMonster('Bonebeast', getRandomSummonPosition(), false, true)
        end
    end

    player:say(isLastCut and 'HOW IS THAT POSSIBLE?!? MY MASTER WILL CRUSH YOU!! AHRRGGG!' or config.sounds[math.random(#config.sounds)], TALKTYPE_MONSTER_YELL, false, player, DEMON_OAK_POSITION)
    toPosition:sendMagicEffect(CONST_ME_DRAWBLOOD)
    player:setStorageValue(itemEx.itemid, progress + 1)
    player:say('-krrrrak-', TALKTYPE_MONSTER_YELL, false, player, toPosition)
    doTargetCombatHealth(0, cid, COMBAT_EARTHDAMAGE, -170, -210, CONST_ME_BIGPLANTS)
    return true
end
 
ua Script Error: [Action Interface]
data/actions/scripts/demon oak quest/demonOak.lua:onUse
data/actions/scripts/demon oak quest/demonOak.lua:69: attempt to call global 'i)
stack traceback:
[C]: in function 'isMonsterInArea'
data/actions/scripts/demon oak quest/demonOak.lua:69: in function <data>
 
need add this? in this part

if isDefeated then
player:teleportTo(DEMON_OAK_KICK_POSITION)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Tell Oldrak about your great victory against the demon oak.')
player:setStorageValue(1010, 1)
player:setStorageValue(1013, 3)
player:setStorageValue(9872, 1)
return true
end


of script dont work, i dont why and get error on console
 
I need help!

Lua Script Error: [Action Interface]
data/actions/scripts/demon oak quest/demonOak.lua:onUse
data/actions/scripts/demon oak quest/demonOak.lua:100: attempt to index local 'p
layer' (a number value)
stack traceback:
[C]: in function '__index'
data/actions/scripts/demon oak quest/demonOak.lua:100: in function <data
/actions/scripts/demon oak quest/demonOak.lua:93>
 

Similar threads

Back
Top