• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

TalkAction [TFS 1.X] /mute and /unmute

Linuss

#use rs232(baud = 19200)
Joined
Apr 17, 2015
Messages
3
Reaction score
6
mute.lua

Lua:
function onSay(player, words, param)

    local storage = 456112

    if words == "/mute" then
        local mute = param:split(",")

        if mute[1] == nil or mute[1] == " " then
            player:sendCancelMessage("Invalid player specified.")
            return false
        end

        if mute[2] == nil or mute[2] == " " then
            player:sendCancelMessage("Invalid time specified.")
            return false
        end

        local target = Player(mute[1])
        local time = tonumber(mute[2])
        local condition = Condition(CONDITION_MUTED)
        condition:setParameter(CONDITION_PARAM_TICKS, time*60*1000)

        if player:getAccountType() < ACCOUNT_TYPE_TUTOR then
            return false
        end

        if target == nil then
            player:sendCancelMessage("A player with that name is not online.")
            return false
        end

        if target:getAccountType() >= ACCOUNT_TYPE_TUTOR then
            player:sendCancelMessage("Only player can be mutated")
            return false
        end

        target:addCondition(condition)
        target:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have been muted by " .. player:getName() .. " , to "..time.. " minutes.")
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You muted " .. target:getName() .." to "..time.." minutes.")
        target:setStorageValue(storage, 1)
        return false
    end

    if words == "/unmute" then

        local remove = Player(param)

        if player:getAccountType() < ACCOUNT_TYPE_TUTOR then
            return false
        end

        if remove == nil then
            player:sendCancelMessage("A player with that name is not online.")
            return false
        end

        if remove:getAccountType() >= ACCOUNT_TYPE_TUTOR then
            return false
        end

        if remove:getStorageValue(storage) == 1 then
            remove:removeCondition(CONDITION_MUTED)
            remove:setStorageValue(storage, -1)
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have unmute" .. remove:getName() ..".")
            remove:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have been unmute by " .. player:getName() ..".")
        else
            player:sendCancelMessage("A player " .. remove:getName() .. "is not mutated")
        end
    end

    return false
end

talkactions.XML

XML:
<talkaction words="/mute" separator=" " script="mute.lua" />
<talkaction words="/unmute" separator=" " script="mute.lua" />



how to use :

/mute Linuss, 1
/unmute Linuss
 
Nice job, but i would done something like this:

Code:
local muteCondition = Condition(CONDITION_MUTED, CONDITIONID_DEFAULT)

function onSay(player, words, param)
    if player:getAccountType() < ACCOUNT_TYPE_TUTOR then
        return true
    end
       
    if words == "/mute" then
            local mute = param:split(",")

            local targetPlayer = Player(mute[1])
        if not targetPlayer then
            player:sendCancelMessage("Player not found.")
            return false
        end
       
            local time = tonumber(mute[2])
        if not time or time > 30000 then
            player:sendCancelMessage("Invalid time specified or time is more than 30000 minutes.")
            return false
        end

        if targetPlayer:getAccountType() >= ACCOUNT_TYPE_TUTOR then
            player:sendCancelMessage("Only players can be muted.")
                    return false
            end

        muteCondition:setParameter(CONDITION_PARAM_TICKS, time * 60 * 1000)
            targetPlayer:addCondition(muteCondition)
            targetPlayer:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have been muted by " .. player:getName() .. " , to "..time.. " minutes.")
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You muted " .. targetPlayer:getName() .." to "..time.." minutes.")
            return false
        elseif words == "/unmute" then
            local targetPlayer = Player(param)

            if not targetPlayer then
                    player:sendCancelMessage("A player with that name is not online.")
                    return false
            end
       
        local condition = targetPlayer:getCondition(CONDITION_MUTED, CONDITIONID_DEFAULT)
        if not condition then
            player:sendCancelMessage(targetPlayer:getName() .." is not mutated")
            return false
        end

        targetPlayer:removeCondition(CONDITION_MUTED, CONDITIONID_DEFAULT)
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have unmute " .. targetPlayer:getName() ..".")
            targetPlayer:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have been unmute by " .. player:getName() ..".")
        end
        return false
end

No idea why you are checking for storage, when you can check for the condition.
 
Nice job, but i would done something like this:

Code:
local muteCondition = Condition(CONDITION_MUTED, CONDITIONID_DEFAULT)

function onSay(player, words, param)
    if player:getAccountType() < ACCOUNT_TYPE_TUTOR then
        return true
    end
      
    if words == "/mute" then
            local mute = param:split(",")

            local targetPlayer = Player(mute[1])
        if not targetPlayer then
            player:sendCancelMessage("Player not found.")
            return false
        end
      
            local time = tonumber(mute[2])
        if not time or time > 30000 then
            player:sendCancelMessage("Invalid time specified or time is more than 30000 minutes.")
            return false
        end

        if targetPlayer:getAccountType() >= ACCOUNT_TYPE_TUTOR then
            player:sendCancelMessage("Only players can be muted.")
                    return false
            end

        muteCondition:setParameter(CONDITION_PARAM_TICKS, time * 60 * 1000)
            targetPlayer:addCondition(muteCondition)
            targetPlayer:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have been muted by " .. player:getName() .. " , to "..time.. " minutes.")
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You muted " .. targetPlayer:getName() .." to "..time.." minutes.")
            return false
        elseif words == "/unmute" then
            local targetPlayer = Player(param)

            if not targetPlayer then
                    player:sendCancelMessage("A player with that name is not online.")
                    return false
            end
      
        local condition = targetPlayer:getCondition(CONDITION_MUTED, CONDITIONID_DEFAULT)
        if not condition then
            player:sendCancelMessage(targetPlayer:getName() .." is not mutated")
            return false
        end

        targetPlayer:removeCondition(CONDITION_MUTED, CONDITIONID_DEFAULT)
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have unmute " .. targetPlayer:getName() ..".")
            targetPlayer:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have been unmute by " .. player:getName() ..".")
        end
        return false
end

No idea why you are checking for storage, when you can check for the condition.
@Linuss

I think storage value is better option.
Condition can be warn off by relogging and if later on when server gets too custom, you never know when you remove conditions with spell or potion or food or whatnot.
 
And how only works for the help & advertising?

I would put this command for tutors, and work only in help & advertising.

TFS 1.0
 
it does not work on tfs 1.0, it's not outputing any msg, and its not muting anyone.
 
Im USed Tfs 0.4 Mute is Fixed But Unmute No And When i Give Any one Mute Relog and Open The Mute Gone Lol.. Can SOme One Help me
 
Back
Top