• 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.X] Player:hasEvent()

Codinablack

Dreamer
Content Editor
Joined
Dec 26, 2013
Messages
1,625
Solutions
11
Reaction score
865
Here you guys go, its just a simple small function that returns true if the player has the event, or false if they don't have it.

Its a lib, so add where you keep your libs (data/lib), but don't forget to make sure its loaded using dofile() or if you have a folder that loads all libs inside (data/lib/core on master branch, or data/scripts), can just drop in there and then be called anywhere.


Lua:
function Player:hasEvent(type, name)
    for k,v in pairs(self:getEvents(type)) do
        if v == name then
            return true
        end
    end
    return false
end

Small , simple, useful.

Can change Player to Creature, to make it work with monsters and players, as well as npcs
Post automatically merged:

For those wondering about the params. The type is an enum from these options
Lua:
CREATURE_EVENT_NONE
CREATURE_EVENT_LOGIN
CREATURE_EVENT_LOGOUT
CREATURE_EVENT_THINK
CREATURE_EVENT_PREPAREDEATH
CREATURE_EVENT_DEATH
CREATURE_EVENT_KILL
CREATURE_EVENT_ADVANCE
CREATURE_EVENT_MODALWINDOW
CREATURE_EVENT_TEXTEDIT
CREATURE_EVENT_HEALTHCHANGE
CREATURE_EVENT_MANACHANGE
CREATURE_EVENT_EXTENDED_OPCODE

and the name is a string, which must be exact match for the specific event you are checking for, the "" inside CreatureEvent("name")
 
Last edited:
Back
Top