RegUser Chat
 

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

RegUser Chat

Started by DTM, 31 January, 2007, 19:12:23

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

DTM

Hello, I need some help..
I need a simple reg user chat for lua 5.1.
Thanks in advance.
PS. I cannot find it in Finished Scripts.


bastya_elvtars

--// Simple VipChat by NightLitch 2005-03-05
--// Fixed bug with some profile not recieving chat - Blondie? 15/10/2006
--// Added Leviathan support - Blondie? 19/10/2006
--// converted to reg chat -  Blondie? 12/12/2006

RegChatName = "?Reg-Chat?"

function Main()
	frmHub:RegBot(RegChatName)
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 == RegChatName then
		if user.iProfile == 2 or user.iProfile == 3 or user.iProfile == 4 or user.iProfile == 5 or user.iProfile == 6 or user.bOperator then
			RegChat(user,msg)
		else
			SendPmToNick(user.sName,RegChatName, "*** You don't have the privileges to talk in this chat.")
			return 1
		end
	end
end

function RegChat(user,msg)
	for _,profile in pairs(GetProfiles()) do
		for _,users in pairs(GetUsersByProfile(profile)) do
			if GetItemByName(users) then
				if GetItemByName(users).iProfile == 2 or GetItemByName(users).iProfile == 3 or GetItemByName(users).iProfile == 4 or GetItemByName(users).iProfile == 5 GetItemByName(users).iProfile == 6 or GetItemByName(users).bOperator then
					if GetItemByName(users).sName ~= user.sName then
						GetItemByName(users):SendData("$To: "..GetItemByName(users).sName.." From: "..RegChatName.." $<"..user.sName.."> "..msg)
					end
				end
			end
		end
	end
end


I've found it in this forum. :-)
Everything could have been anything else and it would have just as much meaning.

DTM

#2
Thank you..but..I also used the ''search'' button, I also found this script, I also tested this script and I found out that this script doesn't work in my PtokaX.

[08:37] Syntax c:\Programme\Ptokax3\scripts\regchat.lua:29: 'then' expected near 'GetItemByName'


I am not a scripter, so I don't know where the mistake is.

Best regards.

Psycho_Chihuahua

change line 29 from

if GetItemByName(users).iProfile == 2 or GetItemByName(users).iProfile == 3 or GetItemByName(users).iProfile == 4 or GetItemByName(users).iProfile == 5 GetItemByName(users).iProfile == 6 or GetItemByName(users).bOperator then


to

if GetItemByName(users).iProfile == 2 or GetItemByName(users).iProfile == 3 or GetItemByName(users).iProfile == 4 or GetItemByName(users).iProfile == 5 or GetItemByName(users).iProfile == 6 or GetItemByName(users).bOperator then
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

CrazyGuy

--// Simple VipChat by NightLitch 2005-03-05
--// Fixed bug with some profile not recieving chat - Blondie? 15/10/2006
--// Added Leviathan support - Blondie? 19/10/2006
--// converted to reg chat -  Blondie? 12/12/2006
--// slightly touched by CrazyGuy 01/02/2007

RegChatName = "?Reg-Chat?"

tProf = {			--set which profiles to allow
	[2] = 1,		--reg
	[0] = 1,		--master
	[1] = 0,		--op
	[4] = 0,		--mod
}

function Main()
	frmHub:RegBot(RegChatName)
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 == RegChatName then
		if tProf[user.iProfile] == 1 then
			RegChat(user,msg)
		else
			SendPmToNick(user.sName,RegChatName, "*** You don't have the privileges to talk in this chat.")
			return 1
		end
	end
end

function RegChat(user,msg)
	for k in pairs(tProf) do
		if tProf[k] == 1 then
			for _,users in pairs(GetUsersByProfile(GetProfileName(tProf[k]))) do
				if GetItemByName(users) then
					if GetItemByName(users).sName ~= user.sName then
						GetItemByName(users):SendData("$To: "..GetItemByName(users).sName.." From: "..RegChatName.." $<"..user.sName.."> "..msg)
					end
				end
			end
		end
	end
end


this allows a bit more changes by setting the profiles table (standard reg and master allowed now in RegChat)

bastya_elvtars

Why not just ~=-1 by the way? ;-)
Everything could have been anything else and it would have just as much meaning.

CrazyGuy

because its Reg-Chat .. for class reg ? ( i removed all the overhead of checking all users of all profiles as in the initial pasted script )

bastya_elvtars

Quote from: CrazyGuy on 01 February, 2007, 14:58:36
because its Reg-Chat .. for class reg ?

~=-1 and bOperator then
Everything could have been anything else and it would have just as much meaning.

DTM

#8
The Regchat from CrazyGuy doesn't work at all !! Absolutely !! And more, I think that the profile for reguser is 3. In Regchat, the 3 profile is not mentioned.

I added the 3 profile and still it doesn't work (no syntax).
The first RegChat, from Bastya, with the changing of Psycho, does work perfectly !
Thank you all.

CrazyGuy

QuoteThe Regchat from CrazyGuy doesn't work at all !! Absolutely !! And more, I think that the profile for reguser is 3. In Regchat, the 3 profile is not mentioned.

Yes, you are correct, my bad.
It should work though if you add [3] = 1, but I havent tested it

DTM

It should work though if you add [3] = 1, but I havent tested it

I've tested before this script and I changed with ''3'' and still it hasn't worked.

And for you, Bastya: have you tested the script before you posted it? :P

PS: This is as an answer on what you wrote to me before
I've found it in this forum. :-)


bastya_elvtars

Quote from: DTM on 01 February, 2007, 19:52:44
And for you, Bastya: have you tested the script before you posted it? :P

PS: This is as an answer on what you wrote to me before
I've found it in this forum. :-)



No, should admins test scripts found in this forum periodically? :P
Does the script I posted work?
Everything could have been anything else and it would have just as much meaning.

DTM

Yes, your script works, you can place it in finished scripts as RegUser Chat, because the 2 ones that there are in there don't work.
If someone looks for a RegUser Chat in finished scripts, will only find 2 scripts that don't work and the same discussion begins again.  ;D

Best regards.
DTM

bastya_elvtars

#13
Moved, and thanks for feedback.

EDIT: uploaded here.
Everything could have been anything else and it would have just as much meaning.

SMF spam blocked by CleanTalk