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

Lua [TFS 0.X] Monster Boosted problem - Attempt to index a boolean value when kill

potinho

Intermediate OT User
Joined
Oct 11, 2009
Messages
1,397
Solutions
17
Reaction score
148
Location
Brazil
Hi guys,

Im trying to use the system from this topic:

But i got error sometimes when a monster of day is killed:

2022-09-23 13:39:26 - [Error - CreatureScript Interface]
2022-09-23 13:39:26 - data/creaturescripts/scripts/daily_monster_bonus.lua:eek:nDeath
2022-09-23 13:39:26 - Description:
2022-09-23 13:39:26 - (luaGetPlayerRates) Player not found
2022-09-23 13:39:26 -
2022-09-23 13:39:26 - [Error - CreatureScript Interface]
2022-09-23 13:39:26 - data/creaturescripts/scripts/daily_monster_bonus.lua:eek:nDeath
2022-09-23 13:39:26 - Description:
2022-09-23 13:39:26 - data/creaturescripts/scripts/daily_monster_bonus.lua:18: attempt to index a boolean value
2022-09-23 13:39:26 - stack traceback:
2022-09-23 13:39:26 - data/creaturescripts/scripts/daily_monster_bonus.lua:18: in function <data/creaturescripts/scripts/daily_monster_bonus.lua:5>

I dont know if is a bug, but when i open table "global_storage" on database, nothing is there, but exp bonus its working. I removed loot from script, follow my actual

globalevent.lua
Lua:
function onStartup()
local BOOSTED_MONSTER = 56404
local boostedMonstersList = {"giant spider", "hydra", "warlock", "demon"}
local randomMonster = math.random(#boostedMonstersList)
setGlobalStorageValue(BOOSTED_MONSTER, randomMonster)
local spawn = {x = 155, y = 50, z = 7}  --  monster spawn position
    doCreateMonster(boostedMonstersList[randomMonster], spawn)
    print("Today's boosted monster is: " .. boostedMonstersList[randomMonster])
end

daily_monster_bonus.lua
Lua:
BOOSTED_MONSTER = 56404
local boostedMonstersList = {"giant spider", "hydra", "warlock", "demon"}
experienceBonus = 50

function onDeath(cid, corpse, deathList)

local master = getCreatureMaster(cid)
  if (master and master ~= cid) then
    return true
  end

  local boostedMonster = boostedMonstersList[getGlobalStorageValue(BOOSTED_MONSTER)]
    if getCreatureName(cid):lower() == boostedMonster then
   
for i = 1, #deathList do
   
-- exp bonus
    local bonusExperience = getMonsterInfo(getCreatureName(cid)).experience/i * getPlayerRates(deathList[i])[SKILL__LEVEL] * experienceBonus/100
    doPlayerAddExperience(deathList[i], bonusExperience)
    doSendAnimatedText(getPlayerPosition(deathList[i]), bonusExperience, 215)
 
  end
   
    end
    return true
end

daily_monster.lua
Lua:
function onStartup()
local BOOSTED_MONSTER = 56404
local boostedMonstersList = {"giant spider", "hydra", "warlock", "demon"}
local randomMonster = math.random(#boostedMonstersList)
setGlobalStorageValue(BOOSTED_MONSTER, randomMonster)
local spawn = {x = 155, y = 50, z = 7}  --  monster spawn position
    doCreateMonster(boostedMonstersList[randomMonster], spawn)
    print("Today's boosted monster is: " .. boostedMonstersList[randomMonster])
end

I already put
Lua:
        <script>      <event name="daily_monster_bonus"/></script>
on each monster of boosted system and put
Lua:
    registerCreatureEvent(cid, "daily_monster")
on login.lua
 
Solution
Probably it's this:
Lua:
local bonusExperience = getMonsterInfo(getCreatureName(cid)).experience/i * getPlayerRates(deathList[i])[SKILL__LEVEL] * experienceBonus/100
exactly this part:
Lua:
getPlayerRates(deathList[i])[SKILL__LEVEL]
You are trying to get getPlayerRates of deathList[i] and then read it as table using [SKILL__LEVEL], but deathList[i] can be summon of player or other monster, which dealt damage to boosted monster by ex. wave.
You should first check if deathList[i] is player:
Lua:
if isPlayer(deathList[i]) then
-- here code to add exp
end
Probably it's this:
Lua:
local bonusExperience = getMonsterInfo(getCreatureName(cid)).experience/i * getPlayerRates(deathList[i])[SKILL__LEVEL] * experienceBonus/100
exactly this part:
Lua:
getPlayerRates(deathList[i])[SKILL__LEVEL]
You are trying to get getPlayerRates of deathList[i] and then read it as table using [SKILL__LEVEL], but deathList[i] can be summon of player or other monster, which dealt damage to boosted monster by ex. wave.
You should first check if deathList[i] is player:
Lua:
if isPlayer(deathList[i]) then
-- here code to add exp
end
 
Solution
Probably it's this:
Lua:
local bonusExperience = getMonsterInfo(getCreatureName(cid)).experience/i * getPlayerRates(deathList[i])[SKILL__LEVEL] * experienceBonus/100
exactly this part:
Lua:
getPlayerRates(deathList[i])[SKILL__LEVEL]
You are trying to get getPlayerRates of deathList[i] and then read it as table using [SKILL__LEVEL], but deathList[i] can be summon of player or other monster, which dealt damage to boosted monster by ex. wave.
You should first check if deathList[i] is player:
Lua:
if isPlayer(deathList[i]) then
-- here code to add exp
end
Thanks! To get Monster of the day and put this image on Gesior ACC, there's a way to do? I put manually like this:

PHP:
<img id="Monster" src="/outfit.php?id=35&addons=0&head=0&body=0&legs=0&feet=0" alt="Monster of the Day" />
 
Back
Top