• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Tfs 1.2 help exaust

Code:
<channel id="9" name="Help" logged="yes" muted="30" conditionId="4" conditionMessage="You may only place one message every 30 seconds."/>

Something like that? In xml, instead of the script.
 
Hi folks! I don't know why this script does not give exaust of 120 seconds for players how talk in help channel. Can someone check it and fix?

Thanks.
Code:
local CHANNEL_HELP = 7
local ticks = {3600000, 120000}
local types = {'mute', 'exhausted'}
local muted = {}
for i = 1, #ticks do
    muted[types[i]] = Condition(CONDITION_CHANNELMUTEDTICKS, CONDITIONID_DEFAULT)
    muted:setParameter(CONDITION_PARAM_SUBID, CHANNEL_HELP + i)
    muted:setParameter(CONDITION_PARAM_TICKS, ticks[i])
end

local level = 8
local commands = { "!mute", "!unmute" }

function onSpeak(player, type, message)
    local playerAccountType = player:getAccountType()
    if player:getLevel() < level or playerAccountType == ACCOUNT_TYPE_NORMAL then
        player:sendCancelMessage("You may not speak into channels as long as you are lower than level ".. level ..".")
        return false
    end
   
    for k = 1, #ticks do
        if player:getCondition(CONDITION_CHANNELMUTEDTICKS, CONDITIONID_DEFAULT, CHANNEL_HELP + k)then
            player:sendCancelMessage("You are muted from the Help channel for using it inappropriately.")
            return false
        end
    end

    if playerAccountType >= ACCOUNT_TYPE_TUTOR then
        if string.sub(message, 1, #commands[1]) == commands[1] then
            local targetName = string.sub(message, #commands[1] + 1)
            local target = Player(targetName)
            if target ~= nil then
                if playerAccountType > target:getAccountType() then
                    if not target:getCondition(CONDITION_CHANNELMUTEDTICKS, CONDITIONID_DEFAULT, CHANNEL_HELP + 1) then
                        target:addCondition(muted[types[1]])
                        sendChannelMessage(CHANNEL_HELP, TALKTYPE_CHANNEL_R1, targetName .. " has been muted by " .. player:getName() .. " for using Help Channel inappropriately.")
                    else
                        if not target:getCondition(CONDITION_CHANNELMUTEDTICKS, CONDITIONID_DEFAULT, CHANNEL_HELP + 2) then
                            player:addCondition(muted[types[2]])
                            player:sendCancelMessage("That player is already muted, but now is exhausted.")
                        else
                            player:sendCancelMessage("That player is already muted and exhausted.")
                        end
                    end
                else
                    player:sendCancelMessage("You are not authorized to mute that player.")
                end
            else
                player:sendCancelMessage(RETURNVALUE_PLAYERWITHTHISNAMEISNOTONLINE)
            end
            return false
        elseif string.sub(message, 1, #commands[2]) == #commands[2] then
            local targetName = string.sub(message, #commands[2] + 1)
            local target = Player(targetName)
            if target ~= nil then
                if playerAccountType > target:getAccountType() then
                    if target:getCondition(CONDITION_CHANNELMUTEDTICKS, CONDITIONID_DEFAULT, CHANNEL_HELP + 1) or target:getCondition(CONDITION_CHANNELMUTEDTICKS, CONDITIONID_DEFAULT, CHANNEL_HELP + 2) then
                        for x = 1, #ticks do
                            target:removeCondition(CONDITION_CHANNELMUTEDTICKS, CONDITIONID_DEFAULT, CHANNEL_HELP + x)
                        end
                        sendChannelMessage(CHANNEL_HELP, TALKTYPE_CHANNEL_R1, targetName .. " has been unmuted by " .. player:getName() .. ".")
                    else
                        player:sendCancelMessage("That player is not muted.")
                    end
                else
                    player:sendCancelMessage("You are not authorized to unmute that player.")
                end
            else
                player:sendCancelMessage(RETURNVALUE_PLAYERWITHTHISNAMEISNOTONLINE)
            end
            return false
        end
    end

    if type == TALKTYPE_CHANNEL_Y then
        if playerAccountType >= ACCOUNT_TYPE_TUTOR or getPlayerFlagValue(player, PlayerFlag_TalkOrangeHelpChannel) then
            type = TALKTYPE_CHANNEL_O
        end
    elseif type == TALKTYPE_CHANNEL_O then
        if playerAccountType < ACCOUNT_TYPE_TUTOR and not getPlayerFlagValue(player, PlayerFlag_TalkOrangeHelpChannel) then
            type = TALKTYPE_CHANNEL_Y
        end
    elseif type == TALKTYPE_CHANNEL_R1 then
        if playerAccountType < ACCOUNT_TYPE_GAMEMASTER and not getPlayerFlagValue(player, PlayerFlag_CanTalkRedChannel) then
            if playerAccountType >= ACCOUNT_TYPE_TUTOR or getPlayerFlagValue(player, PlayerFlag_TalkOrangeHelpChannel) then
                type = TALKTYPE_CHANNEL_O
            else
                type = TALKTYPE_CHANNEL_Y
            end
        end
    end
    return type
end
 
All I can do is guess :p

Now we got a error.

IRPFkGz.png
 
Human Error.. it happens.
Code:
local CHANNEL_HELP = 7
local ticks = {3600000, 120000}
local types = {'mute', 'exhausted'}
local muted = {}
for i = 1, #ticks do
    muted[types[i]] = Condition(CONDITION_CHANNELMUTEDTICKS, CONDITIONID_DEFAULT)
    muted[types[i]]:setParameter(CONDITION_PARAM_SUBID, CHANNEL_HELP + i)
    muted[types[i]]:setParameter(CONDITION_PARAM_TICKS, ticks[i])
end

local level = 8
local commands = { "!mute", "!unmute" }

function onSpeak(player, type, message)
    local playerAccountType = player:getAccountType()
    if player:getLevel() < level or playerAccountType == ACCOUNT_TYPE_NORMAL then
        player:sendCancelMessage("You may not speak into channels as long as you are lower than level ".. level ..".")
        return false
    end
 
    for k = 1, #ticks do
        if player:getCondition(CONDITION_CHANNELMUTEDTICKS, CONDITIONID_DEFAULT, CHANNEL_HELP + k)then
            player:sendCancelMessage("You are muted from the Help channel for using it inappropriately.")
            return false
        end
    end

    if playerAccountType >= ACCOUNT_TYPE_TUTOR then
        if string.sub(message, 1, #commands[1]) == commands[1] then
            local targetName = string.sub(message, #commands[1] + 1)
            local target = Player(targetName)
            if target ~= nil then
                if playerAccountType > target:getAccountType() then
                    if not target:getCondition(CONDITION_CHANNELMUTEDTICKS, CONDITIONID_DEFAULT, CHANNEL_HELP + 1) then
                        target:addCondition(muted[types[1]])
                        sendChannelMessage(CHANNEL_HELP, TALKTYPE_CHANNEL_R1, targetName .. " has been muted by " .. player:getName() .. " for using Help Channel inappropriately.")
                    else
                        if not target:getCondition(CONDITION_CHANNELMUTEDTICKS, CONDITIONID_DEFAULT, CHANNEL_HELP + 2) then
                            player:addCondition(muted[types[2]])
                            player:sendCancelMessage("That player is already muted, but now is exhausted.")
                        else
                            player:sendCancelMessage("That player is already muted and exhausted.")
                        end
                    end
                else
                    player:sendCancelMessage("You are not authorized to mute that player.")
                end
            else
                player:sendCancelMessage(RETURNVALUE_PLAYERWITHTHISNAMEISNOTONLINE)
            end
            return false
        elseif string.sub(message, 1, #commands[2]) == #commands[2] then
            local targetName = string.sub(message, #commands[2] + 1)
            local target = Player(targetName)
            if target ~= nil then
                if playerAccountType > target:getAccountType() then
                    if target:getCondition(CONDITION_CHANNELMUTEDTICKS, CONDITIONID_DEFAULT, CHANNEL_HELP + 1) or target:getCondition(CONDITION_CHANNELMUTEDTICKS, CONDITIONID_DEFAULT, CHANNEL_HELP + 2) then
                        for x = 1, #ticks do
                            target:removeCondition(CONDITION_CHANNELMUTEDTICKS, CONDITIONID_DEFAULT, CHANNEL_HELP + x)
                        end
                        sendChannelMessage(CHANNEL_HELP, TALKTYPE_CHANNEL_R1, targetName .. " has been unmuted by " .. player:getName() .. ".")
                    else
                        player:sendCancelMessage("That player is not muted.")
                    end
                else
                    player:sendCancelMessage("You are not authorized to unmute that player.")
                end
            else
                player:sendCancelMessage(RETURNVALUE_PLAYERWITHTHISNAMEISNOTONLINE)
            end
            return false
        end
    end

    if type == TALKTYPE_CHANNEL_Y then
        if playerAccountType >= ACCOUNT_TYPE_TUTOR or getPlayerFlagValue(player, PlayerFlag_TalkOrangeHelpChannel) then
            type = TALKTYPE_CHANNEL_O
        end
    elseif type == TALKTYPE_CHANNEL_O then
        if playerAccountType < ACCOUNT_TYPE_TUTOR and not getPlayerFlagValue(player, PlayerFlag_TalkOrangeHelpChannel) then
            type = TALKTYPE_CHANNEL_Y
        end
    elseif type == TALKTYPE_CHANNEL_R1 then
        if playerAccountType < ACCOUNT_TYPE_GAMEMASTER and not getPlayerFlagValue(player, PlayerFlag_CanTalkRedChannel) then
            if playerAccountType >= ACCOUNT_TYPE_TUTOR or getPlayerFlagValue(player, PlayerFlag_TalkOrangeHelpChannel) then
                type = TALKTYPE_CHANNEL_O
            else
                type = TALKTYPE_CHANNEL_Y
            end
        end
    end
    return type
end
 
@Codex NG
Testing with a normal account and always returning with this, also when I remove lines 16-19 it just does not speak on the channel.
Originally you had this code added, so I combined it with the level restriction.
Code:
    -- add exaust to account_type_normal
    if playerAccountType == ACCOUNT_TYPE_NORMAL then
        player:addCondition(exausted)
    end
I don't run these codes on a server so I don't know what the values are and apparently neither do you :p
I just use programming logic to try and get these scripts to work.
So with that said replace this
Code:
if player:getLevel() < level or playerAccountType == ACCOUNT_TYPE_NORMAL then
with this
Code:
if player:getLevel() < level then
 
Originally you had this code added, so I combined it with the level restriction.
Code:
    -- add exaust to account_type_normal
    if playerAccountType == ACCOUNT_TYPE_NORMAL then
        player:addCondition(exausted)
    end
I don't run these codes on a server so I don't know what the values are and apparently neither do you :p
I just use programming logic to try and get these scripts to work.
So with that said replace this
Code:
if player:getLevel() < level or playerAccountType == ACCOUNT_TYPE_NORMAL then
with this
Code:
if player:getLevel() < level then

Still can spam on help channel, but there is no erros on console.
 
now we have:
Code:
function Player.setExhaustion(self, value, time)
    return self:setStorageValue(value, time + os.time())
end

function Player.getExhaustion(self, value)
    local storage = self:getStorageValue(value)
    if storage <= 0 then
        return 0
    end

    return storage - os.time()
end
this function is pretty good, made by @Printer
way to use:
Code:
player:setExhaustion(keystorage, time)
exemple:
Code:
player:setExhaustion(Storage.Quest1, 60)
 
Back
Top