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.
--// 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. :-)
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.
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
--// 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)
Why not just ~=-1 by the way? ;-)
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 )
Quote from: CrazyGuy on 01 February, 2007, 14:58:36
because its Reg-Chat .. for class reg ?
~=-1 and bOperator then
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.
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
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. :-)
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?
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
Moved, and thanks for feedback.
EDIT: uploaded here (http://forum.ptokax.org/index.php?action=tpmod;dl=item30).