adrianoswatt

/mute & /desmute

Feb 19th, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.20 KB | None | 0 0
  1. function onSay(cid, words, param, channel)
  2.     if(param == '') then
  3.         doPlayerSendTextMessage(cid, 21, "[Ex: /mute NAME, Seconds OR /desmute NAME]")
  4.         return true
  5.     end
  6.     local t = string.explode(param, ",")
  7.     player = getPlayerByName(t[1])
  8.     if (words == "/mute") or (words == "!mute") then
  9.         if(not t[2] or t[2] == '') then
  10.             doPlayerSendTextMessage(cid, 21, "Example [/mute NAME, Seconds]")
  11.         return true
  12.         end
  13.         if t[2] then
  14.             tempo = tonumber(t[2]*1000)
  15.             local condition = createConditionObject(CONDITION_MUTED)
  16.             setConditionParam(condition, CONDITION_PARAM_TICKS, tempo)
  17.             local infight = createConditionObject(CONDITION_INFIGHT)
  18.             setConditionParam(infight, CONDITION_PARAM_TICKS, tempo)
  19.            
  20.             if(isPlayer(player) == TRUE and getPlayerGroupId(cid) > getPlayerGroupId(player) and getPlayerFlagValue(player, PLAYERFLAG_CANNOTBEMUTED) == false) then
  21.                 doAddCondition(player, condition)
  22.                 doAddCondition(player, infight)
  23.                 doPlayerSendTextMessage(player, MESSAGE_STATUS_WARNING, "You have been muted by " .. getPlayerName(cid) .. " for " .. t[2] .. " seconds.")
  24.                 doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, getCreatureName(player) .. " has been muted for " .. t[2] .. " seconds.")
  25.             else
  26.                 doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. t[1] .. " is not currently online or cannot be muted.")
  27.             end
  28.         end
  29.     elseif (words == "/desmute") or (words == "!desmute") then
  30.         if(isPlayer(player) == TRUE and getPlayerGroupId(cid) > getPlayerGroupId(player))then
  31.             if getCreatureCondition(player, CONDITION_MUTED) then
  32.                 doRemoveCondition(player, CONDITION_MUTED)
  33.                 doRemoveCondition(player, CONDITION_INFIGHT)
  34.                 doPlayerSendTextMessage(player, MESSAGE_STATUS_WARNING, "You have been desmuted by " .. getPlayerName(cid) .. ".")
  35.                 doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, getCreatureName(player) .. " has been desmuted.")
  36.             else
  37.                 doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. t[1] .. " is not muted.")
  38.             end
  39.         else
  40.             doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. t[1] .. " is not currently online or cannot be muted.")
  41.         end
  42.        
  43.     end  
  44.     return true
  45. end
Advertisement
Add Comment
Please, Sign In to add comment