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

Exhaust for commands

jareczekjsp

Member
Joined
Jan 30, 2023
Messages
188
Reaction score
9
GitHub
Jarek123
Hello I use TFS 1.5 by nekiro , And I have question How I can add exhaust to Commands !aol !bless etc, for 2 seconds??
 
Lua:
local exhaustTable = {} -- Use different name for different script ( must be added on top of script )

-- This part add under the function
local playerGuid = player:getGuid()
local timeAmount = exhaustTable[playerGuid] -- exhaustTable name must be changed always to the current name you use for the table
if timeAmount and timeAmount > os.time() then
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You must wait " .. (timeAmount - os.time()) .. " seconds.")
    return true
end

-- do your stuff like player get aol now
exhaustTable[playerGuid] = os.time() + 60 -- 60 seconds amount + exhaustTable name must be changed always to the current name you use for the table

example how it should look like:

Lua:
local exhaustTable = {}

local talkAction = TalkAction("!aol")

function talkAction.onSay(player, words, param, type)
    local playerGuid = player:getGuid()
    local timeAmount = exhaustTable[playerGuid]
    if timeAmount and timeAmount > os.time() then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You must wait " .. (timeAmount - os.time()) .. " seconds.")
        return true
    end
    player:addItem(2173, 1)
    player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
    exhaustTable[playerGuid] = os.time() + 60
    return false
end

talkAction:register()
 
Back
Top