• 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 [1.4.X] onLook (creatureScript)

OTcreator

Active Member
Joined
Feb 14, 2022
Messages
425
Solutions
1
Reaction score
44
Hello.
I use this script in 0.3.7 on creaturescript and work fine.
How I can add this to TFS 1.4.2?
Events onPlayer? On creaturescripts not working.

Lua:
    local titles = {
                [0] = "Private",
                [10] = "Huntsman",
                [20] = "Ranger",
                [40] = "Big Game Hunter",
                [70] = "Trophy Hunter",
                [100] = "Elite Hunter"
            }
            
        local rankStorage = 2500
        
        function onLook(cid, thing, position, lookDistance)
                if(isPlayer(thing.uid)) then
                    local rank = {rank = "Private", name = 0}
                    for k, v in pairs(titles) do
                        if(math.max(0, getPlayerStorageValue(thing.uid, rankStorage)) > k - 1) then
                            if(k - 1 > rank.name) then
                                rank.rank, rank.name = v, k - 1
                            end
                        end
                    end
                    doPlayerSetSpecialDescription(thing.uid, "\n Task rank: " .. rank.rank ..".")
                end
                return true
            end
 
data\scripts\eventcallbacks\player\player_onLook.lua
Lua:
local titles = {
    [0] = "Private",
    [10] = "Huntsman",
    [20] = "Ranger",
    [40] = "Big Game Hunter",
    [70] = "Trophy Hunter",
    [100] = "Elite Hunter"
}
local rankStorage = 2500

local ec = EventCallback
ec.onLook = function(self, thing, position, distance, description)
    if thing:isPlayer() then
        local rank = { name = "Private", id = 0}
        for k, v in pairs(titles) do
            if (math.max(0, thing:getStorageValue(rankStorage)) > k - 1) then
                if k - 1 > rank.id then
                    rank.name, rank.id = v, k - 1
                end
            end
        end

        return ("%s Task rank: %s"):format(description, rank.name)
    end

    return description
end

ec:register()
 
Back
Top