Nead help with !showreg
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

Nead help with !showreg

Started by Janhouse, 07 May, 2004, 20:09:49

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Janhouse

Hi! A got this script in forum but it is not so good.

It shows all registred users but it don't show are they online. In robocop script shows it. So could you help me?

Here is the script:
-- !showreg
-- !showlevel  - level may be name or number

BotName = "!!![OP]BotZ"

NAMES = {
   ["reg"] = "\r\n	:::::::::::::::::::::::::::::::::::::             Profils REG          :::::::::::::::::::::::::::::::::::::",
   ["vip"] = "\r\n	:::::::::::::::::::::::::::::::::::::             Profils VIP          :::::::::::::::::::::::::::::::::::::",
   ["operator"] = "\r\n	:::::::::::::::::::::::::::::::::::::             Profils OP             :::::::::::::::::::::::::::::::::::::",
   ["moderator"] = "\r\n	:::::::::::::::::::::::::::::::::::::        Profils Moderators      :::::::::::::::::::::::::::::::::::::",
   ["master"] = "\r\n	:::::::::::::::::::::::::::::::::::::          Profils Masters         :::::::::::::::::::::::::::::::::::::"
   }

function DataArrival(curUser, data)
	if strsub(data, 1, 1) ~= "<" then return end
   data = strsub(data, 1, (strlen(data)-1))
	local s, e, cmd, args = strfind(data, "^%b<>%s%!(%a+)%s*(.*)")
	if not s then return end
	cmd = strlower(cmd)
	if (cmd=="showreg") 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\tSaraksta beigas"
end

function ViewRegs(Level)
   table = nil
   if tonumber(Level) then
      Level = GetProfileName(Level)
      table = GetUsersByProfile(Level)
   else
      table = GetUsersByProfile(Level)
   end
   if type(table) == "table" then
      local temp = {}
      for index, names in table do
         tinsert(temp, names)
      end
      sort(temp)
      if getn(temp) == 0 then
         Msg = Msg.."\r\n ".."Lietotaji ar profilu "..Level.." nav atrasti. \r\n"
      else
         Msg = Msg..NAMES[strlower(Level)]
         Msg = Msg.."\r\n	:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::"
         for i=1,getn(temp) do 
            local _,_,ProfileName = strfind(temp[i],"(%S+)")
            Msg = Msg.."\r\n "..i..".  "..ProfileName..""
         end
         Msg = Msg.."\r\n	:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::"
         Msg = Msg.."\r\n "
      end
   else
      Msg = Msg.."\r\n ".."Lietotaji ar profilu  "..Level.." nav atrasti. \r\n"
   end
end

Xico

Try this:

-- !showreg
-- !showlevel  - level may be name or number

BotName = "!!![OP]BotZ"

NAMES = {
   ["reg"] = "\r\n	:::::::::::::::::::::::::::::::::::::             Profils REG          :::::::::::::::::::::::::::::::::::::",
   ["vip"] = "\r\n	:::::::::::::::::::::::::::::::::::::             Profils VIP          :::::::::::::::::::::::::::::::::::::",
   ["operator"] = "\r\n	:::::::::::::::::::::::::::::::::::::             Profils OP             :::::::::::::::::::::::::::::::::::::",
   ["moderator"] = "\r\n	:::::::::::::::::::::::::::::::::::::        Profils Moderators      :::::::::::::::::::::::::::::::::::::",
   ["master"] = "\r\n	:::::::::::::::::::::::::::::::::::::          Profils Masters         :::::::::::::::::::::::::::::::::::::"
   }
function Main()
	frmHub:RegBot(BotName)
end

function DataArrival(curUser, data)

	if strsub(data, 1, 1) ~= "<" then 
		return 
	end
   data = strsub(data, 1, (strlen(data)-1))
	local s, e, cmd, args = strfind(data, "^%b<>%s%!(%a+)%s*(.*)")
	if not s then 
		return 
	end
	cmd = strlower(cmd)
	if (cmd=="showreg") 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\tSaraksta beigas"
end

function ViewRegs(Level)
   table = nil
   if tonumber(Level) then
      Level = GetProfileName(Level)
      table = GetUsersByProfile(Level)
   else
      table = GetUsersByProfile(Level)
   end
   if type(table) == "table" then
      local temp = {}
      for index, names in table do
         tinsert(temp, names)
      end
      sort(temp)
      if getn(temp) == 0 then
         Msg = Msg.."\r\n ".."Lietotaji ar profilu "..Level.." nav atrasti. \r\n"
      else
         Msg = Msg..NAMES[strlower(Level)]
         Msg = Msg.."\r\n	:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::"
         for i=1,getn(temp) do 
            local _,_,ProfileName = strfind(temp[i],"(%S+)")
            
            -- / Added by Xico
            local sOnLine ="Off line"
            if GetItemByName(ProfileName) then
            	sOnLine ="On line"
            end
            -- / end
            
            Msg = Msg.."\r\n "..i..".  "..ProfileName.."\t\t"..sOnLine..""
         end
         Msg = Msg.."\r\n	:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::"
         Msg = Msg.."\r\n "
      end
   else
      Msg = Msg.."\r\n ".."Lietotaji ar profilu  "..Level.." nav atrasti. \r\n"
   end
