PtokaX forum

Archive => Archived 5.1 boards => Help with scripts => Topic started by: CyberChris on 16 August, 2006, 15:20:55

Title: TeamBot
Post by: CyberChris on 16 August, 2006, 15:20:55
Hi people !
I've problem with this script :

Code (lua) Select
-- Show All Registered Users
-- By NightLitch 2003
-- Modded By [fow]CCCL-NL on 27.05.2004
-- Adapted for RoboCop V10
-- Updated to LUA 5 by Pothead
--
-- Command: !crew
-- Command: !showlevel
------------------------------------------------------------
BotName = frmHub:GetHubBotName()
------------------------------------------------------------
NAMES = {
["reg"] = "\r\n\t * LES UTILISATEURS REG *",
["vip"] = "\r\n\t * LES UTILISATEURS VIP *",
["operator"] = "\r\n\t * LES OPERATEURS *",
["master"] = "\r\n\t * LES ADMINISTRATEURS *",

}

function ChatArrival(curUser, data)
if (string.sub(data,1,1) == "<" or string.sub(data,1,5+strlen(sBot)) == "$To: "..sBot) then
data = string.sub(data,1,string.len(data)-1)
local s, e, cmd, args = string.find(data, "^%b<>%s%+(%a+)%s*(.*)")
if not s then return end
cmd = string.lower(cmd)
if (cmd=="crew") then
Msg = "\r\n"
ShowRegistered()
curUser:SendPM(BotName, Msg)
return 1
elseif cmd == "showlevel" then
Msg = "\r\n"
ViewRegs(args)
curUser:SendPM(BotName, Msg)
return 1
end
end
end

function ShowRegistered()
ViewRegs("Master")
ViewRegs("Operator")
ViewRegs("Vip")
ViewRegs("Reg")
Msg = Msg.."\r\n\t**** FIN DE LA LISTE ****"
end

function ViewRegs(Level)
tables = nil
if tonumber(Level) then
if GetProfileName(Level) then
Level = GetProfileName(Level)
tables = GetUsersByProfile(Level)
end
else
tables = GetUsersByProfile(Level)
end
if type(tables) == "table" then
local temp = {}
for index, names in tables do
table.insert(temp, names)
end
table.sort(temp)
if table.getn(temp) == 0 then
Msg = Msg.."\r\n ".."*** Aucun utilisateur avec ce niveau : "..Level.."\r\n"
else
Msg = Msg.."\r\n>>=====================================<<"
Msg = Msg..NAMES[string.lower(Level)]
Msg = Msg.."\r\n>>=====================================<<\r\n"
for i=1,table.getn(temp) do
local _,_,ProfileName = string.find(temp[i],"(%S+)")
if GetItemByName(ProfileName) then
Msg = Msg.." "..i.."\t Connect?\t"..ProfileName.."\r\n"
else
Msg = Msg.." "..i.."\tD?connect?\t\t"..ProfileName.."\r\n"
end
end
Msg = Msg..">>=====================================<<\r\n"
end
else
Msg = Msg.."\r\n ".."*** Aucun utilisateur avec ce niveau : "..Level.."\r\n"
end
end

Can you translate for lua 5.1 please ??
Respect !

CyberChris
Title: Re: TeamBot
Post by: speedX on 16 August, 2006, 15:24:04
already one !showreg script for Lua 5.1 is available.....
Title: Re: TeamBot
Post by: bastya_elvtars on 16 August, 2006, 15:29:30
Try this:

Code (lua) Select
-- Show All Registered Users
-- By NightLitch 2003
-- Modded By [fow]CCCL-NL on 27.05.2004
-- Adapted for RoboCop V10
-- Updated to LUA 5 by Pothead
-- Lua 5.1 and futile string processing removal by bastya_elvtars
--
-- Command: !crew
-- Command: !showlevel
------------------------------------------------------------
BotName = frmHub:GetHubBotName()
------------------------------------------------------------
NAMES = {
["reg"] = "\r\n\t * LES UTILISATEURS REG *",
["vip"] = "\r\n\t * LES UTILISATEURS VIP *",
["operator"] = "\r\n\t * LES OPERATEURS *",
["master"] = "\r\n\t * LES ADMINISTRATEURS *",

}

function ChatArrival(curUser, data)
data = string.sub(data,1,string.len(data)-1)
local cmd, args = string.match(data, "%b<>%s+(%S+)%s*(.*)")
if not s then return end
cmd = string.lower(cmd)
if (cmd=="!crew") then
Msg = "\r\n"
ShowRegistered()
curUser:SendPM(BotName, Msg)
  return 1
elseif cmd == "!showlevel" then
Msg = "\r\n"
ViewRegs(args)
curUser:SendPM(BotName, Msg)
return 1
  end
end

function ShowRegistered()
ViewRegs("Master")
ViewRegs("Operator")
ViewRegs("Vip")
ViewRegs("Reg")
Msg = Msg.."\r\n\t**** FIN DE LA LISTE ****"
end

