Author Topic: Master chat don't work  (Read 2918 times)

0 Members and 1 Guest are viewing this topic.

Offline HappyTheMan

  • Member
  • ***
  • Posts: 25
  • Karma: +1/-0
Master chat don't work
« on: 12 September, 2006, 00:52:32 »
Hi there!
I have found the script master chat by hawk. I changed it a bit to be able to create a chat room for OPs and Unregged users only. Problem: when the unregged chats,  OPs get the msg but when one OP chats, the unregged doesn't get the msg. What is weird is that the pb only appears with unregged users. It works fine with vips masters etc.. Of course all my other scripts are turned off.
Here is the script:

Code: [Select]
ChatRoomName = "#Garden_(GUEST-Chat)"
ChatProfiles = {
[-1] = 1, -- Guest
[0] = 1, -- Master
[1] = 1, -- Operator
[2] = 0, -- VIP
[3] = 0, -- Reg
[4] = 0, -- Moderator
[5] = 0, -- NetFounder
}


-- Do not edit below
-- -----------------

function Main()
   frmHub:RegBot(ChatRoomName)
end

function ToArrival(user,data)
s,e,whoTo = string.find(data,"$To:%s+(%S+)")
if whoTo == ChatRoomName then
if ChatProfiles[user.iProfile] == 1 then
s,e,whoTo,from,msg = string.find(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(.+)")
MasterChatRoom(user,msg)
else
user:SendData("$To: "..user.sName.." From: "..ChatRoomName.." $You don't have the right to chat here. Your message has not been sent")
end
end
end

function MasterChatRoom(user,msg)
local AllProfiles = GetProfiles()
local Index, Profile, Index2, Nick
for Index, Profile in AllProfiles do
local Users = GetUsersByProfile(Profile)
for Index2, Nick in Users do
local usr = GetItemByName(Nick)
if usr ~= nil then
if user.sName == usr.sName then
else
if ChatProfiles[usr.iProfile] == 1 then
usr:SendData("$To: "..usr.sName.." From: "..ChatRoomName.." $<"..user.sName.."> " ..msg)
else
return 1
end
end
end
end
end
end

thx for your help :-)

PtokaX forum

Master chat don't work
« on: 12 September, 2006, 00:52:32 »

Offline HappyTheMan

  • Member
  • ***
  • Posts: 25
  • Karma: +1/-0
Re: Master chat don't work
« Reply #1 on: 12 September, 2006, 06:21:51 »
Thx again and again American Idiot. Or maybe i should call you Mentor because you are always the one who reply my topics LOL.
I will study that table thing!
I know its not really the goal of the Masterchat but I prefer modify scripts intsead of just taking new ones because it helps me learning this LUA langage. I am having much fun doing it :-)
Posted on: 12 September 2006, 04:28:42
ok so I wrote this:
Code: [Select]
function ChatRoom(user,msg)
for i,nick in frmHub:GetOnlineUsers() do
if user.sName ~= nick.sName and ChatProfiles[nick.iProfile] == 1 and user.sName ~= nick.sName then
nick:SendData("$To: "..nick.sName.." From: "..ChatRoomName.." $<"..user.sName.."> " ..msg)
end
end
end
but i am affraid of loops of something like that because there isn't any "return 1". But it doesn't seem to eat MBs of memory
Hawk wrote that in his script:
Code: [Select]
function ChatRoom(user,msg)
for i,nick in frmHub:GetOnlineUsers() do
if nick ~= nil then
if user.sName == nick.sName then
else
if ChatProfiles[nick.iProfile] == 1 then
usr:SendData("$To: "..nick.sName.." From: "..ChatRoomName.." $<"..user.sName.."> " ..msg)
else
return 1
end
end
end
end
end
But the line 4 kinds of disturb me: "then else return 1"
then what ? LOL
« Last Edit: 12 September, 2006, 06:25:43 by HappyTheMan »

Offline Samantha

  • Newbie
  • *
  • Posts: 7
  • Karma: +4/-0
Re: Master chat don't work
« Reply #2 on: 13 January, 2007, 19:02:20 »
Code: [Select]
--// Simple MasterChat by NightLitch 2005-03-05
--// Fixed bug with some profile not recieving chat - Blondie? 15/10/2006
--// Added Leviathan support - Blondie? 19/10/2006

MasterChatName = "?Admin-Chat?"

function Main()
frmHub:RegBot(MasterChatName)
end


function ToArrival(user,data)
local s,e,to,from,msg = string.find(data,"%$To:%s+(%S+)%s+From:%s+(%S+)%s+%$%b<>%s+(.*)%|")
if to == VipChatName then
if user.iProfile == 0 or user.iProfile == 5 or user.iProfile == 6 then
MasterChat(user,msg)
else
SendPmToNick(user.sName,MasterChatName, "*** You don't have the privileges to talk in this chat.")
return 1
end
end
end