end

Corayzon

this might seem like a handfull but its relyable and sercure...hope it helps ;)

-- None Editable Settings
prefixs = {}

-- Editable Settings
sBot = "Reglist-Bot"

prefixs["+"] = 1
prefixs["!"] = 1

cmdreglist = "reglist"								-- the command that the reglist will show on
cmdreglistlevel = 3								-- the profile level that is needed to do the command
cmdreglistusage = "profilename"						-- the usage string sent back to user when args are not inputted

reglistmsg = "#new#new#tabR e g i s t e r e d   U s e r   L i s t#new#new"			-- The title of the reglist message
reglistformat = "#tab#tab#user#new"						-- The format at which the reglist adds the usernames
reglisterr = "***You are unable to view registered users for a profile that doesn't exist!"		-- The error returned to the user when the reglist isnt found

-- Scripts Start
function DataArrival(user, data)

	data = strsub(data, 1, strlen(data) -1) 
	local _,_,cmd=strfind(data, "%b<>%s+(%S+)")

	if cmd ~= nil and prefixs[strsub(cmd,1,1)] == 1 then
		cmd = strlower(cmd)
		cmd = strsub(cmd, 2, strlen(cmd))

		if cmd == cmdreglist then
			if doRegisterCommand(user, data, cmd) then return 1 end
		end
	end
end

function doRegisterCommand(user, data, cmd)
	if cmd == cmdreglist then
		if cmdreglistlevel > user.iProfile then
			showRegList(user, data)
		end
		return 1
	end
end

function showRegList (user,data)
	local _,_, pName = strfind(data, "%b<>%s+%S+%s+(.*)" )
	if pName ~= nil  then
		local tUsers = GetUsersByProfile(pName)
		local iCount = zgetn(tUsers)
		if iCount == 0 then user:SendData(sBot, translateString(reglisterr, {["#user"] = user.sName, ["#profile"] = pName})) return end
		local sOut = translateString(reglistmsg, {["#user"] = user.sName, ["#profile"] = pName})
		for iIndex = 0, iCount - 1 do
			sOut = sOut .. translateString(reglistformat, {["#user"] = tUsers[iIndex], ["#profile"] = pName})
		end
		user:SendPM(sBot, sOut)
	else
		sendUsage(user, cmdreglist, "profilename")
	end
end

function translateString(sString, tTranslations)

	local _ = ""
	sString, _ = gsub(sString, "#hd" ,frmHub:GetHubDescr())
	sString, _ = gsub(sString, "#uc", frmHub:GetUsersCount())
	sString, _ = gsub(sString, "#hb", frmHub:GetHubBotName())
	sString, _ = gsub(sString, "#mu", frmHub:GetMaxUsers())
	sString, _ = gsub(sString, "#ms", convertShareSize(frmHub:GetMinShare(), 2))
	sString, _ = gsub(sString, "#op", frmHub:GetOpChatName())
	sString, _ = gsub(sString, "#ra", frmHub:GetRedirectAddress() or "none")
	sString, _ = gsub(sString, "#hs", convertShareSize(frmHub:GetCurrentShareAmount()))
	sString, _ = gsub(sString, "#h", frmHub:GetHubName())
	sString, _ = gsub(sString, "#new", "\r\n")
	sString, _ = gsub(sString, "#tab", "\t")

	if tTranslations ~= nil then
		for sConvertFrom, sConvertTo in tTranslations do
			sString, _ = gsub(sString, sConvertFrom, sConvertTo)
		end
	end
	return sString
end

function convertShareSize(iSize, iSkip)

	local tList = {[1] = "B", [2] = "kB", [3] = "MB", [4] = "GB", [5] = "TB"}
	local iCount = 1
	if iSkip ~= nil then iCount = iSkip + 1 end

	while iSize > 1024 do
		if iSize >= 1024 then 
			iSize = iSize / 1024 
			iCount = iCount + 1
		end
	end

	local sChar = ""
	local iLen = strlen(iSize)
	local iStart = iLen

	if strfind(iSize, ".") then
 		while sChar ~= "." do
			sChar = strsub(iSize, iStart, iStart)
			iStart = iStart - 1
			if sChar ~= "." then iLen = iLen - 1 end
			if sChar == "" or sChar == nil then
				iLen = strlen(iSize) - 2
				break
			end
		end
	end

	iSize = strsub(iSize,1,iLen + 2)
	return iSize .. " " .. tList[iCount]
