Hi all;
I have 6 profiles; Owner, Admin, Pro_OP, Nor_OP, VIP and Reg. Yesterday I got a script for Master chat room ONLY masters. Is it posible to rewrite the script so it is ONLY Owner, Admin and Pro_OP that can talk to each other trough the chat bot?
The script is like this:
-- Master-Chat
-- Original VipChat v1.0
-- By Guibs 10/11/2003
-- Enjoy :)
-- Simple Modify by NightLitch
-- to Master Bot Only
------------------
-- Main Function --
------------------
function Main()
OPCHAT = "OP_MChat"
frmHub:RegBot(OPCHAT)
end
------------------
-- Data Arrival --
------------------
function DataArrival(user,data)
if(strsub(data,1,4) == "$To:") then
s,e,whoTo = strfind(data,"$To:%s+(%S+)")
if whoTo == OPCHAT then
if user.iProfile == 0 then
s,e,whoTo,from,msg = strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(.+)")
MasterChatRoom(user,msg)
end
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 usr.iProfile == 0 then
usr:SendData("$To: "..usr.sName.." From: "..OPCHAT.." $<"..user.sName.."> " ..msg)
end
end
end
end
end
end
what does your profiles.dat look like?
i think the scripters are going to need the profile #s
since you have added other profiles.
It's like this. The Nor_OP is the last one els it would run some conflicts with the reg user script.
0|Owner|11111111111111111111000000000000
1|Admin|11110111011111111111000000000000
2|Pro_OP|11110110011101111111000000000000
3|Reg|10000000000000000000000000000000
4|VIP|10000000000001111000000000000000
5|Nor_OP|10110100011001111100000000000000
Thanks for fast reply:)
well this is my first attempt at modding a script,
it just turned out to be a cut and paste job,
took me all day to figure it out,
but it works on my system
I hope the more experienced scripters can
maybe make it more efficient.
guys if i did anything wrong please let me know
but it works.
Thanks for the lessons guys.
-- Master-Chat
-- Original VipChat v1.0
-- By Guibs 10/11/2003
-- Enjoy :)
-- Simple Modify by NightLitch
-- to Master Bot Only
-- Simple Mod by SaintSinner thanks to phatty for the lessons
------------------
-- Main Function --
------------------
function Main()
OPCHAT = "OP_MChat"
frmHub:RegBot(OPCHAT)
end
------------------
-- Data Arrival --
------------------
function DataArrival(user,data)
if(strsub(data,1,4) == "$To:") then
s,e,whoTo = strfind(data,"$To:%s+(%S+)")
if whoTo == OPCHAT then
if user.iProfile == 0 then
s,e,whoTo,from,msg = strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(.+)")
MasterChatRoom(user,msg)
elseif user.iProfile == 1 then
s,e,whoTo,from,msg = strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(.+)")
MasterChatRoom(user,msg)
elseif user.iProfile == 2 then
s,e,whoTo,from,msg = strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(.+)")
MasterChatRoom(user,msg)
end
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 usr.iProfile == 0 then
usr:SendData("$To: "..usr.sName.." From: "..OPCHAT.." $<"..user.sName.."> " ..msg)
elseif usr.iProfile == 1 then
usr:SendData("$To: "..usr.sName.." From: "..OPCHAT.." $<"..user.sName.."> " ..msg)
elseif usr.iProfile == 2 then
usr:SendData("$To: "..usr.sName.." From: "..OPCHAT.." $<"..user.sName.."> " ..msg)
end
end
end
end
end
end
here's a hint saintsinner.
Levels= {["0"]=1, ["1"]=1}
if Levels[user.iProfile] then
should be easy now.
plop
QuoteOriginally posted by plop
here's a hint saintsinner.
Levels= {["0"]=1, ["1"]=1}
if Levels[user.iProfile] then
should be easy now.
plop
hmm i dont see the point of adding a table for a simple "or" job ;)
QuoteOriginally posted by (uk-kingdom)pH?tt?
QuoteOriginally posted by plop
here's a hint saintsinner.
Levels= {["0"]=1, ["1"]=1}
if Levels[user.iProfile] then
should be easy now.
plop
hmm i dont see the point of adding a table for a simple "or" job ;)
if usr.iProfile == 0 or usr.iProfile == 1 or usr.iProfile == 2 then
if Levels[user.iProfile] then
well the table is shorter, so less typing and results that any1 can modify it easely 2 there needs.
nomather what profile numbers some1 uses all they have 2 do is add the profile numbers they want 2 be able 2 use the chat 2 the table.
but yes i know, i'm a table junky. lol
plop
Loooool ok you got me, but table is slower, altho its easier i suppose :P
better ay todo it actually and its unnoticable the difference in speed.....
Thx SaintSinner for using a hard days work I appreciate it very much, but I can only get it working it if "Owners" are talking trough it... Could it have something to do with:
s,e,whoTo,from,msg = strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(.+)")
MasterChatRoom(user,msg)
elseif user.iProfile == 1 then
s,e,whoTo,from,msg = strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(.+)")
MasterChatRoom(user,msg)
elseif user.iProfile == 2 then
s,e,whoTo,from,msg = strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(.+)")
MasterChatRoom(user,msg)
It's just a wild guess, but thx any way... And thx to Plop and UK for pasting codes, though I don't no what they are for:)
i just tested and it works with the profile data that you posted, i setup 3 diffrent acct on three diffrent clients,
and i was able to chat with all off them,
did you do a hub restart?
or a restart scripts?
if not that may help.
here from the chat window:
[13:14] testowner
[13:15] testadmin
[13:15] testnor
and i got it working with no owner in the hub
[13:26] test no owner signed into hub
[13:26] return test
Yeh I'v tried to restart the scripts and the program, but it's seems that non of it works... Well right now I'm trying to get it to work...
Wird I think I'v must have saved it the wrong way, cause when I opned it again it was the old script... Of cause now it works:) Why didn't I trust U:D Thanks alot for the help SaintSinner...
QuoteOriginally posted by Smulf
Wird I think I'v must have saved it the wrong way, cause when I opned it again it was the old script... Of cause now it works:) Why didn't I trust U:D Thanks alot for the help SaintSinner...
no problem, im glad it works for you.
taking a hint from plop, and phatty,
this will also work:
-- Master-Chat
-- Original VipChat v1.0
-- By Guibs 10/11/2003
-- Enjoy :)
-- Simple Modify by NightLitch
-- to Master Bot Only
-- Simple Mod by SaintSinner thanks to phatty for the lessons
------------------
-- Main Function --
------------------
function Main()
OPCHAT = "OP_MChat"
frmHub:RegBot(OPCHAT)
end
------------------
-- Data Arrival --
------------------
function DataArrival(user,data)
if(strsub(data,1,4) == "$To:") then
s,e,whoTo = strfind(data,"$To:%s+(%S+)")
if whoTo == OPCHAT then
if user.iProfile == 0 or user.iProfile == 1 or user.iProfile == 2 then
s,e,whoTo,from,msg = strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(.+)")
MasterChatRoom(user,msg)
end
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 user.iProfile == 0 or user.iProfile == 1 or user.iProfile == 2 then
usr:SendData("$To: "..usr.sName.." From: "..OPCHAT.." $<"..user.sName.."> " ..msg)
end
end
end
end
end
end
I dont know if this is more efficient, but i was just messing around....
plop,
why would you do this
Levels= {["0"]=1, ["1"]=1}
if Levels[user.iProfile] then
is this telling the script that levels 0 and level 1 are both equal to level 1?
QuoteOriginally posted by SaintSinner
plop,
why would you do this
Levels= {["0"]=1, ["1"]=1}
if Levels[user.iProfile] then
is this telling the script that levels 0 and level 1 are both equal to level 1?
the 1 is just a dummy vallue, you can use anything BUT nil here.
execute the next code with the lua command line, it whill give you a nice example whats going on.
table= {[1]=1, [5]=1, [2]=1, [9]=1, [4]=1 }
for i=1, 10 do
if table[i] then
print(i.." is in the table")
else
print(i.." isn't in the table")
end
end
plop
darn i cant figure this out, i been trying this for 2 days
can i get a hint or a little more bump in the right direction, :D
------------------
-- Main Function --
------------------
function Main()
OPCHAT = "OP_MChat"
frmHub:RegBot(OPCHAT)
end
Levels= {["0"]=1, ["1"]=1, ["2"]=1,}
------------------
-- Data Arrival --
------------------
function DataArrival(user,data)
if(strsub(data,1,4) == "$To:") then
s,e,whoTo = strfind(data,"$To:%s+(%S+)")
if whoTo == OPCHAT then
if Levels[user.iProfile] then
s,e,whoTo,from,msg = strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(.+)")
MasterChatRoom(user,msg)
end
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 Levels[user.iProfile] then
usr:SendData("$To: "..usr.sName.." From: "..OPCHAT.." $<"..user.sName.."> " ..msg)
end
end
end
end
end
end
i cant get it to work using the tables that plop suggesterd, im not going to be using it i just want to
practice.
your really close saintsinner.
check this it's from the scripting.txt.
iProfile - (number) users profile index or -1 for normal user. Use GetProfileName(index) to get the profile name string
your table holds ....... (wouldn't be a hint if i would say what it holds).
thats all i'm gone say.
plop
i thought i was close
i tried many diffrent variables syntaxes
but this one made the most sense but it
does not work.....
------------------
-- Main Function --
------------------
function Main()
OPCHAT = "OP_MChat"
frmHub:RegBot(OPCHAT)
end
Levels= {["0"]=1, ["1"]=1, ["2"]=1,}
------------------
-- Data Arrival --
------------------
function DataArrival(user,data)
if(strsub(data,1,4) == "$To:") then
s,e,whoTo = strfind(data,"$To:%s+(%S+)")
if whoTo == OPCHAT then
if Levels[user.iProfile] then
s,e,whoTo,from,msg = strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(.+)")
MasterChatRoom(user,msg)
end
end
end
end
function MasterChatRoom(user,msg)
local allprofiles = GetProfileName(Levels)
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 Levels[user.iProfile] then
usr:SendData("$To: "..usr.sName.." From: "..OPCHAT.." $<"..user.sName.."> " ..msg)
end
end
end
end
end
end
ok another hint.
iProfile returns a number, your table holds strings.
change the table 2 numbers and it comes alive.
plop
ITS ALIVE, ITS ALIVE
I think i got it
i dont know if this is what you meant
but it works for all profiles given and are able to chat.
function Main()
OPCHAT = "OP_MChat"
frmHub:RegBot(OPCHAT)
end
Levels= { [0]=0, [1]=0, [2]=0, }
------------------
-- Data Arrival --
------------------
function DataArrival(user,data)
if(strsub(data,1,4) == "$To:") then
s,e,whoTo = strfind(data,"$To:%s+(%S+)")
if whoTo == OPCHAT then
if Levels[user.iProfile] then
s,e,whoTo,from,msg = strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(.+)")
MasterChatRoom(user,msg)
end
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 Levels[user.iProfile] then
usr:SendData("$To: "..usr.sName.." From: "..OPCHAT.." $<"..user.sName.."> " ..msg)
end
end
end
end
end
end
anything i could have done better?.. or am i totally wrong in the way i did it?
nice. You have learnd something new... :-)
it is in my eyes correct.
QuoteOriginally posted by SaintSinner
ITS ALIVE, ITS ALIVE
I think i got it
i dont know if this is what you meant
but it works for all profiles given and are able to chat.
anything i could have done better?.. or am i totally wrong in the way i did it?
thats 100% like i ment.
you earned a stickertje (hope i spelled that right). lol
plop
WOW,...a sticker from plop
SAWEEETTT...
no really, thanks for the help.. im learning alot.
:D :D :D :D :D
Well you could get a lollipop from me if you want. ;-D hehe
Strawberry tase... lol...
Damn am twisted sometimes. :-P
QuoteOriginally posted by SaintSinner
WOW,...a sticker from plop
SAWEEETTT...
no really, thanks for the help.. im learning alot.
:D :D :D :D :D
np @ all.
rather teach something 2 some1 then just fix there problem.
nomather if the teaching take me more time.
plop
just an idea as i have the same in a.i. and it's really handy.
you know those bot's called "pm_to_op's".
in a.i. is a opchat where users can post messages straigth into the opchat, but they can't read whats going on in there.
saves 1 bot in the user list.
also handy is that i have a command which the op's can use 2 reply 2 a user from the opchat.
this can be really handy if a user reports something and you can't understand what he means, and saves you from opening another pm window (+ the other op's see that you reply 2).
plop
I see what pm2ops is, i cant find it,
but please continue.
how would i start.
QuoteOriginally posted by SaintSinner
I see what pm2ops is, i cant find it,
but please continue.
how would i start.
1st step is removing the level check for pm's 2 the opchat so every1 can post in it.
this won't cause any harm as your function which sends the pm's 2 all the op's also has a level check but this time for recieving.
plop