Master chat don't work
 

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

Master chat don't work

Started by HappyTheMan, 12 September, 2006, 00:52:32

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

HappyTheMan

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:

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 :-)

HappyTheMan

#1
Thx again and again Mutor. 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:
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:
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

Samantha

--// 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 :)

smeg568

#3
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

CrazyGuy

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

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) ??

smeg568

Thanks CG 

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

CrazyGuy

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.

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

bastya_elvtars

Everything could have been anything else and it would have just as much meaning.

SMF spam blocked by CleanTalk