PtokaX forum

Archive => Archived 4.0 boards => Help with Lua 4 scripts => Topic started by: Janhouse on 15 April, 2004, 19:43:14

Title: Help me with !showreg
Post by: Janhouse on 15 April, 2004, 19:43:14
I found this script in forums but I don't like it because when I write !showreg, information is shown in main chat window but I want that you can see information in PM.

Here is that script...
-- !showreg
-- !showlevel - level may be name or number

BotName = "LV"

NAMES = {
   ["reg"] = "\r\n                                                    ---Profils Reg---",
   ["vip"] = "\r\n                                                    ---Profils VIP---",
   ["operator"] = "\r\n                                                    ---Profils  Operators---",
   ["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:SendData(BotName, Msg)
return 1
   elseif cmd == "showlevel" then
      Msg = "\r\n"
      ViewRegs(args)
      curUser:SendData(BotName, Msg)
      return 1
end
end

function ShowRegistered()

ViewRegs("MASTER")
ViewRegs("OPERATOR")
ViewRegs("VIP")
ViewRegs("REG")
Msg = Msg.."\r\n\tEnd of List"
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



Please help me. I am newbie in lua scripts.  :rolleyes:
Title:
Post by: plop on 15 April, 2004, 21:15:35
change.

curUser:SendData(BotName, Msg)

for

curUser:SendPM(BotName, Msg)

needs 2 be done on 2 places and your done.

plop
Title:
Post by: Janhouse on 16 April, 2004, 13:22:09
Thank you! I will try.