READ THE RULES
0 Members and 1 Guest are viewing this topic.
--[[ SpareChat 1.0b LUA 5.11 [Strict][API 2] By Mutor 07/11/07 Requested by M_S o s a Yet another chat app, this one is light in function but small, per request. (~35k Mem) +Changes from 1.0 10/21/07 ~Converted for the new PtokaX API -Removed RoboCop profiles]]local ChatName = "[ChatRoom]"--[[ Set your profiles here. [yours may be different] [#] = 0 = disabled/1=enabled for chat,]]local ChatProfiles = { [-1] = 0, -- Unregistered User [Technically, a non profile] [0] = 1, -- Master [1] = 1, -- Operator [2] = 0, -- Vip [3] = 1, -- Reg}--Set a few local variables for the script [edit only the timer interval 'Int']local Mem,Time,Int,Timer = 0,os.time(),5function OnStartup() local x = true for i,v in ipairs(Core.GetBots()) do if ChatName == v.sNick then x = false break end end if x then local prt = SetMan.GetString(3) or "411" Core.RegBot(ChatName,SetMan.GetString(0).." Chat Room", SetMan.GetString(2)..":"..prt:gsub("%;.+$",""),true) end Timer = TmrMan.AddTimer(Int*60000)endOnTimer = function(Id) if Timer == Id then if collectgarbage("count") > (Mem * 1.05) then collectgarbage("collect") end if ((os.time() - Time) / 60) > Int then TmrMan.RemoveTimer(Timer) Timer = nil end endendToArrival = function(user,data) local _,_,to = data:find("^$To: (%S+) From:") if to and to:lower() == ChatName:lower() then if ChatProfiles[user.iProfile] and ChatProfiles[user.iProfile] == 1 then Time = os.time() local _,_,msg = data:find("%b<> (.+)|$") if msg then SendToChat(user,msg) end if not Timer then Timer = TmrMan.AddTimer(Int*60000) end OnTimer(Timer) else return Core.SendPmToNick(user.sNick,ChatName,"Sorry "..user.sNick..", this chat is for ".. "select profiles only. Your message has not been sent. :("),1 end endendfunction SendToChat(user,msg) local Tab = Core.GetOnlineUsers() for i,usr in ipairs(Tab) do if ChatProfiles[usr.iProfile] and ChatProfiles[usr.iProfile] == 1 then if usr.sNick:lower() ~= user.sNick:lower() then Core.SendToNick(usr.sNick,"$To: "..usr.sNick.." From: "..ChatName.. " $<"..user.sNick.."> " ..msg.."|") end end end collectgarbage("collect")endcollectgarbage("collect")Mem = collectgarbage("count")