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

TalkAction [Cs] Command /Mute [Fixed]

Critico

Sexy
Joined
Mar 25, 2010
Messages
370
Reaction score
176
[Cs] Command /Mute/Desmute [Fixed]

Credits: Vodkart

muteplayer.lua
PHP:
local v = {}
for k = 1, 100 do
table.insert(v, createConditionObject(CONDITION_MUTED))
setConditionParam(v[k], CONDITION_PARAM_TICKS, k*60*1000)
end
function onSay(cid, words, param)
if (words == "/mute") then
local t = string.explode(param, ",")  
if param == '' then  doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid param specified.")  return true end  
local player,time,pid = getPlayerByName(t[1]),t[2],getPlayerByNameWildcard(t[1])  
if(not pid or (isPlayerGhost(pid) and getPlayerGhostAccess(pid) > getPlayerGhostAccess(cid))) then  
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player with this name doesn\'t exist or is offline.")  return TRUE  end
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You muted Player "..t[1].." for "..time.." minutes.")
doAddCondition(player, v[tonumber(time)])
setPlayerStorageValue(player, 90000, os.time()+time*60)
doPlayerSendTextMessage(player, MESSAGE_INFO_DESCR, "You have been muted for "..time.." minutes.")
elseif (words == "/desmute") then
if param == '' then  doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid param specified.")  return true end  
local player = getPlayerByNameWildcard(param)
if(not player)then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player not found.") return true end
if getCreatureCondition(player, CONDITION_MUTED) == false then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This player is not muted.") return true end
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You desmuted player "..param..".")
doRemoveCondition(player, CONDITION_MUTED)
setPlayerStorageValue(player, 90000, -1)
doPlayerSendTextMessage(player, MESSAGE_INFO_DESCR, "You have been desmuted.")
end
return true  
end

talkactions.xml
Code:
<talkaction log="yes" words="/mute;/desmute" access="2" event="script" value="muteplayer.lua"/>

exemple:

/mute NAME,MINUTES


creaturescript/script

mute_check.lua
PHP:
local v = {}
for k = 1, 100000 do
table.insert(v, createConditionObject(CONDITION_MUTED))
setConditionParam(v[k], CONDITION_PARAM_TICKS, k*1000)
end
function onLogin(cid)
if getPlayerStorageValue(cid, 90000) >= os.time() then
doAddCondition(cid, v[tonumber(getPlayerStorageValue(cid, 90000) - os.time())])
end
return TRUE
end

creaturescript.xml
Code:
<event type="login" name="MutePlayer" event="script" value="mute_check.lua"/>
 
Last edited:
Code:
[0:33:05.718] [Error - TalkAction Interface]
[0:33:05.718] data/talkactions/scripts/mute.lua:onSay
[0:33:05.718] Description:
[0:33:05.718] data/talkactions/scripts/mute.lua:13: attempt to concatenate global 'time' (a nil value)
 
Code:
[0:33:05.718] [Error - TalkAction Interface]
[0:33:05.718] data/talkactions/scripts/mute.lua:onSay
[0:33:05.718] Description:
[0:33:05.718] data/talkactions/scripts/mute.lua:13: attempt to concatenate global 'time' (a nil value)
Code:
local v = {}
for k = 1, 100 do
table.insert(v, createConditionObject(CONDITION_MUTED))
setConditionParam(v[k], CONDITION_PARAM_TICKS, k*60*1000)
end
local time = k*60*1000
function onSay(cid, words, param)
if (words == "/mute") then
local t = string.explode(param, ",") 
    if param == '' then 
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid param specified.") 
        return true
    end 

local player,time,pid = getPlayerByName(t[1]),t[2],getPlayerByNameWildcard(t[1]) 

    if(not pid or (isPlayerGhost(pid) and getPlayerGhostAccess(pid) > getPlayerGhostAccess(cid))) then 
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player with this name doesn\'t exist or is offline.") 
        return true 
    end

doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You muted Player "..t[1].." for "..time.." minutes.")
doAddCondition(player, v[tonumber(time)])
setPlayerStorageValue(player, 90000, os.time()+time*60)
doPlayerSendTextMessage(player, MESSAGE_INFO_DESCR, "You have been muted for "..time.." minutes.")
    elseif (words == "/desmute") then
    if param == '' then 
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid param specified.") 
        return true
    end 

    local player = getPlayerByNameWildcard(param)

    if(not player)then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player not found.")
        return true
    end
   
    if getCreatureCondition(player, CONDITION_MUTED) == false then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This player is not muted.")
        return true
    end
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You desmuted player "..param..".")
        doRemoveCondition(player, CONDITION_MUTED)
        setPlayerStorageValue(player, 90000, -1)
        doPlayerSendTextMessage(player, MESSAGE_INFO_DESCR, "You have been desmuted.")
    end
    return true 
end
 
[10:4:16.627] [Error - TalkAction Interface]
[10:4:16.627] data/talkactions/scripts/mute.lua
[10:4:16.627] Description:
[10:4:16.627] data/talkactions/scripts/mute.lua:6: attempt to perform arithmetic on global 'k' (a nil value)
[10:4:16.627] [Warning - Event::loadScript] Cannot load script (data/talkactions/scripts/mute.lua)
 
Sry i alittle mistake that i didn't realize that time was declared twice this should work
Code:
local v = {}
for k = 1, 100 do
table.insert(v, createConditionObject(CONDITION_MUTED))
setConditionParam(v[k], CONDITION_PARAM_TICKS, k*60*1000)
end
local timea = k*60*1000
function onSay(cid, words, param)

if (words == "/mute") then
local t = string.explode(param, ",")
    if param == '' then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid param specified.")
        return true
    end

local player,time,pid = getPlayerByName(t[1]),t[2],getPlayerByNameWildcard(t[1])

    if(not pid or (isPlayerGhost(pid) and getPlayerGhostAccess(pid) > getPlayerGhostAccess(cid))) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player with this name doesn\'t exist or is offline.")
        return true
    end

doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You muted Player "..t[1].." for "..tonumber(timea).." minutes.")
doAddCondition(player, v[tonumber(time)])
setPlayerStorageValue(player, 90000, os.time()+time*60)
doPlayerSendTextMessage(player, MESSAGE_INFO_DESCR, "You have been muted for "..tonumber(timea).." minutes.")
    elseif (words == "/desmute") then
    if param == '' then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid param specified.")
        return true
    end

    local player = getPlayerByNameWildcard(param)

    if(not player)then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player not found.")
        return true
    end
 
    if getCreatureCondition(player, CONDITION_MUTED) == false then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This player is not muted.")
        return true
    end
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You desmuted player "..param..".")
        doRemoveCondition(player, CONDITION_MUTED)
        setPlayerStorageValue(player, 90000, -1)
        doPlayerSendTextMessage(player, MESSAGE_INFO_DESCR, "You have been desmuted.")
    end
    return true
end
 
Back
Top