PtokaX forum

Archive => Archived 5.1 boards => Finished Scripts => Topic started by: Herodes on 11 September, 2006, 11:33:04

Title: :OpInterCom v4: | Mainchat Op chat
Post by: Herodes on 11 September, 2006, 11:33:04
This allows Operators to chat in the mainchat while others can't see,... It is an old script of mine I revamped in the weekend--- OpInterCom v4
--- by Herodes
--------- --------- --------- --------- --------- --------- ---------
--- Provides an easy way to communicate in the main chat for operators ...
--- Who needs OpChat when you have InterCom ... lol
--- Just type: " [-]  " in the MainChat ...
--- Note : You DO need the ' [-] ' .. :)
--------- --------- --------- --------- --------- --------- ---------
--- 10 / 8 - 2004
--- added ' [+] ' for going into permanent OpsOnly mode..
--- added ' [=] ' for going out of OpsOnly mode...
--- added ' [?] ' for listing the Ops in OpsOnly mode...
--------- --------- --------- --------- --------- --------- ---------
--- 2 / 3 - 2005
--- converted to Lua 5 for the latest PtokaX
--------- --------- --------- --------- --------- --------- ---------
--- 15 / 3 - 2005
--- added right-click menu ( request by AMediaMan )
--------- --------- --------- --------- --------- --------- ---------
--- 28/3 - 2005
--- changed [-] mode switches does the inverse than your mode ( OpsOnly -> Normal and reverse )
--- added [!]    to talk to a single person ;) ( request by TimeTraveler )
--------- --------- --------- --------- --------- --------- ---------
--- 11/9 - 2006
--- changed the structure of the script
--- made it compatible for latest PtokaX
--- Using Lua 5.1.1
--------- --------- --------- --------- --------- --------- ---------

tCops = {}
--&#124|
function OpConnected(user)
if user.bUserCommand then
user:SendData("$UserCommand 1 3 :InterCom:\\OpsOnly Mode\\ON$<%[mynick]> [+]&#124")
user:SendData("$UserCommand 1 3 :InterCom:\\OpsOnly Mode\\OFF$<%[mynick]> [=]&#124")
user:SendData("$UserCommand 1 3 :InterCom:\\OpsOnly Msg$<%[mynick]> [-]%[line:Enter your msg here:]&#124")
user:SendData("$UserCommand 1 2 :InterCom:\\WhisperToUser$<%[mynick]> [!] %[nick] %[line:Enter your msg here:]&#124")
user:SendData("$UserCommand 1 3 :InterCom:\\List OpsOnly Opers$<%[mynick]> [?]&#124")
user:SendData(":InterCom-[v4]:", "Rightclick menu for InterCom[v4] is available...")
end
end

function ChatArrival ( oper, msg )
if ( oper.bOperator ) then
local s, e, txt = string.find(msg, "%b<>%s+(.+)")
tActions = {
['[-]'] = function ( oper, data )
if (tCops[oper.sName] == 1) then
SendToAll( oper.sName, data );
elseif ( not tCops[oper.sName] ) then
SendToOps('OpsOnly', '['..oper.sName..'] '..data )
end
return 1;
end,
['[!]'] = function( oper, data )
local who, what = string.match( data, "%s*(%S*)%s*(.*)" )
local w = GetItemByName(who)
if w then
w:SendData('Whisper from '..oper.sName..': '..what )
oper:SendData('Whispered to '..who..': '..what)
else
oper:SendData('There is no user named '..who..',... try again.' )
end
return 1;
end,
['[+]'] = function ( oper )
if (tCops[oper.sName] == 1) then
oper:SendData("OpsOnly", "You are in OpsOnly mode already...")
elseif ( not tCops[oper.sName] ) then
tCops[oper.sName] = 1
oper:SendData("OpsOnly", "You are in OpsOnly mode now ... to go into normal type ' [=] ' ")
SendToOps("OpsOnly", "*** "..oper.sName.." went into OpsOnly mode...")
end
return 1;
end,
['[=]'] = function ( oper )
if ( not tCops[oper.sName] ) then
oper:SendData("OpsOnly", "You were not in OpsOnly mode ...")
elseif (tCops[oper.sName] == 1) then
tCops[oper.sName] = nil
oper:SendData("OpsOnly", "You are in normal mainchat mode now ... be carefull!!!")
SendToOps("OpsOnly", "*** "..oper.sName.." is in normal chat mode now")
end
return 1;
end,
['[?]'] = function ( oper )
local msg = ''
for name, v in pairs( tCops ) do
msg = '\r\n\t     - '..name..msg
end
if msg == '' then
msg = " None are in OpsOnly mode..."
else
msg = "\r\n\t Operators in OpsOnly Mainchat mode :"..msg
end;
oper:SendData("OpsOnly", msg )
return 1;
end,
}
local threefirst = string.sub( txt, 1, 3 )
if tActions[threefirst] then
return tActions[threefirst]( oper, string.sub( txt, 4 ) )
else
if tCops[oper.sName] then
SendToOps( 'OpsOnly', '['..oper.sName..'] '..txt )
return 1
end
end
end
end