function VipChat(user,msg)
for _,profile in pairs(GetProfiles()) do
for _,users in pairs(GetUsersByProfile(profile)) do
if GetItemByName(users) then
if GetItemByName(users).iProfile == 6 or GetItemByName(users).iProfile == 5 or GetItemByName(users).iProfile == 0 then
if GetItemByName(users).sName ~= user.sName then
GetItemByName(users):SendData("$To: "..GetItemByName(users).sName.." From: "..MasterChatName.." $<"..user.sName.."> "..msg)
end
end
end
end
end
end



i hope this is what you are looking and it been tried and tested :)

Offline smeg568

  • Junior Member
  • **
  • Posts: 13
  • Karma: +1/-0
Re: Master chat don't work
« Reply #3 on: 15 January, 2007, 22:57:08 »
I'm probably being stupid,

The profile indicators in ptokax eg:

               [-1] = 1, -- Unreg
               
  • = 1, -- Master
  • [1] = 1, -- Operator
       [2] = 0, -- VIP
       [3] = 0, -- Reg
       [4] = 0, -- Moderator
       [5] = 0, -- NetFounder

    Are the these configurations set in stone?

    Would it be possible to just add another profile  like  [6] = 0, -- Hubowner     (I got a special profile for me only)

    I'm a bit clueless with scripting lol
« Last Edit: 15 January, 2007, 23:05:23 by smeg568 »

Offline CrazyGuy

  • Viking
  • ****
  • Posts: 506
  • Karma: +83/-20
    • ?????=-_The NightHawk_-=?????
Re: Master chat don't work
« Reply #4 on: 15 January, 2007, 23:06:57 »
yes you can:

Quote
GetProfiles()            - Return table with profilenames ... table starting with 1 but real profile number is 0 !
GetProfileIdx(ProfileName)      - Return ProfileNumber or -1 failed
GetProfileName(ProfileNumber)      - Return ProfileName or nil for failed

this small code will throw all profile names plus matching number in mainchat

Code: [Select]
IdentifyProfiles = function()
local sProfiles = "Known profile numbers and names:\n\n"
for k in pairs (GetProfiles()) do
sProfiles = sProfiles.."["..(k-1).."]\t"..GetProfileName((k-1)).."\n"
end
sProfiles = sProfiles.."[-1]\tUnregistered Users\n"
SendToAll(frmHub:GetHubBotName(), sProfiles)
end

result:
Quote
<PtokaX> Known profile numbers and names:

-
  •    Master

- [1]   Operator
- [2]   VIP
- [3]   Reg
- [4]   4
- [-1]   Unregistered Users


hmm, is it just me or does board seem to have trouble displaying  [ 0 ]  (without spaces) ??

Offline smeg568

  • Junior Member
  • **
  • Posts: 13
  • Karma: +1/-0
Re: Master chat don't work
« Reply #5 on: 15 January, 2007, 23:09:40 »
Thanks CG 

I'll have a go at 'tweaking'    ;D

Offline CrazyGuy

  • Viking
  • ****
  • Posts: 506
  • Karma: +83/-20
    • ?????=-_The NightHawk_-=?????
Re: Master chat don't work
« Reply #6 on: 15 January, 2007, 23:17:33 »
no probs

Profiles, although very often defined the same, are variables.
You can add and remove profiles through both scripts and PtokaX's Profile Manager.
The order the Profile Manager shows the profiles, is the order the scripts see them starting with number 0 on top.

Adding a profile through script can be done using

AddProfile(ProfileName, ProfileNumber)   - Return 1 success or -1 failed. Max ProfileName length 64 chars.

It is wise to check first what the next free ProfileNumber is.
As GetProfiles() really returns the number of profiles, you can use the highest number returned by GetProfiles() as your first free profile number.

Code: [Select]
MakeNewProfile = function(sProfileName)
local iProf = 0
for k in pairs (GetProfiles()) do
iProf = iProf +1
end
AddProfile(sProfileName, iProf)
end

will create a new profile at the next free number having the name specified in the function call

Offline bastya_elvtars

  • Forum God
  • ****
  • Posts: 3 725
  • Karma: +173/-7
  • The rock n' roll doctor
    • The FreshStuff3 Site
Re: Master chat don't work
« Reply #7 on: 15 January, 2007, 23:31:14 »
#GetProfiles()+1
Everything could have been anything else and it would have just as much meaning.

PtokaX forum

Re: Master chat don't work
« Reply #7 on: 15 January, 2007, 23:31:14 »