• 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 1.4] Rarity Rolls & Custom Attributes Library Bug?

Stewartt

Active Member
Joined
Jan 14, 2022
Messages
15
Reaction score
25
Location
Canada
Hey hope y'all good.
Im having problems with this amazing system [TFS 1.X] Rarity Rolls & Custom Attributes Library (https://otland.net/threads/tfs-1-x-rarity-rolls-custom-attributes-library.268888/)
Im using TFS 1.4 (latest one 12.85 from here: GitHub - otland/forgottenserver: A free and open-source MMORPG server emulator written in C++ (https://github.com/otland/forgottenserver)) i even managed to install the system/compile everything without any error/warning.
But the monsters doesn't drop any single "rarity item"
127.0.0.1_PzHHAf8jRH.gif
Tried spawning tons of mobs none of them drop rarity items but if i use /roll it works, how i can i make it work so monsters can drop rarity items without using /roll everytime?
PD: no error in console or warning so i don't really know
thanks in advance
 
maybe you did something wrong with the onSpawn and onDropLoot part since the tutorial is kinda outdated since eventcallbacks were implemented
 
Not sure tbh the OnSpawn thing was already implemented and since i don't get any error/warning i don't have a clue what could be wrong : ( such an amazing system

Using /roll it works but only this way
127.0.0.1_pOho1LiolS.gif
So yeah probably something OnDropLoot/OnSpawn needs to be updated : /
 
Last edited:
someone more familar with TFS 1.4 event callbacks would need to figure out where to place this code:

i have no idea how the new event callbacks work:
 
someone more familar with TFS 1.4 event callbacks would need to figure out where to place this code:

i have no idea how the new event callbacks work:
code was just moved to somewhere else: forgottenserver/default_onDropLoot.lua at master · otland/forgottenserver (https://github.com/otland/forgottenserver/blob/master/data/scripts/eventcallbacks/monster/default_onDropLoot.lua)

and now you can simply create a callback like this instead of changing the main function:

Lua:
local ec = EventCallback

function ec.onDropLoot(monster, corpse)
    -- Apply rarity chance to corpse contents and apply animation
    if rollRarity(corpse) > 0 then -- If a rare item was rolled, play animation
        if rare_popup then
            local spectators = Game.getSpectators(corpse:getPosition(), false, true, 7, 7, 5, 5)
            for i = 1, #spectators do
                spectators[i]:say(rare_text, TALKTYPE_MONSTER_SAY, false, spectators[i], corpse:getPosition())
            end
        end
        if rare_effect then
            corpse:getPosition():sendMagicEffect(rare_effect_id)
        end
    end
end

ec:register(-1)
 
Hey hope y'all good.
Im having problems with this amazing system [TFS 1.X] Rarity Rolls & Custom Attributes Library (https://otland.net/threads/tfs-1-x-rarity-rolls-custom-attributes-library.268888/)
Im using TFS 1.4 (latest one 12.85 from here: GitHub - otland/forgottenserver: A free and open-source MMORPG server emulator written in C++ (https://github.com/otland/forgottenserver)) i even managed to install the system/compile everything without any error/warning.
But the monsters doesn't drop any single "rarity item"
View attachment 64767
Tried spawning tons of mobs none of them drop rarity items but if i use /roll it works, how i can i make it work so monsters can drop rarity items without using /roll everytime?
PD: no error in console or warning so i don't really know
thanks in advance
did you manage it? tell me the solution
 
I tested it and it worked fine... I'm using TFS 1.4.2.

try.
events/scripts/monster.lua

Lua:
-- Rarity Animations
local rare_popup = true
local rare_effect = true
local rare_effect_id = CONST_ME_STUN

function Monster:onDropLoot(corpse)
    if EventCallback.onDropLoot then
        EventCallback.onDropLoot(self, corpse)
    end

    -- Apply rarity chance to corpse contents and apply animation
    if rollRarity(corpse) > 0 then -- If a rare item was rolled, play animation
        if rare_popup then
            local spectators = Game.getSpectators(corpse:getPosition(), false, true, 7, 7, 5, 5)
            for i = 1, #spectators do
                spectators[i]:say(rare_text, TALKTYPE_MONSTER_SAY, false, spectators[i], corpse:getPosition())
            end
        end
        if rare_effect then
            corpse:getPosition():sendMagicEffect(rare_effect_id)
        end
    end
end

function Monster:onSpawn(position, startup, artificial)
    if EventCallback.onSpawn then
        return EventCallback.onSpawn(self, position, startup, artificial)
    else
        return true
    end

    -- Register additional events
    self:registerEvent("rollHealth")
    self:registerEvent("rollMana")

    return true
end
 
Last edited:
I tried, this message appeared tfs 1.4.1

Lua Script Error: [Event Interface]
data/events/scripts/monster.lua:Monster@onDropLoot
...top\Dark War Server\data\scripts/lib\event_callbacks.lua:125: attempt to get length of local 'eventTable' (a nil value)
stack traceback:
[C]: in function '__len'
...top\Dark War Server\data\scripts/lib\event_callbacks.lua:125: in function 'onDropLoot'
data/events/scripts/monster.lua:8: in function <data/events/scripts/monster.lua:6>
I tested it and it worked fine... I'm using TFS 1.4.2.

try.
events/scripts/monster.lua

Lua:
-- Rarity Animations
local rare_popup = true
local rare_effect = true
local rare_effect_id = CONST_ME_STUN

function Monster:onDropLoot(corpse)
    if EventCallback.onDropLoot then
        EventCallback.onDropLoot(self, corpse)
    end

    -- Apply rarity chance to corpse contents and apply animation
    if rollRarity(corpse) > 0 then -- If a rare item was rolled, play animation
        if rare_popup then
            local spectators = Game.getSpectators(corpse:getPosition(), false, true, 7, 7, 5, 5)
            for i = 1, #spectators do
                spectators[i]:say(rare_text, TALKTYPE_MONSTER_SAY, false, spectators[i], corpse:getPosition())
            end
        end
        if rare_effect then
            corpse:getPosition():sendMagicEffect(rare_effect_id)
        end
    end
end

function Monster:onSpawn(position, startup, artificial)
    if EventCallback.onSpawn then
        return EventCallback.onSpawn(self, position, startup, artificial)
    else
        return true
    end

    -- Register additional events
    self:registerEvent("rollHealth")
    self:registerEvent("rollMana")

    return true
end
 
Back
Top