PtokaX forum

Archive => Archived 5.0 boards => Finished Scripts => Topic started by: Zigurds on 03 March, 2005, 21:44:13

Title: Gag, ungag, showgag script
Post by: Zigurds on 03 March, 2005, 21:44:13
work

code-----------------------------------------

---------------------------------------------------------------------------------------------------------------------
--   MUTE
--cmd gag work to cmd ungag
---------------------------------------------------------------------------------------------------------------------

sBot = "-MUTE-"

MUTE = {}

function ChatArrival(user, data)

   if (string.sub(data,1,1) == "<") then
   data=string.sub(data,1,string.len(data)-1)
   s,e,cmd = string.find(data,"%b<>%s+(%S+)")
      if ((cmd=="+gag")) and user.bOperator then
         DoMute(user, data) return 1

   elseif cmd == "+showgag" and user.bOperator then
      function MUTED()
      local disp = ""
         for index, value in MUTE do
         local line = index
         disp = disp.."\t ? "..line.."\r\n"
         end
         return disp
         end
      user:SendPM(sBot,"\r\n\r\n\t\t\t\t\t(? ?.??.->   These are the muted   <-.??.???)\r\n\r\n"..MUTED().."|")
      return 1
         
      elseif ((cmd=="+ungag")) and user.bOperator then
         DoUnMute(user, data) return 1
      end
      if string.sub(data,1,1) == "<" then
         if MUTE[user.sName] == 1 then return 1
         end
      end
   end
end

function DoMute(user, data)
local s,e,cmd,vic = string.find(data,"%b<>%s+(%S+)%s+(%S+)")
local victim = GetItemByName(vic)
   if victim == nil then
      user:SendData(sBot,"User is not in the hub...")
   else
      if MUTE[victim.sName] == nil then
         MUTE[victim.sName] = 1
         SendToAll(sBot,"He, he "..victim.sName..", you txt not speak ;)")
      end
   end
end

function DoUnMute(user, data)
local s,e,cmd,vic = string.find(data,"%b<>%s+(%S+)%s+(%S+)")
local victim = GetItemByName(vic)
   if victim == nil then
      user:SendData(sBot,"User is not in the hub...")
   else
      if MUTE[victim.sName] == 1 then
         MUTE[victim.sName] = nil;
         SendToAll(sBot, victim.sName.." you txt allow speak ;) ")
      end
   end
end
Title:
Post by: ConejoDelMal on 18 May, 2005, 06:14:06
Can someone add a profile protection to this script?

Like, Op's can be immune, and vip's can only gag reg/unreg
Title:
Post by: jiten on 18 May, 2005, 10:41:33
Something like this?
---------------------------------------------------------------------------------------------------------------------
-- Mute script
-- changed a bit by jiten
---------------------------------------------------------------------------------------------------------------------

sBot = "-MUTE-"

tMute = {}

AllowedProfiles = {
-- [Gagger Profile Number] = {
-- [Gagged Profile Number] = 0 --> can't gag victim; 1 --> can gag victim
-- },

[1] = { [1] = 1, [2] = 1, [3] = 1, [4] = 0, [5] = 0, [0] = 0, [-1] = 1, },
[2] = { [1] = 0, [2] = 1, [3] = 1, [4] = 0, [5] = 0, [0] = 0, [-1] = 1, },
[4] = { [1] = 1, [2] = 1, [3] = 1, [4] = 1, [5] = 0, [0] = 0, [-1] = 1, },
[5] = { [1] = 1, [2] = 1, [3] = 1, [4] = 1, [5] = 1, [0] = 1, [-1] = 1, },
[0] = { [1] = 1, [2] = 1, [3] = 1, [4] = 1, [5] = 0, [0] = 1, [-1] = 1, },
}

function ChatArrival(user, data)
local data=string.sub(data,1,-2)
local s,e,cmd = string.find(data,"%b<>%s+(%S+)")
if AllowedProfiles[user.iProfile] or user.bOperator then
if ((cmd=="+gag")) then
DoMute(user, data) return 1
elseif cmd == "+showgag" then
local disp = ""
for index, value in tMute do
local line = index
disp = disp.."\t ? "..line.."\r\n"
end
user:SendPM(sBot,"\r\n\r\n\t\t\t\t\t(? ?.??.-> These are the muted <-.??.???)\r\n\r\n"..disp.."|")
return 1
elseif ((cmd=="+ungag")) then
DoUnMute(user, data) return 1
end
end
if tMute[user.sName] == 1 then return 1 end
end

function DoMute(user, data)
local s,e,cmd,vic = string.find(data,"%b<>%s+(%S+)%s+(%S+)")
local victim = GetItemByName(vic)
if victim == nil then
user:SendData(sBot,"User is not in the hub...")
else
if AllowedProfiles[user.iProfile][victim.iProfile] == 1 then
if tMute[victim.sName] == nil then
tMute[victim.sName] = 1
SendToAll(sBot,"He, he "..victim.sName..", you txt not speak ;)")
end
else
if not victim.bRegistered then
user:SendData(sBot,"*** Error: You can't gag Users!")
else
user:SendData(sBot,"*** Error: You can't gag "..GetProfileName(victim.iProfile).."s!")
end
end
end
end

function DoUnMute(user, data)
local s,e,cmd,vic = string.find(data,"%b<>%s+(%S+)%s+(%S+)")
local victim = GetItemByName(vic)
if victim == nil then
user:SendData(sBot,"User is not in the hub...")
else
if tMute[victim.sName] == 1 then
tMute[victim.sName] = nil;
SendToAll(sBot, victim.sName.." you txt allow speak ;) ")
end
end
end
Title:
Post by: ConejoDelMal on 18 May, 2005, 11:06:01
well, it looks exactly what i asked for :P

Thx a lot, and once again jiten  :]

I will try it out...

*edited*

Tried it now... it works great, but the immune profiles table doesnt makes much sense...if i make a profile immune, the script wont work on it, and the user anyway gets gagged by ptokax inbuilt cmd's, thats why i had so much trouble trying to make it on my own...

but thx a lot, with the allowed profile table its just perfect
Title:
Post by: jiten on 18 May, 2005, 12:06:42
QuoteOriginally posted by [AT]conejodelmal
well, it looks exactly what i asked for :P

Thx a lot, and once again jiten  :]

I will try it out...

*edited*

Tried it now... it works great, but the immune profiles table doesnt makes much sense...if i make a profile immune, the script wont work on it, and the user anyway gets gagged by ptokax inbuilt cmd's, thats why i had so much trouble trying to make it on my own...

but thx a lot, with the allowed profile table its just perfect
That was exactly my doubt when I was editing the script.
It's way better to use only the AllowedProfile table as it really doesn't make sense :D
So, I updated the first script with something more logical.

Cheers
Title:
Post by: ConejoDelMal on 18 May, 2005, 12:48:12
Its just perfect, thx again