PtokaX forum

Archive => Archived 4.0 boards => Help with Lua 4 scripts => Topic started by: Spoonlord312 on 10 March, 2005, 21:34:28

Title: Registered Users ONLY Message In Main Chat
Post by: Spoonlord312 on 10 March, 2005, 21:34:28
Hi guys i am fairly new to scripting in lua and i am also trying to write my own script - the two of which don't go well together! Anyway, i am trying to write a script that will allow registered users to send a msg to the main chat that only regged users will receive. here is what i have:

-----------------------

Comm = "!regm1"
Bot = "RegMSG"

function Main()
end

function DataArrival(user, data)
   xyz = 0
   s,e,cmd,msg = strfind(data,"%b<>%s+(%S+)%s+(.+)")
   if (cmd == "!regm2") then
      cmd = "!regm1"
      xyz = 1
   end
   if (cmd == Comm) then
      for i = 0, zgetn(profiles) - 1 do
         local tmp = strupper(profiles)
         local users = GetUsersByProfile(tmp)
         local n = zgetn(users);
         total = total + n
         for j = 0, n - 1 do
            nick = users[j]
            if nick.iProfile ~= -1 then
               if xyz == 0 then
                  nick:SendData(nick, "<<<"..Bot.." From: "..user.sName..">>> "..msg)
               else
                  nick:SendData(nick, "<<<"..Bot.." From: Anonymous>>> "..msg)
               end
            end
         end
      end
      return 1
   end
   
end

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

----------------------

I started using Mutor's whisper script and tried to convert it to this... the hub says there are no errors in the script but messages don't ever show up. Could someone please see if you can figure it out or show me a script that works?
I would certainly appreciate any help you can give me...
Title:
Post by: Pothead on 10 March, 2005, 21:39:19
Change DataArrival  to ChatArrival , change strfind  to string.find  , and strupper  to string.upper  . :)
Title: hmm
Post by: Spoonlord312 on 10 March, 2005, 21:49:47
i did that - now the messages are showing up but its not doing what i want it too.

when they enter:     !regm1 hello
that shows up to everyone instead of "hello" showing up to only regged users.

Any suggestions here?