PtokaX forum

Archive => Archived 5.1 boards => Finished Scripts => Topic started by: DTM on 31 January, 2007, 19:12:23

Title: RegUser Chat
Post by: DTM on 31 January, 2007, 19:12:23
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.

Title: Re: RegUser Chat
Post by: bastya_elvtars on 01 February, 2007, 00:15:02
--// 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. :-)
Title: Re: RegUser Chat
Post by: DTM on 01 February, 2007, 08:40:51
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.
Title: Re: RegUser Chat
Post by: Psycho_Chihuahua on 01 February, 2007, 09:06:00
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
Title: Re: RegUser Chat
Post by: CrazyGuy on 01 February, 2007, 10:51:32

--// 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)
Title: Re: RegUser Chat
Post by: bastya_elvtars on 01 February, 2007, 14:43:43
Why not just ~=-1 by the way? ;-)
Title: Re: RegUser Chat
Post by: CrazyGuy on 01 February, 2007, 14:58:36
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 )
Title: Re: RegUser Chat
Post by: bastya_elvtars on 01 February, 2007, 15:04:12
Quote from: CrazyGuy on 01 February, 2007, 14:58:36
because its Reg-Chat .. for class reg ?

~=-1 and bOperator then
Title: Re: RegUser Chat
Post by: DTM on 01 February, 2007, 17:21:41
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.
Title: Re: RegUser Chat
Post by: CrazyGuy on 01 February, 2007, 19:10:13
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
Title: Re: RegUser Chat
Post by: DTM on 01 February, 2007, 19:52:44
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. :-)
Title: Re: RegUser Chat
Post by: bastya_elvtars on 01 February, 2007, 23:15:42
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?
Title: Re: RegUser Chat
Post by: DTM on 02 February, 2007, 17:43:50
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
Title: Re: RegUser Chat
Post by: bastya_elvtars on 02 February, 2007, 18:48:17
Moved, and thanks for feedback.

EDIT: uploaded here (http://forum.ptokax.org/index.php?action=tpmod;dl=item30).