• 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!

Summon Boss with onthink

igorlabanca

New Member
Joined
Aug 15, 2010
Messages
36
Reaction score
3
In the script below, he checks if he has any monster with that name, in case he does not have him summon the monster, in case he does not summon and does nothing.

Lua:
local shit = {
    {boss = "Smaug", pos = {x=1397, y=375, z=2}},
    {boss = "laracna", pos = {x=980, y=866, z=12}},
    {boss = "son of ancalagon", pos = {x=955, y=369, z=8}},
    {boss = "son of ancalagon", pos = {x=1651, y=615, z=12}},
    {boss = "Wormageddon", pos = {x=331, y=390, z=8}},
    {boss = "olog-hai", pos = {x=1664, y=1141, z=8}},
    {boss = "olog-hai", pos = {x=507, y=835, z=10}},
    {boss = "scatha", pos = {x=1394, y=210, z=9}},
    {boss = "valaraukar", pos = {x=554, y=295, z=1}},
    {boss = "valaraukar", pos = {x=332, y=508, z=4}},
    {boss = "ferumbras", pos = {x=1865, y=811, z=0}},
    {boss = "jormungand", pos = {x=616, y=518, z=9}},
    {boss = "adramelech", pos = {x=1659, y=517, z=11}},
    {boss = "ancalagon", pos = {x=1630, y=851, z=14}},
    {boss = "smaug", pos = {x=1397, y=375, z=2}},
    {boss = "eddie", pos = {x=1636, y=458, z=11}},
    {boss = "the necromancer", pos = {x=557, y=315, z=0}},
    {boss = "baalrog", pos = {x=553, y=761, z=9}},
    {boss = "emelianenko", pos = {x=1206, y=766, z=11}},
    {boss = "khel thuzad", pos = {x=1788, y=453, z=15}},
    {boss = "ungoliant", pos = {x=1790, y=374, z=6}},
    {boss = "saruman", pos = {x=959, y=983, z=1}},
    {boss = "cerberus", pos = {x=1779, y=355, z=12}},
    {boss = "scatha", pos = {x=1104, y=1183, z=0}},
    {boss = "azaka", pos = {x=537, y=196, z=6}},
    {boss = "Melkors Summon", pos = {x=1540, y=94, z=13}},
    {boss = "Avari Leader", pos = {x=978, y=1341, z=8}},
    {boss = "Azazel", pos = {x=374, y=182, z=9}},
    {boss = "The Necromancer", pos = {x=337, y=706, z=1}},
    {boss = "Wormageddon", pos = {x=274, y=832, z=9}},
    {boss = "Melkors Summon", pos = {x=309, y=846, z=9}},
    {boss = "Lord of The Elements", pos = {x=127, y=818, z=13}},
    {boss = "deathstrike", pos = {x=1431, y=484, z=9}},
    {boss = "Obujos", pos = {x=651, y=1153, z=13}},
    {boss = "Jaul", pos = {x=775, y=1162, z=13}},
    {boss = "Gaz'haragoth", pos = {x=319, y=1179, z=5}},
    {boss = "Evancing", pos = {x=777, y=1514, z=12}},
    {boss = "Glooth Fairy", pos = {x=535, y=1491, z=7}},
    {boss = "Zamulosh", pos = {x=1848, y=352, z=13}},
    {boss = "Gaz'haragoth", pos = {x=319, y=1180, z=5}},
    {boss = "Sauron", pos = {x=1630, y=1142, z=8}}
}

function onThink(cid, interval)
    local random = math.random(1, #shit)
    if not getCreatureName(shit[random].boss) then
        doSummonCreature(shit[random].boss, shit[random].pos)
    end
    return true
end

I need to change this script as follows:

If you have a monster on the map with that name, it looks for another monster that is not already on the map and summon it.
 
This is a pretty horrid solution and it i didn't test it... but it should do what you want..

Code:
function onThink(cid, interval)
    local bosses = {}
    for i = 1, #shit do
        if not getCreatureName(shit[i].boss:lower()) then
            bosses[i] = shit[i]
        end
    end
   
    if not bosses[1] then
        print('All bosses are spawned')
        return false
    end
   
    local random = math.random(1, #bosses)
    doSummonCreature(bosses[random].boss, bosses[random].pos)
end
 
@strutZ


It works however whenever a boss is summoned this message appears in the console:
Lua:
[Error - GlobalEvents :: think] Failed to execute event: Bosses Respawn

and sometimes this message appears
Lua:
Moon Script Error: [GlobalEvent Interface]
data / globalevents / scripts / bosses.lua: onThink
data / globalevents / scripts / bosses.lua: 29: attempt to index a nil value
stack traceback:
        [C]: in function '__index'
        data / globalevents / scripts / bosses.lua: 29: in function <data / globalevents / scripts / bosses.lua: 15


Thanks
 
Back
Top