end

function zgetn(tTable)
	return (tTable and (getn(tTable) + (tTable[0] and 1 or 0))) or 0;
end

Janhouse

Thanx Xico but it isn't working. And I don't know why.

Xico

Hi Janhouse

I'm sorry, I did test it. Was working.
Can you tell us a litle more about the error, debug messages, anything ...

Janhouse

It shows

QuoteSyntax error: expected;
  last token read: `&' at line 68 in string "-- !showreg
..."

Can you fix it?  ?(

Madman

The problem is here

Msg = Msg..& quot;\r\n

And you made it.... becuse when i copyed the script you posted, i got the same error you did so, its not xico faults... something probarly got wrong when you posted the script.....

All we have to do i to figer out what the "& quot;" should bee insteaad..

sorry for my bad english...i am swedish =) and not so good at spelling
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

Optimus

mm, strange a posted a Update but got the same results. Even posted it in other formats the [code] thingy but also same results. Still places  .. & quot .. in the lines

Janhouse

Please! Can somebody fix it?  ?(

nErBoS

#9
Hi,

Fixed..

------------------BEGINING OF CODE-------------------
-- !showreg
-- !showlevel - level may be name or number

BotName = "!!![OP]BotZ"

NAMES = {
   ["reg"] = "\r\n   :::::::::::::::::::::::::::::::::::::             Profils REG          :::::::::::::::::::::::::::::::::::::",
   ["vip"] = "\r\n   :::::::::::::::::::::::::::::::::::::             Profils VIP          :::::::::::::::::::::::::::::::::::::",
   ["operator"] = "\r\n   :::::::::::::::::::::::::::::::::::::             Profils OP             :::::::::::::::::::::::::::::::::::::",
   ["moderator"] = "\r\n   :::::::::::::::::::::::::::::::::::::        Profils Moderators      :::::::::::::::::::::::::::::::::::::",
   ["master"] = "\r\n   :::::::::::::::::::::::::::::::::::::          Profils Masters         :::::::::::::::::::::::::::::::::::::"
   }
function Main()
   frmHub:RegBot(BotName)
end

function DataArrival(curUser, data)

   if strsub(data, 1, 1) ~= "<" then
      return
   end
   data = strsub(data, 1, (strlen(data)-1))
   local s, e, cmd, args = strfind(data, "^%b<>%s%!(%a+)%s*(.*)")
   if not s then
      return
   end
   cmd = strlower(cmd)
   if (cmd=="showreg") 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\tSaraksta beigas"
end

function ViewRegs(Level)
   table = nil
   if tonumber(Level) then
      Level = GetProfileName(Level)
      table = GetUsersByProfile(Level)
   else
      table = GetUsersByProfile(Level)
   end
   if type(table) == "table" then
      local temp = {}
      for index, names in table do
         tinsert(temp, names)
      end
      sort(temp)
      if getn(temp) == 0 then
         Msg = Msg.."\r\n ".."Lietotaji ar profilu "..Level.." nav atrasti. \r\n"
      else
         Msg = Msg..NAMES[strlower(Level)]
         Msg = Msg.."\r\n\t:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::"
         for i=1,getn(temp) do
            local _,_,ProfileName = strfind(temp,"(%S+)")
           
            -- / Added by Xico
            local sOnLine ="Off line"
            if GetItemByName(ProfileName) then
               sOnLine ="On line"
            end
            -- / end
           
            Msg = Msg.."\r\n "..i..".  "..ProfileName.."\t\t"..sOnLine..""
         end
    Msg=Msg.."\r\n\t:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::"
         Msg = Msg.."\r\n "
      end
   else
      Msg = Msg.."\r\n ".."Lietotaji ar profilu  "..Level.." nav atrasti. \r\n"
   end
end
------------------END OF CODE-------------------

Best regards, nErBoS
--## nErBoS Spot ##--

Madman

no... still same error

Syntax error: expected;
  last token read: `&' at line 68 in file `D:\Program\Hub\PtokaX-0.330\scripts\Showreg.lua'
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

nErBoS

Hi,

This is the forum making this error, where you have this
"& quot;" put this "

There is two places with that.

Best regards, nErBoS
--## nErBoS Spot ##--

Madman

Yup, that fixed the problem...
I should have known, that it was supose to be " and not & quot;

Well it , works fine now...

 :rolleyes:
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

SMF spam blocked by CleanTalk