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

TFS 0.X Monster of the day 0.4

newby

Active Member
Joined
Jun 11, 2016
Messages
183
Reaction score
43
How to when opens the server
random("rat", "spider", "troll", "orc", "minotaur", "dwarf", "elf", "skeleton", "amazon", "valkirie", "dark apprentice", "ghoul", "cyclops", "dwarf guard", "necromancer", "vampire", "werewolf", "dragon", "dragon lord", "wyrm", "giant spider", "hydra", "warlock", "demon") to make the monster of the day

When players login shows the monster of day

And when kill the monster of the day give 50% more exp

bump

bump

bump

bump

bump

bump

bump

bump

bump

bump
 
Solution
Wrote a little snippet.
Note: this is not a fully working code, but might help you find a workaround.
data/global.lua:
Lua:
BOOSTED_MONSTER = 56404
boostedMonstersList = {"rat", "spider", "troll", "orc", "minotaur", "dwarf", "elf", "skeleton", "amazon", "valkirie", "dark apprentice", "ghoul", "cyclops", "dwarf guard", "necromancer", "vampire", "werewolf", "dragon", "dragon lord", "wyrm", "giant spider", "hydra", "warlock", "demon"}

data/globalevents/scripts/init.lua
Add this anywhere below function onStartup():
Lua:
local randomMonster = math.random(#boostedMonsterList)
setGlobalStorageValue(BOOSTED_MONSTER, randomMonster)
print("Today's boosted monster is: " .. boostedMonsterList[randomMonster])

New file...
Wrote a little snippet.
Note: this is not a fully working code, but might help you find a workaround.
data/global.lua:
Lua:
BOOSTED_MONSTER = 56404
boostedMonstersList = {"rat", "spider", "troll", "orc", "minotaur", "dwarf", "elf", "skeleton", "amazon", "valkirie", "dark apprentice", "ghoul", "cyclops", "dwarf guard", "necromancer", "vampire", "werewolf", "dragon", "dragon lord", "wyrm", "giant spider", "hydra", "warlock", "demon"}

data/globalevents/scripts/init.lua
Add this anywhere below function onStartup():
Lua:
local randomMonster = math.random(#boostedMonsterList)
setGlobalStorageValue(BOOSTED_MONSTER, randomMonster)
print("Today's boosted monster is: " .. boostedMonsterList[randomMonster])

New file:
data/creaturescripts/scripts/boostedMonster.lua

Lua:
local experienceBonus = 0.3 -- this means: 30% more experience

function onKill(cid, target, damage, flags)
  local master = getCreatureMaster(target)
  if (master and master ~= target) then
    return true
  end
  local boostedMonster = monsters[getGlobalStorageValue(BOOSTED_MONSTER)]
  if getCreatureName(target):lower() == boostedMonster then
    local bonusExperience = getMonsterInfo(getCreatureName(target)).experience * getPlayerRates(cid)[SKILL__LEVEL] * experienceBonus
    doPlayerAddExperience(cid, bonusExperience)
    print("[BOOSTED MONSTER]: " .. boostedMonster)
  end
  return true
end

Not tested.
 
Solution
Wrote a little snippet.
Note: this is not a fully working code, but might help you find a workaround.
data/global.lua:
Lua:
BOOSTED_MONSTER = 56404
boostedMonstersList = {"rat", "spider", "troll", "orc", "minotaur", "dwarf", "elf", "skeleton", "amazon", "valkirie", "dark apprentice", "ghoul", "cyclops", "dwarf guard", "necromancer", "vampire", "werewolf", "dragon", "dragon lord", "wyrm", "giant spider", "hydra", "warlock", "demon"}

data/globalevents/scripts/init.lua
Add this anywhere below function onStartup():
Lua:
local randomMonster = math.random(#boostedMonsterList)
setGlobalStorageValue(BOOSTED_MONSTER, randomMonster)
print("Today's boosted monster is: " .. boostedMonsterList[randomMonster])

New file:
data/creaturescripts/scripts/boostedMonster.lua

Lua:
local experienceBonus = 0.3 -- this means: 30% more experience

function onKill(cid, target, damage, flags)
  local master = getCreatureMaster(target)
  if (master and master ~= target) then
    return true
  end
  local boostedMonster = monsters[getGlobalStorageValue(BOOSTED_MONSTER)]
  if getCreatureName(target):lower() == boostedMonster then
    local bonusExperience = getMonsterInfo(getCreatureName(target)).experience * getPlayerRates(cid)[SKILL__LEVEL] * experienceBonus
    doPlayerAddExperience(cid, bonusExperience)
    print("[BOOSTED MONSTER]: " .. boostedMonster)
  end
  return true
end

Not tested.

Code:
local config = {
    creationTime = 7 * 86400,
    checkTime = 7 * 86400,
    viceCount = 4,
    memberCount = 10
}

function onStartup()
    local data, time, result = {}, os.time(), db.getResult("SELECT `id`, `ownerid`, `creationdata`, `checkdata` FROM `guilds` WHERE `world_id` = " .. getConfigValue('worldId') .. ";")
    if(result:getID() ~= -1) then
        repeat
            data[result:getDataInt("id")] = {result:getDataInt("ownerid"), result:getDataInt("creationdata"), result:getDataInt("checkdata")}
        until not(result:next())
        result:free()
    end

    for id, v in ipairs(data) do
        local owner, created, check = v[1], v[2], v[3]
        if(created < (time - config.creationTime)) then
            result = db.getResult("SELECT `id`, `level` FROM `guild_ranks` WHERE `guild_id` = " .. id .. ";")
            if(result:getID() ~= -1) then
                local rank, ranks = 0, {}
                repeat
                    ranks[result:getDataInt("id")] = result:getDataInt("level")
                    if(result:getDataInt("level") == 1) then
                        rank = result:getDataInt("id")
                    end
                until not(result:next())
                result:free()

                local members = {0, 0, 0, 0}
                for k, v in ipairs(ranks) do
                    result = db.getResult("SELECT COUNT(`id`) AS `count` FROM `players` WHERE `rank_id` = " .. k .. ";")
                    if(result:getID() ~= -1) then
                        members[v] = members[v] + result:getDataInt("count")
                        result:free()
                    end

                    if(v == 2) then
                        result = db.getResult("SELECT `p`.`id` FROM `players` p LEFT JOIN `accounts` a ON `p`.`account_id` = `a`.`id` WHERE `p`.`rank_id` = " .. k .. " AND (`a`.`premdays` = 0 OR (`a`.`lastday` + (`a`.`premdays` * 86400) <= 0));")
                        if(result:getID() ~= -1) then
                            local demote = ""
                            repeat
                                demote = demote .. result:getDataInt("id") .. ","
                                members[2] = members[2] - 1
                                members[1] = members[1] + 1
                            until not(result:next())
                            result:free()

                            if(demote ~= "" and rank ~= 0) then
                                db.executeQuery("UPDATE `players` SET `rank_id` = " .. rank .. " WHERE `id` IN (" .. demote:sub(1, -2) .. ");")
                            end
                        end
                    end
                end

                for i = 1, 3 do
                    members[4] = members[4] + members[i]
                end

                if(members[2] < config.viceCount or members[4] < config.memberCount) then
                    if(check == 0) then
                        db.executeQuery("UPDATE `guilds` SET `checkdata` = " .. (time + config.checkTime) .. " WHERE `id` = " .. id .. ";")
                    elseif(check < time) then
                        local tmp = ""
                        for rank, _ in ipairs(ranks) do
                            tmp = tmp .. rank .. ","
                        end

                        db.executeQuery("UPDATE `players` SET `rank_id` = 0, `guildnick` = '', `guildjoin` = 0 WHERE `rank_id` IN (" .. tmp:sub(1, -2) .. ");")
                        db.executeQuery("DELETE FROM `guilds` WHERE `id` = " .. id .. ";")
                    end
                end
            end
        end
    end

    -- monster of the day
    local randomMonster = math.random(#boostedMonsterList)
    setGlobalStorageValue(BOOSTED_MONSTER, randomMonster)
    print("Today's boosted monster is: " .. boostedMonsterList[randomMonster])

    db.executeQuery("UPDATE `players` SET `online` = 0 WHERE `world_id` = " .. getConfigValue('worldId') .. " AND `online` > 0;")
    return true
end

function onGlobalSave()
    if(getGameState() ~= GAMESTATE_CLOSING) then
        return onStartup()
    end

    return true
end

Code:
[15:43:02.899] [Error - GlobalEvent Interface] 
[15:43:02.899] data/globalevents/scripts/init.lua:onStartup
[15:43:02.899] Description: 
[15:43:02.899] data/globalevents/scripts/init.lua:79: attempt to get length of global 'boostedMonsterList' (a nil value)
[15:43:02.899] stack traceback:
[15:43:02.899]     data/globalevents/scripts/init.lua:79: in function <data/globalevents/scripts/init.lua:8>
 
Code:
local config = {
    creationTime = 7 * 86400,
    checkTime = 7 * 86400,
    viceCount = 4,
    memberCount = 10
}

function onStartup()
    local data, time, result = {}, os.time(), db.getResult("SELECT `id`, `ownerid`, `creationdata`, `checkdata` FROM `guilds` WHERE `world_id` = " .. getConfigValue('worldId') .. ";")
    if(result:getID() ~= -1) then
        repeat
            data[result:getDataInt("id")] = {result:getDataInt("ownerid"), result:getDataInt("creationdata"), result:getDataInt("checkdata")}
        until not(result:next())
        result:free()
    end

    for id, v in ipairs(data) do
        local owner, created, check = v[1], v[2], v[3]
        if(created < (time - config.creationTime)) then
            result = db.getResult("SELECT `id`, `level` FROM `guild_ranks` WHERE `guild_id` = " .. id .. ";")
            if(result:getID() ~= -1) then
                local rank, ranks = 0, {}
                repeat
                    ranks[result:getDataInt("id")] = result:getDataInt("level")
                    if(result:getDataInt("level") == 1) then
                        rank = result:getDataInt("id")
                    end
                until not(result:next())
                result:free()

                local members = {0, 0, 0, 0}
                for k, v in ipairs(ranks) do
                    result = db.getResult("SELECT COUNT(`id`) AS `count` FROM `players` WHERE `rank_id` = " .. k .. ";")
                    if(result:getID() ~= -1) then
                        members[v] = members[v] + result:getDataInt("count")
                        result:free()
                    end

                    if(v == 2) then
                        result = db.getResult("SELECT `p`.`id` FROM `players` p LEFT JOIN `accounts` a ON `p`.`account_id` = `a`.`id` WHERE `p`.`rank_id` = " .. k .. " AND (`a`.`premdays` = 0 OR (`a`.`lastday` + (`a`.`premdays` * 86400) <= 0));")
                        if(result:getID() ~= -1) then
                            local demote = ""
                            repeat
                                demote = demote .. result:getDataInt("id") .. ","
                                members[2] = members[2] - 1
                                members[1] = members[1] + 1
                            until not(result:next())
                            result:free()

                            if(demote ~= "" and rank ~= 0) then
                                db.executeQuery("UPDATE `players` SET `rank_id` = " .. rank .. " WHERE `id` IN (" .. demote:sub(1, -2) .. ");")
                            end
                        end
                    end
                end

                for i = 1, 3 do
                    members[4] = members[4] + members[i]
                end

                if(members[2] < config.viceCount or members[4] < config.memberCount) then
                    if(check == 0) then
                        db.executeQuery("UPDATE `guilds` SET `checkdata` = " .. (time + config.checkTime) .. " WHERE `id` = " .. id .. ";")
                    elseif(check < time) then
                        local tmp = ""
                        for rank, _ in ipairs(ranks) do
                            tmp = tmp .. rank .. ","
                        end

                        db.executeQuery("UPDATE `players` SET `rank_id` = 0, `guildnick` = '', `guildjoin` = 0 WHERE `rank_id` IN (" .. tmp:sub(1, -2) .. ");")
                        db.executeQuery("DELETE FROM `guilds` WHERE `id` = " .. id .. ";")
                    end
                end
            end
        end
    end

    -- monster of the day
    local randomMonster = math.random(#boostedMonsterList)
    setGlobalStorageValue(BOOSTED_MONSTER, randomMonster)
    print("Today's boosted monster is: " .. boostedMonsterList[randomMonster])

    db.executeQuery("UPDATE `players` SET `online` = 0 WHERE `world_id` = " .. getConfigValue('worldId') .. " AND `online` > 0;")
    return true
end

function onGlobalSave()
    if(getGameState() ~= GAMESTATE_CLOSING) then
        return onStartup()
    end

    return true
end

Code:
[15:43:02.899] [Error - GlobalEvent Interface]
[15:43:02.899] data/globalevents/scripts/init.lua:onStartup
[15:43:02.899] Description:
[15:43:02.899] data/globalevents/scripts/init.lua:79: attempt to get length of global 'boostedMonsterList' (a nil value)
[15:43:02.899] stack traceback:
[15:43:02.899]     data/globalevents/scripts/init.lua:79: in function <data/globalevents/scripts/init.lua:8>

bump
 
Like i remember in tfs 0.4 and 0.3.6 you cannot use global.lua or lib for globalevent. You have to write boostedMonstersList to startup function.
Just.. open your onStartup script and do something like this:

Code:
local config = {
    creationTime = 7 * 86400,
    checkTime = 7 * 86400,
    viceCount = 4,
    memberCount = 10
}
local boostedMonstersList = {"rat", "spider", "troll", "orc", "minotaur", "dwarf", "elf", "skeleton", "amazon", "valkirie", "dark apprentice", "ghoul", "cyclops", "dwarf guard", "necromancer", "vampire", "werewolf", "dragon", "dragon lord", "wyrm", "giant spider", "hydra", "warlock", "demon"}

function onStartup()
[...]
it should work, but remember that with this you have two place to edit.
 
There is no global.lua in my 0.4


That was exactly what i made

/lib/monster_of_day.lua
Code:
-- [lib]
-- /lib/monster_of_day.lua

-- [globalevents]
-- <globalevent name="monster_of_day" type="startup" event="script" value="monsteroftheday_oninit.lua"/>

-- [creature]
-- <event type="kill" name="monsteroftheday_onkill" event="script" value="monsteroftheday_onkill.lua"/>
-- [login.lua]
-- registerCreatureEvent(cid, "monsteroftheday_onkill")

BOOSTED_MONSTER = 56404
boostedMonstersList = {"rat", "spider", "troll", "orc", "minotaur", "dwarf", "elf", "skeleton", "amazon", "valkirie", "dark apprentice", "ghoul", "cyclops", "dwarf guard", "necromancer", "vampire", "werewolf", "dragon", "dragon lord", "wyrm", "giant spider", "hydra", "warlock", "demon"}


monsteroftheday_onkill.lua

Code:
local experienceBonus = 0.3 -- this means: 30% more experience


function onKill(cid, target, damage, flags)

  local master = getCreatureMaster(target)

  if (master and master ~= target) then

    return true

  end

  local boostedMonster = monsters[getGlobalStorageValue(BOOSTED_MONSTER)]

  if getCreatureName(target):lower() == boostedMonster then

    local bonusExperience = getMonsterInfo(getCreatureName(target)).experience * getPlayerRates(cid)[SKILL__LEVEL] * experienceBonus

    doPlayerAddExperience(cid, bonusExperience)

    print("[BOOSTED MONSTER]: " .. boostedMonster)

  end

  return true

end



Code:
function onStartup()

    -- monster of the day

    local randomMonster = math.random(#boostedMonsterList)

    setGlobalStorageValue(BOOSTED_MONSTER, randomMonster)

    print("Today's boosted monster is: " .. boostedMonsterList[randomMonster])

end



recive this errors
Code:
[14:0:52.853] [Error - GlobalEvent Interface]
[14:0:52.853] data/globalevents/scripts/monsteroftheday_oninit.lua:onStartup
[14:0:52.854] Description:
[14:0:52.854] data/globalevents/scripts/monsteroftheday_oninit.lua:3: attempt to get length of global 'boostedMonsterList' (a nil value)
[14:0:52.854] stack traceback:
[14:0:52.854]     data/globalevents/scripts/monsteroftheday_oninit.lua:3: in function <data/globalevents/scripts/monsteroftheday_oninit.lua:1>
 
Just copy the entire array on each of the file like this:
Lua:
local BOOSTED_MONSTER = 56404
local boostedMonsterList = {"rat", "spider", "troll", "orc", "minotaur", "dwarf", "elf", "skeleton", "amazon", "valkirie", "dark apprentice", "ghoul", "cyclops", "dwarf guard", "necromancer", "vampire", "werewolf", "dragon", "dragon lord", "wyrm", "giant spider", "hydra", "warlock", "demon"}

function onStartup()
    -- monster of the day
    local randomMonster = math.random(#boostedMonsterList)
    setGlobalStorageValue(BOOSTED_MONSTER, randomMonster)
    print("Today's boosted monster is: " .. boostedMonsterList[randomMonster])
end

Lua:
local BOOSTED_MONSTER = 56404
local boostedMonsterList = {"rat", "spider", "troll", "orc", "minotaur", "dwarf", "elf", "skeleton", "amazon", "valkirie", "dark apprentice", "ghoul", "cyclops", "dwarf guard", "necromancer", "vampire", "werewolf", "dragon", "dragon lord", "wyrm", "giant spider", "hydra", "warlock", "demon"}
local experienceBonus = 0.3 -- this means: 30% more experience

function onKill(cid, target, damage, flags)
  local master = getCreatureMaster(target)
  if (master and master ~= target) then
    return true
  end
  local boostedMonster = boostedMonsterList[getGlobalStorageValue(BOOSTED_MONSTER)]
  if getCreatureName(target):lower() == boostedMonster then
    local bonusExperience = getMonsterInfo(getCreatureName(target)).experience * getPlayerRates(cid)[SKILL__LEVEL] * experienceBonus
    doPlayerAddExperience(cid, bonusExperience)
    print("[BOOSTED MONSTER]: " .. boostedMonster)
  end
  return true
end
 
Last edited:
Just copy the entire array on each of the file like this:
Lua:
local BOOSTED_MONSTER = 56404
local boostedMonstersList = {"rat", "spider", "troll", "orc", "minotaur", "dwarf", "elf", "skeleton", "amazon", "valkirie", "dark apprentice", "ghoul", "cyclops", "dwarf guard", "necromancer", "vampire", "werewolf", "dragon", "dragon lord", "wyrm", "giant spider", "hydra", "warlock", "demon"}

function onStartup()
    -- monster of the day
    local randomMonster = math.random(#boostedMonsterList)
    setGlobalStorageValue(BOOSTED_MONSTER, randomMonster)
    print("Today's boosted monster is: " .. boostedMonsterList[randomMonster])
end

Lua:
local BOOSTED_MONSTER = 56404
local boostedMonstersList = {"rat", "spider", "troll", "orc", "minotaur", "dwarf", "elf", "skeleton", "amazon", "valkirie", "dark apprentice", "ghoul", "cyclops", "dwarf guard", "necromancer", "vampire", "werewolf", "dragon", "dragon lord", "wyrm", "giant spider", "hydra", "warlock", "demon"}
local experienceBonus = 0.3 -- this means: 30% more experience

function onKill(cid, target, damage, flags)
  local master = getCreatureMaster(target)
  if (master and master ~= target) then
    return true
  end
  local boostedMonster = monsters[getGlobalStorageValue(BOOSTED_MONSTER)]
  if getCreatureName(target):lower() == boostedMonster then
    local bonusExperience = getMonsterInfo(getCreatureName(target)).experience * getPlayerRates(cid)[SKILL__LEVEL] * experienceBonus
    doPlayerAddExperience(cid, bonusExperience)
    print("[BOOSTED MONSTER]: " .. boostedMonster)
  end
  return true
end

I thought that vars on data/lib could be accessed in every scripts

Still that error:
Code:
[12:38:24.011] [Error - GlobalEvent Interface] 
[12:38:24.011] data/globalevents/scripts/monsteroftheday_oninit.lua:onStartup
[12:38:24.011] Description: 
[12:38:24.011] data/globalevents/scripts/monsteroftheday_oninit.lua:6: attempt to get length of global 'boostedMonsterList' (a nil value)
[12:38:24.011] stack traceback:
[12:38:24.011]     data/globalevents/scripts/monsteroftheday_oninit.lua:6: in function <data/globalevents/scripts/monsteroftheday_oninit.lua:4>
 
Lua:
local BOOSTED_MONSTER = 56404
local boostedMonstersList = {"rat", "spider", "troll", "orc", "minotaur", "dwarf", "elf", "skeleton", "amazon", "valkirie", "dark apprentice", "ghoul", "cyclops", "dwarf guard", "necromancer", "vampire", "werewolf", "dragon", "dragon lord", "wyrm", "giant spider", "hydra", "warlock", "demon"}

function onStartup()
    -- monster of the day
    local randomMonster = math.random(#boostedMonsterList)
    setGlobalStorageValue(BOOSTED_MONSTER, randomMonster)
    print("Today's boosted monster is: " .. boostedMonsterList[randomMonster])
end

Start looking at the code and not just on the console errors.
Typo in the word boostedMonsterList.
Lua:
local boostedMonstersList = {"rat", "spider", ...,}

Lua:
local randomMonster = math.random(#boostedMonsterList)
Lua:
print("Today's boosted monster is: " .. boostedMonsterList[randomMonster])
 
The var name has an s at the end of Monster, however whenever it's accessed that s is not there.
Exactly :D

I remember that without registering in monster.xml onKill, onDeath scripts didn't work on monsters.
If it will not work for you too, add it to every monster:
Lua:
<script>
        <event name="eventname"/>
</script>

shorter version c++
 
Just copy the entire array on each of the file like this:
Lua:
local BOOSTED_MONSTER = 56404
local boostedMonsterList = {"rat", "spider", "troll", "orc", "minotaur", "dwarf", "elf", "skeleton", "amazon", "valkirie", "dark apprentice", "ghoul", "cyclops", "dwarf guard", "necromancer", "vampire", "werewolf", "dragon", "dragon lord", "wyrm", "giant spider", "hydra", "warlock", "demon"}

function onStartup()
    -- monster of the day
    local randomMonster = math.random(#boostedMonsterList)
    setGlobalStorageValue(BOOSTED_MONSTER, randomMonster)
    print("Today's boosted monster is: " .. boostedMonsterList[randomMonster])
end

Lua:
local BOOSTED_MONSTER = 56404
local boostedMonsterList = {"rat", "spider", "troll", "orc", "minotaur", "dwarf", "elf", "skeleton", "amazon", "valkirie", "dark apprentice", "ghoul", "cyclops", "dwarf guard", "necromancer", "vampire", "werewolf", "dragon", "dragon lord", "wyrm", "giant spider", "hydra", "warlock", "demon"}
local experienceBonus = 0.3 -- this means: 30% more experience

function onKill(cid, target, damage, flags)
  local master = getCreatureMaster(target)
  if (master and master ~= target) then
    return true
  end
  local boostedMonster = boostedMonsterList[getGlobalStorageValue(BOOSTED_MONSTER)]
  if getCreatureName(target):lower() == boostedMonster then
    local bonusExperience = getMonsterInfo(getCreatureName(target)).experience * getPlayerRates(cid)[SKILL__LEVEL] * experienceBonus
    doPlayerAddExperience(cid, bonusExperience)
    print("[BOOSTED MONSTER]: " .. boostedMonster)
  end
  return true
end

One issue to consider when using onKill in this situation, is that every player to participate by dealing any amount of damage will receive the full bonus exp.

To avoid this, the function getCreatureDamageMap() should be added through a source edit (it's not native to 0.4).
It should be used in an onPrepareDeath script to calculate the total amount of damage & provide exp to each participant based on how many % of the total damage they've dealt.
 
One issue to consider when using onKill in this situation, is that every player to participate by dealing any amount of damage will receive the full bonus exp.

To avoid this, the function getCreatureDamageMap() should be added through a source edit (it's not native to 0.4).
It should be used in an onPrepareDeath script to calculate the total amount of damage & provide exp to each participant based on how many % of the total damage they've dealt.
This is true, as I stated before this is not a completed code, but might help a bit.
 
This is true, as I stated before this is not a completed code, but might help a bit.


This i'll try to fix by myself latter, for now would be amazing have this base


---


lib/monster_of_day.lua
Code:
-- [lib]
-- /lib/monster_of_day.lua

-- [globalevents]
-- <globalevent name="monster_of_day" type="startup" event="script" value="monsteroftheday_oninit.lua"/>

-- [creature]
-- <event type="kill" name="monsteroftheday_onkill" event="script" value="monsteroftheday_onkill.lua"/>
-- [login.lua]
-- registerCreatureEvent(cid, "monsteroftheday_onkill")

BOOSTED_MONSTER = 56404
mboostedExperienceBonus = 0.3 -- this means: 30% more experience
mboostedMonstersList = {"rat", "spider", "troll", "orc", "minotaur", "dwarf", "elf", "skeleton", "amazon", "valkirie", "dark apprentice", "ghoul", "cyclops", "dwarf guard", "necromancer", "vampire", "werewolf", "dragon", "dragon lord", "wyrm", "giant spider", "hydra", "warlock", "demon"}

monsteroftheday_oninit.lua
Code:
function onStartup()
    local randomMonster = math.random(#mboostedMonstersList)
    setGlobalStorageValue(BOOSTED_MONSTER, randomMonster)
    print("Today's boosted monster is: " .. mboostedMonstersList[randomMonster])
end

monsteroftheday_onkill.lua
Code:
function onKill(cid, target, damage, flags)
  local master = getCreatureMaster(target)
  if (master and master ~= target) then
    return true
  end
  local boostedMonster = monsters[getGlobalStorageValue(BOOSTED_MONSTER)]
  if getCreatureName(target):lower() == boostedMonster then
    local bonusExperience = getMonsterInfo(getCreatureName(target)).experience * getPlayerRates(cid)[SKILL__LEVEL] * mboostedExperienceBonus
    doPlayerAddExperience(cid, bonusExperience)
    print("[BOOSTED MONSTER]: " .. boostedMonster)
  end
  return true
end

Code:
[19:30:00.834] >> Initializing game state and binding services...
Today's boosted monster is: orc
[19:30:01.055] > Global IP address: 127.0.0.1

But got this error when kill the Orc
Code:
[19:32:43.149] [Error - CreatureScript Interface] 
[19:32:43.149] data/creaturescripts/scripts/monsteroftheday_onkill.lua:onKill
[19:32:43.149] Description: 
[19:32:43.149] ...a/creaturescripts/scripts/monsteroftheday_onkill.lua:6: attempt to index global 'monsters' (a nil value)
[19:32:43.149] stack traceback:
[19:32:43.149]  ...a/creaturescripts/scripts/monsteroftheday_onkill.lua:6: in function <...a/creaturescripts/scripts/monsteroftheday_onkill.lua:1>

[19:32:43.651] [Error - CreatureScript Interface] 
[19:32:43.651] data/creaturescripts/scripts/monsteroftheday_onkill.lua:onKill
[19:32:43.651] Description: 
[19:32:43.651] ...a/creaturescripts/scripts/monsteroftheday_onkill.lua:6: attempt to index global 'monsters' (a nil value)
[19:32:43.651] stack traceback:
[19:32:43.651]  ...a/creaturescripts/scripts/monsteroftheday_onkill.lua:6: in function <...a/creaturescripts/scripts/monsteroftheday_onkill.lua:1>

--

So i tried to add register stuff to every monster
j ust like: Feature - [CreatureEvent] Regestire all monster and players in creatureevent.xml (https://otland.net/threads/creatureevent-regestire-all-monster-and-players-in-creatureevent-xml.134003/)

So i made this changes on creatureevent.cpp, creatureevent.h and monster.cpp

creatureevent.cpp

type CTRL+F:
// register all monster 1
// register all monster 2


creatureevent.h

type CTRL+F:
// register all monster 1
// register all monster 2
// register all monster 3



monster.cpp

type CTRL+F:
// register all monster 1
// register all monster 2


So when i start the server i got a lot of errors:
Code:
[12:37:19.993] [Warning - CreatureEvent::configureEvent] : You havn't register event 'GuildMotd'
[12:37:19.993] [Warning - CreatureEvent::configureEvent] : You havn't register event 'Mail'
[12:37:19.993] [Warning - CreatureEvent::configureEvent] : You havn't register event 'SaveReportBug'
[12:37:19.994] [Warning - CreatureEvent::configureEvent] : You havn't register event 'AdvanceSave'
[12:37:19.994] [Warning - CreatureEvent::configureEvent] : You havn't register event 'Idle'
[12:37:19.995] [Warning - CreatureEvent::configureEvent] : You havn't register event 'SkullCheck'
[12:37:20.010] [Warning - CreatureEvent::configureEvent] : You havn't register event 'Coins'
[12:37:20.029] [Warning - CreatureEvent::configureEvent] : You havn't register event 'FullHpManaUP'
...
[12:37:20.232] > Loading MarriageSystem.xml...[Warning - CreatureEvent::configureEvent] : You havn't register event 'MarryLook'
[12:37:20.232] [Warning - CreatureEvent::configureEvent] : You havn't register event 'MarryNoAttack'
[12:37:20.232]  done.
[12:37:20.243] > Loading autoLootOnKill.xml...[Warning - CreatureEvent::configureEvent] : You havn't register event 'LootEventDeath'
[12:37:20.244] [Warning - CreatureEvent::configureEvent] : You havn't register event 'MonsterAttack'
[12:37:20.245]  done.
[12:37:20.248] > Loading Arenaqst.xml...[Warning - CreatureEvent::configureEvent] : You havn't register event 'PlayerArena'
[12:37:20.249] [Warning - CreatureEvent::configureEvent] : You havn't register event 'ArenaKill'
[12:37:20.254]  done.
[12:37:20.269] > Loading Simple Task.xml...[Warning - CreatureEvent::configureEvent] : You havn't register event 'KillTask'
[12:37:20.271]  done.
 
Back
Top