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

onKill bosses TFS 1.2

president vankk

Web Developer & AuraOT Owner
Joined
Jul 10, 2009
Messages
5,719
Solutions
9
Reaction score
339
Hi everyone, the main idea of this script is when the bosses die then it should set gamestorage to 0, but isn't working, and doesn't get any error.

Code:
local config = {
  ["ferumbras"] = {storageKey = Storage.Bosses.Ferumbras, name = 'Ferumbras'},
   ["morgaroth"] = {storageKey = Storage.Bosses.Morgaroth, name = 'Morgaroth'},
   ["ghazbaran"] = {storageKey = Storage.Bosses.Ghazbaran, name = 'Ghazbaran'},
   ["orshabaal"] = {storageKey = Storage.Bosses.Orshabaal, name = 'Orshabaal'},
   ["zulazza"] = {storageKey = Storage.Bosses.Zulazza, name = 'Zulazza'}
}

function onKill(creature, target)
  local monster = config[target:getName():lower()]
  if not monster or target:isPlayer() then
  return true
  end
   
   Game.setStorageValue(monster.storageKey, 0)
   Game.broadcastMessage("Will not be allowed to enter on "..monster.name.."'s lair anymore due to even be dead.", MESSAGE_STATUS_WARNING)
  return true
end

xml
Code:
<event type="kill" name="bossesDeath" script="others/bossesDeath.lua"/>

Already registred bossesDeath in login.lua

monsters.xml
Code:
<script>
     <event name="bossesDeath"/>
   </script>

Thanks.
 
ui-DR7N.png


http://pastebin.com/pSeVpYQJ
 
Here's the fixed version:

Code:
local t = {
    ['demon'] = {
        storage = 12345
    }
}

local function firstStringToUpper(str)
    return (str:gsub("^%l", string.upper))
end

function onKill(player, target)
    local monster = target:getMonster()
    if not monster then
        return true
    end

    local k = t[monster:getName():lower()]
    if not k then
        return true
    end

    Game.setStorageValue(k.storage, 0)
    Game.broadcastMessage("You may no longer enter " .. firstStringToUpper(monster:getName()) .. "'s lair. He has been defeated.", MESSAGE_STATUS_WARNING)
    return true
end

Nice work! Happy to help. :)
 
Last edited:
Back
Top