function ViewRegs(Level)
tables = nil
if tonumber(Level) then
if GetProfileName(Level) then
Level = GetProfileName(Level)
tables = GetUsersByProfile(Level)
end
else
tables = GetUsersByProfile(Level)
end
if type(tables) == "table" then
local temp = {}
for index, names in pairs(tables) do
table.insert(temp, names)
end
table.sort(temp)
if #temp == 0 then
Msg = Msg.."\r\n ".."*** Aucun utilisateur avec ce niveau : "..Level.."\r\n"
else
Msg = Msg.."\r\n>>=====================================<<"
Msg = Msg..NAMES[string.lower(Level)]
Msg = Msg.."\r\n>>=====================================<<\r\n"
for _,v in ipairs(temp) do
local ProfileName = string.match(v,"(%S+)")
if GetItemByName(ProfileName) then
Msg = Msg.." "..i.."\t Connect?\t"..ProfileName.."\r\n"
else
Msg = Msg.." "..i.."\tD?connect?\t\t"..ProfileName.."\r\n"
end
end
Msg = Msg..">>=====================================<<\r\n"
end
else
Msg = Msg.."\r\n ".."*** Aucun utilisateur avec ce niveau : "..Level.."\r\n"
end
end
Title: Re: TeamBot
Post by: CyberChris on 16 August, 2006, 15:55:40
Hi bastya_elvtars  ,
I've try ...But nothing (no results and no bugs founds)
for info :
I use Ptokax 0.3.5.1 with leviathan script.

CyberChris
Title: Re: TeamBot
Post by: 6Marilyn6Manson6 on 16 August, 2006, 17:58:12
---Original author: Mutor, original source: LUA4
---comands: !listreg / !listvip / !listop / !listmod / !listmaster / !listfounder / !listall
--// Update To Lua 5.1.1 by 6Marilyn6Manson6    27/07/2006
--// Change commands: !listreg / !listvip / !listope / !listmod / !listmas / !listntf / !listall
--// Thanks bastya_elvtars for small help with return commands :)    16/08/2006
----------------------------------------------------
----------------------------------------------------
Prefix = "!" -- ! + # ? -
BotName = "[ITA]RegList" -- frmHub:GetHubBotName(),
----------------------------------------------------
UseCMD = { -- What profile you want blocked 1/yes 0/no
[0] = 1, -- Master
[1] = 0, -- Operator
[2] = 0, -- VIP
[3] = 0, -- Registered
[4] = 1, -- Moderator
[5] = 1, -- Netfounder
[-1] = 0, -- Unregistered
}
----------------------------------------------------
function Main()
if BotName ~= frmHub:GetHubBotName() then
frmHub:RegBot(BotName)
end
end
----------------------------------------------------
function ChatArrival(user,data)
if user.bOperator then
if UseCMD[user.iProfile]==1 then
local s,e,cmd = string.find(data, "%b<>%s+(%S+)(%S+)")
if cmd == Prefix.."listreg" then
Show(user,"ReG")
return 1
elseif cmd == Prefix.."listvip" then
Show(user,"ViP")
return 1
elseif cmd == Prefix.."listope" then
Show(user,"OPeRaToR")
return 1
elseif cmd == Prefix.."listmod" then
Show(user,"MoDeRaToR")
return 1
elseif cmd == Prefix.."listmas" then
Show(user,"MaSTeR")
return 1
elseif cmd == Prefix.."listntf" then
Show(user,"NeTFoundeR")
return 1
elseif cmd == Prefix.."listall" then
Show(user,"ReG")
Show(user,"ViP")
Show(user,"OPeRaToR")
Show(user,"MoDeRaToR")
Show(user,"MaSTeR")
Show(user,"NeTFoundeR")
return 1
end
end
else
end
end
----------------------------------------------------
function Show(user,which)
user:SendPM(BotName,"")
user:SendPM(BotName,"")
user:SendPM(BotName,"\t\tList for Profile - "..which)
user:SendPM(BotName,"\t---<>--------------------------------------------------<>--")
local aux,usr
for aux, usr in pairs(GetUsersByProfile(which)) do
user:SendPM(BotName,"\t\t"..usr)
end
user:SendPM(BotName,"")
user:SendPM(BotName,"")
end
----------------------------------------------------
--// 6Marilyn6Manson6


Try this
Title: Re: TeamBot
Post by: bastya_elvtars on 16 August, 2006, 18:11:35
Quote from: CyberChris on 16 August, 2006, 15:55:40
Hi bastya_elvtars  ,
I've try ...But nothing (no results and no bugs founds)
for info :
I use Ptokax 0.3.5.1 with leviathan script.

Umm, the pattern capture was b0rked, edited the above post.
Title: Re: TeamBot
Post by: CyberChris on 16 August, 2006, 18:37:40
It working fine 6Marilyn6Manson6 !
But , when i tape !reg  (exemple) , in chat we see this command : [19:30:49]<UserX> !listreg


But i'm happy , Thank's  ;)

CyberChris
Title: Re: TeamBot
Post by: 6Marilyn6Manson6 on 16 August, 2006, 20:54:55
Quote from: CyberChris on 16 August, 2006, 18:37:40
It working fine 6Marilyn6Manson6 !
But , when i tape !reg  (exemple) , in chat we see this command : [19:30:49]<UserX> !listreg


But i'm happy , Thank's  ;)

CyberChris

Post update with your request. Thanks bastya_elvtars for help :)