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

boss event creature script

bum bum

zatania developer
Joined
Aug 23, 2010
Messages
24
Reaction score
1
hello otlanders i have a problem with this creaturescript of boss event the movement scripts are fine and working but when the boss die it is not respawning like the spript even not start at all thanks in advance

Lua:
local config = {
    respawnSecs = 1, -- how many seconds until next boss spawns
    storage = 70200,
    bosspos = {x=32044,y=31927,z=7},
    bossspawnstorage = 70400
}

local t = {'rotworm','Ghazbaran','Ferumbras','Orshabaal','Countess Sorrow','Massacre','Fluffy','Dracola','the plasmother','Mr. Punish','The Handmaiden'}

local function f()
    doCreateMonster(t[math.random(#t)], config.bosspos, false, true, true)
    doBroadcastMessage('A new boss has spawned in the boss arena!', MESSAGE_STATUS_CONSOLE_ORANGE)
    doSetStorage(config.bossspawnstorage, 0)
end

function onKill(cid, target, damage, flags)
    if bit.band(flags, 1) == 1 and isMonster(target) and getCreatureMaster(target) == target and getPlayerStorageValue(cid,config.storage) == 1 then
        local s = getCreatureName(target)
        if isInArray(t, s:lower()) and getStorage(config.bossspawnstorage) == 0 then
            doBroadcastMessage(getCreatureName(cid)..' has just killed the boss "'..s..'", a new boss will spawn in '..config.respawnSecs..' seconds!', MESSAGE_STATUS_CONSOLE_ORANGE)
            doSetStorage(config.bossspawnstorage,1)
            addEvent(f, config.respawnSecs*100)
        end
    end
    return true
end


bum bum
 
Last edited by a moderator:
Solution
Lua:
local config = {
    respawnSecs = 1, -- how many seconds until next boss spawns
    storage = 70200,
    bosspos = {x=32044,y=31927,z=7},
    bossspawnstorage = 70400
}

-- more clear table name rather than t
local monsters = {'Rotworm','Ghazbaran','Ferumbras','Orshabaal','Countess Sorrow','Massacre','Fluffy','Dracola','The Plasmother','Mr. Punish','The Handmaiden'}

local function respawn() -- use a more clear function name other than f
    doCreateMonster(monsters[math.random(#monsters)], config.bosspos)
    doBroadcastMessage('A new boss has spawned in the boss arena!', MESSAGE_STATUS_CONSOLE_ORANGE)
    setGlobalStorageValue(config.bossspawnstorage, 0)
end

function onKill(cid, target, damage, flags)
    if isMonster(target) and...
addEvent(f, config.respawnSecs*100) change that to
Lua:
addEvent(f, config.respawnSecs*1000)

since 100 would make it 0.1 seconds
and 1000 would make it 1 second

Edit:
local s = getCreatureName(target)
if isInArray(t, s:lower()) and getStorage(config.bossspawnstorage) == 0 then

That is also checking the boss names in lowercase and you have some uppercase names in the table t
 
Last edited:
@Mummrik did not work i have tried to change a lot of things but cant get it to work the script does not work in the onkill part i have tfs 0.4 btw and i am not so good at the lua parameters in it :)
 
@Mummrik did not work i have tried to change a lot of things but cant get it to work the script does not work in the onkill part i have tfs 0.4 btw and i am not so good at the lua parameters in it :)
does the player have storage 70200 set to 1?

also im not sure what "bit.band(flags, 1) == 1" would do, is that something you set in an other script?
 
yes the players get the storage i dont have a clue either what that flag thing does have tried to change and remove it but nothing at all :/
 
yes the players get the storage i dont have a clue either what that flag thing does have tried to change and remove it but nothing at all :/
above this line
Lua:
if bit.band(flags, 1) == 1 and isMonster(target) and getCreatureMaster(target) == target and getPlayerStorageValue(cid,config.storage) == 1 then
add this
Lua:
print(target)
and look in server consol if it prints something
 
yes it printed a number 1073789914

it come up in console if i kill a monster outside the boss room to even if i kill a rat :)

the event consist of some parts the movement script works well when i step in the tp i get teleported to the room and gets my storage and the boss spawns and when the boss dies it should spawn after 20 secs again.
 
Last edited by a moderator:
yes it printed a number 1073789914
ok great, you can remove that line again.
about the bit.band(type, n)
this is what i found about it (someone more advanced in Lua might tell you how to use it)
lua-users wiki: Bitwise Operators
link to quote: https://www.lua.org/manual/5.3/manual.html#3.4.2
3.4.2 – Bitwise Operators
Lua supports the following bitwise operators:

  • &: bitwise AND
  • |: bitwise OR
  • ~: bitwise exclusive OR
  • >>: right shift
  • <<: left shift
  • ~: unary bitwise NOT
All bitwise operations convert its operands to integers (see §3.4.3), operate on all bits of those integers, and result in an integer.

Both right and left shifts fill the vacant bits with zeros. Negative displacements shift to the other direction; displacements with absolute values equal to or higher than the number of bits in an integer result in zero (as all bits are shifted out).

so i recommend to remove it for now since it seems to turn the flag into an integer

it come up in console if i kill a monster outside the boss room to even if i kill a rat :)
Yes its called everytime you do onKill so that should be right, i just wanted to know if it was possible to use target like this for example "isMonster(target)"

Edit:
Edit2: updated the script again
Lua:
local config = {
   respawnSecs = 1, -- how many seconds until next boss spawns
   storage = 70200,
   bosspos = {x=32044,y=31927,z=7},
   bossspawnstorage = 70400
}
local t = {'Rotworm','Ghazbaran','Ferumbras','Orshabaal','Countess Sorrow','Massacre','Fluffy','Dracola','The Plasmother','Mr. Punish','The Handmaiden'}
local function f()
   doCreateMonster(t[math.random(#t)], config.bosspos)
   doBroadcastMessage('A new boss has spawned in the boss arena!', MESSAGE_STATUS_CONSOLE_ORANGE)
   setGlobalStorageValue(config.bossspawnstorage, 0)
end
function onKill(cid, target, damage, flags)
   if isMonster(target) and getCreatureMaster(target) == target and getPlayerStorageValue(cid,config.storage) == 1 then
   local s = getCreatureName(target)
       if isInArray(t, s) and getGlobalStorageValue(config.bossspawnstorage) ~= 1 then
           doBroadcastMessage(getCreatureName(cid)..' has just killed the boss "'..s..'", a new boss will spawn in '..config.respawnSecs..' seconds!', MESSAGE_STATUS_CONSOLE_ORANGE)
           setGlobalStorageValue(config.bossspawnstorage,1)
           addEvent(f, config.respawnSecs*1000)
       end
   end
   return true
end
seems like you did use wrong getstorage wrong it should be setGlobalStorageValue and getGlobalStorageValue
try if this works
 
Last edited by a moderator:
try this

Code:
local config = {
   respawnSecs = 1, -- how many seconds until next boss spawns
   storage = 70200,
   bosspos = {x=32044,y=31927,z=7},
   bossspawnstorage = 70400
}

local t = {'Rotworm','Ghazbaran','Ferumbras','Orshabaal','Countess Sorrow','Massacre','Fluffy','Dracola','The Plasmother','Mr. Punish','The Handmaiden'}

local function f()
    rand_mons = math.random(1, #t)
    doCreateMonster(t[rand_mons], config.bosspos)
    doBroadcastMessage('A new boss has spawned in the boss arena!', MESSAGE_STATUS_CONSOLE_ORANGE)
    setGlobalStorageValue(config.bossspawnstorage, 0)
end

function onKill(cid, target, damage, flags)
    if not isInArray(t, getCreatureName(target)) then
        return true
    end
   
    if getCreatureMaster(target) ~= target then
        return true
    end
   
    if getPlayerStorageValue(cid, config.storage) ~= 1 then
        return true
    end
   
    if getGlobalStorageValue(config.bossspawnstorage) == 1 then
        return true
    end
   
    doBroadcastMessage(getCreatureName(cid)..' has just killed the boss "'..s..'", a new boss will spawn in '..config.respawnSecs..' seconds!', MESSAGE_STATUS_CONSOLE_ORANGE)
    setGlobalStorageValue(config.bossspawnstorage,1)
    addEvent(f, config.respawnSecs*1000)
   return true
end
 
did not work :/ i will post all my scripts to this event

creaturescripts

Lua:
   <event type="death" name="ArenaDeath" event="script" value="arenadeath.lua"/>
<event type="kill" name="BossKill" event="script" value="bosskill.lua"/>

Code:
   registerCreatureEvent(cid, "BossKill")
    registerCreatureEvent(cid, "ArenaDeath")
doCreatureSetStorage(cid, 50300)

Lua:
function onDeath(cid)
    if getCreatureStorage(cid, 50300) == 1 then
        local n = math.max(0, getStorage(50290)-1)
        doSetStorage(50290, n)
        if n == 0 then
            doSetStorage(50310, 0)
        end
    end
    return true
end

Lua:
local config = {
   respawnSecs = 1, -- how many seconds until next boss spawns
   storage = 70200,
   bosspos = {x=32044,y=31927,z=7},
   bossspawnstorage = 70400
}
local t = {'Rotworm','Ghazbaran','Ferumbras','Orshabaal','Countess Sorrow','Massacre','Fluffy','Dracola','The Plasmother','Mr. Punish','The Handmaiden'}
local function f()
   doCreateMonster(t[math.random(#t)], config.bosspos)
   doBroadcastMessage('A new boss has spawned in the boss arena!', MESSAGE_STATUS_CONSOLE_ORANGE)
   setGlobalStorageValue(config.bossspawnstorage, 0)
end
function onKill(cid, target, damage, flags)
   if isMonster(target) and getCreatureMaster(target) == target and getPlayerStorageValue(cid,config.storage) == 1 then
   local s = getCreatureName(target)
       if isInArray(t, s) and getGlobalStorageValue(config.bossspawnstorage) ~= 1 then
           doBroadcastMessage(getCreatureName(cid)..' has just killed the boss "'..s..'", a new boss will spawn in '..config.respawnSecs..' seconds!', MESSAGE_STATUS_CONSOLE_ORANGE)
           setGlobalStorageValue(config.bossspawnstorage,1)
           addEvent(f, config.respawnSecs*1000)
       end
   end
   return true
end

moveevents

Lua:
local config = {
tppos = {x=1252,y=1038,z=7}, -- WHERE TO TELEPORT TO.
monsterpos = {x=1262,y=1045,z=7}, -- WHERE MONSTER TELEPORTS.
maxplayers = 10, -- HOW MANY PLAYERS CAN ENTER.
globalstorage = 50290,
monsterstorage = 50310,
enteredArea = 50300, -- EMPTY PLAYER STORAGE.
exhauststorage = 50340 -- EMPTY PLAYER STORAGE.
}
local monsters = {'unknown freak','Dark sorcerer','bull wolf','king kong','captain sniper','strong freak','shorty','captain freak','bull wolf','king kong'}
function onStepIn(cid,item,pos,fromPos)
    if isPlayer(cid) then
        if getPlayerLevel(cid) < 250 then
            doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,'You need to be of Level 250 or higher to enter.')
        else
            local g = math.max(0, getStorage(config.globalstorage)) + 1
            if g > config.maxplayers then
                doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,'Too many players are participating already.')
            elseif exhaustion.check(cid,config.exhauststorage) then
                doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,'You can\'t enter yet, you\'ll have to wait '..exhaustion.get(cid,config.exhauststorage)..' more seconds.')
            else
                doSetStorage(config.globalstorage, g)
                doCreatureSetStorage(cid,config.enteredArea,1)
                doTeleportThing(cid,config.tppos)
                doSendMagicEffect(config.tppos, CONST_ME_TELEPORT)
                doSendMagicEffect(pos,CONST_ME_POFF)
                if getStorage(config.monsterstorage) < 1 then
                    doCreateMonster(monsters[math.random(#monsters)],config.monsterpos)
                    doSendMagicEffect(config.monsterpos,CONST_ME_TELEPORT)
                    doSetStorage(config.monsterstorage,1)
                end
                return
            end
        end
        doTeleportThing(cid, {x=1000, y=1000, z=7})
        doSendMagicEffect({x=1000, y=1000, z=7}, CONST_ME_TELEPORT)
    end
end
function onAddItem(moveitem, tileitem, pos)
    pos.x = pos.x + 3
    doTeleportThing(moveitem.uid, pos)
    doSendMagicEffect(pos, 12)
end

Lua:
local config = {
tppos = {x=1000,y=1000,z=7}, -- WHERE TO TELEPORT TO. (SHOULD BE CENTER OF THE ROOM)
maxplayers = 10, -- HOW MANY PLAYERS CAN ENTER.
globalstorage = 50290,
monsterstorage = 50310,
enteredArea = 50300,
from = {x=1246, y=1032, z=7}, -- AREA UPPERLEFT CORNER.
to = {x=1278, y=1057, z=7}, -- AREA LOWERRIGHT CORNER.
bossspawnstorage = 50320,
exhausttimer = 5, -- EXHAUSTION IN MINUTES.
exhauststorage = 50340
}
local from, to = config.from, config.to
function onStepIn(cid,item,pos,fromPos)
    local v = getThingPos(cid)
    if isPlayer(cid) then
        if getStorage(config.bossspawnstorage) > 0 then
            doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,'Please wait until the next boss is spawned before leaving.')
            doTeleportThing(cid, fromPos, true)
            return true
        end
        exhaustion.set(cid,config.exhauststorage,config.exhausttimer*60)
        local s = math.max(0, getStorage(config.globalstorage) - 1)
        doSetStorage(config.globalstorage, s)
        doBroadcastMessage('['..s..'/'..config.maxplayers..'] people are in boss event now!', MESSAGE_STATUS_CONSOLE_RED)
        doTeleportThing(cid,config.tppos)
        doSendMagicEffect(pos,CONST_ME_POFF)
        doSendMagicEffect(config.tppos,CONST_ME_TELEPORT)
        doCreatureSetStorage(cid,config.enteredArea)
        if s == 0 then
            doSetStorage(config.monsterstorage,0)
            for x = from.x, to.x do
                for y = from.y, to.y do
                    local v = getTopCreature({x=x, y=y, z=from.z})
                    if v.type == 2 then
                        doRemoveCreature(v.uid)
                    end
                end
            end
        end
    end
    return true
end
 
Use this and post a pic of your console after you kill the boss...

Code:
local config = {
   respawnSecs = 1, -- how many seconds until next boss spawns
   storage = 70200,
   bosspos = {x=32044,y=31927,z=7},
   bossspawnstorage = 70400
}

local t = {'Rotworm','Ghazbaran','Ferumbras','Orshabaal','Countess Sorrow','Massacre','Fluffy','Dracola','The Plasmother','Mr. Punish','The Handmaiden'}

local function f()
    rand_mons = math.random(1, #t)
    doCreateMonster(t[rand_mons], config.bosspos)
    doBroadcastMessage('A new boss has spawned in the boss arena!', MESSAGE_STATUS_CONSOLE_ORANGE)
    setGlobalStorageValue(config.bossspawnstorage, 0)
end

function onKill(cid, target, damage, flags)
    if not isInArray(t, getCreatureName(target)) then
        return true
    end
   print("step 1")
    if getCreatureMaster(target) ~= target then
        return true
    end
   print("step 2")
    if getPlayerStorageValue(cid, config.storage) ~= 1 then
        return true
    end
   print("step 3")
    if getGlobalStorageValue(config.bossspawnstorage) == 1 then
        return true
    end
   print("step 4")
    doBroadcastMessage(getCreatureName(cid)..' has just killed the boss "'..s..'", a new boss will spawn in '..config.respawnSecs..' seconds!', MESSAGE_STATUS_CONSOLE_ORANGE)
    setGlobalStorageValue(config.bossspawnstorage,1)
    addEvent(f, config.respawnSecs*1000)
   return true
end
 
Lua:
local config = {
    respawnSecs = 1, -- how many seconds until next boss spawns
    storage = 70200,
    bosspos = {x=32044,y=31927,z=7},
    bossspawnstorage = 70400
}

-- more clear table name rather than t
local monsters = {'Rotworm','Ghazbaran','Ferumbras','Orshabaal','Countess Sorrow','Massacre','Fluffy','Dracola','The Plasmother','Mr. Punish','The Handmaiden'}

local function respawn() -- use a more clear function name other than f
    doCreateMonster(monsters[math.random(#monsters)], config.bosspos)
    doBroadcastMessage('A new boss has spawned in the boss arena!', MESSAGE_STATUS_CONSOLE_ORANGE)
    setGlobalStorageValue(config.bossspawnstorage, 0)
end

function onKill(cid, target, damage, flags)
    if isMonster(target) and getPlayerStorageValue(cid, config.storage) == 1 then
        local targetName = getCreatureName(target)
        local playerName = getCreatureName(cid)
        if isInArray(monsters, targetName) and getGlobalStorageValue(config.bossspawnstorage) ~= 1 then
            local message = ("%s has just killed the boss %s, a new boss will spawn in %d seconds!"):format(playerName, targetName, config.respawnSecs)
            doBroadcastMessage(message, MESSAGE_STATUS_CONSOLE_ORANGE)
            setGlobalStorageValue(config.bossspawnstorage, 1)
            addEvent(respawn, config.respawnSecs * 1000)
        end
    end
    return true
end
 
Solution
Back
Top