Letting ops ammend their own welcomes - Page 2
 

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

Letting ops ammend their own welcomes

Started by Stravides, 16 January, 2004, 02:59:24

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

plop

QuoteOriginally posted by Stravides
General gist of the code will be in dataarrival

function DataArrival(user,data)
	if strsub(data, 1, 1) == "<" then
		data=strsub(data,1,strlen(data)-1)
		s,e,cmd = strfind(data,"%b<>%s+(%S+)")

		if cmd == prefix.."changelogin" then
			_,_,cmd,message = strfind( data, "%b<>%s+(%S+)%s+(.+)" )
			if OPLoginTable[user.sName] then  
				OPLogoutTable[user.sName] = message
 				SendToAll(BOTName,"Login changed to: "..OPLogoutTable[user.sName])
			end
		elseif cmd == prefix.."changelogout" then

I know the    OPLogoutTable[user.sName] = message will only change it for there and then, but I do not know how to change the table perm. can you assist in this but ;)

regards
Stravides
you got it, just a tiny mix up.
your changing the logout on the login command.
and yes this only works aslong as the bot isn't restarted, for this 2 be a permanent change we need 2 save it.
now we could save it as table so on loading we only need 2 do a dofile(filename) but were gone save it as plain txt file.
this so you learn some more pattern matching on loading the file again.
2 save this were gone need a loop 2 proces all the entry's in the table and think of a handy way 2 store the things in the file.
if you look @ the dat files from ptokax you can see that they use the | between things, so were gone do the same.
so our file is gone look like this.
name1|text1
name2|text2
name3|text3
2 save we 1st need 2 open the file.
we can do that in 2 way's.
filename = "welcome.txt" 
writeto(filename)
or we can put those 2 steps 2gether.
writeto("welcome.txt")
the 1st 1 is easyer for other ppl 2 change the filename 2 save 2 as you can place it seperatly in a config part of the bot or even a special config file.

now we have opend the file we can start writing 2 it.
so were gone start the loop.
for key,vallue in table do
   write("for_you_2_find_out\n")
end
now you see i left something for you 2 find out.
the \n i'll explain, that tells the bot make a new line after writing the stuff we want.

when that is done we only have 2 close the file, this is done by calling writeto again but now without giving a filename.

now we should have a nice file with all the welcome lines.

good luck.

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

plop

how's it going Stravides, been so quiet here???

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

Stravides

not too good :(

dunno table structure and objects :(

still trying tho, might help if I knew how to call the value or keys from the table
Stravides
For RPG Books, Mp3 & Videos
We host trivia  and the ever failing Smeagolbot

plop

QuoteOriginally posted by Stravides
not too good :(

dunno table structure and objects :(

still trying tho, might help if I knew how to call the value or keys from the table
ok.
2 insert something in the table you use.
tablename[key]=vallue

and 2 call something from the table you use.
tablename[key]

the key in your case if the users nick.
tablename[user.sName]

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

Stravides

AAAAAAAAAARRRRRRRGGGGGGGGGGHHHHHHHHHHH

to put it mildly...

for a generic table of

table(key=details)  

Ok I can get the details to a file thats not an issue at all
but how do i record the actual key..

ie I have a few tables, but lets just take 1

OPLoginTable = { 
["Stravides"]="The Heavens hathed opened and thus vomitted forth the hapless figure of Stravides",
["Malevolence"]="Bow down and Cower for Malevolence has arrived..",
["Blumpy"]="From the festering brown froth of the sewers, the Overlord of Faeces, Blumpy, emerges.",
["Morgyn"]="RPGBooks Cymru Welcomes a Guest OP - Morgyn from RPGmadhouse.no-ip.org",
["Kyoya"]="RPGBooks Cymru Welcomes a Guest OP - Kyoya from RPGmadhouse.no-ip.org",
["Sniffy"]="Best be on yer best behaviour as Mrs Sniffy has arrived..",
["Reload3d"]="A large dog looms over, twitches, moans and chuffs up the steaming body of Reload3d - eeeeew",
["Feuer_Frei"]="Misfits & Miscreants beware! Feuer_Frei is here to check your share!!",
["Tumnakitty"]="Welcome, my daughter and servant... soft be your feline footfalls, Tumnakitty",
};

I then call in a test environment the code

elseif cmd == prefix.."changelogout" then
     for key,value in OPLoginTable do
 	SendToAll(BOTName,OPLoginTable[key])
     end
     return 1
elseif....

this outputs the "The Heavens hathed opened and thus vomitted forth the hapless figure of Stravides" and all the other messages.
Once I get this into a sendall I can worry about putting it to file as thats fairly easy.

Thanks for your assistance, sorry I seem a little dim

regards
Stravides
Stravides
For RPG Books, Mp3 & Videos
We host trivia  and the ever failing Smeagolbot

Stravides

Ok things not quite right here, the Send to all works but the save to file does not

The table in question is
OPLoginTable = { 
["Stravides"]="The Heavens hathed opened and thus vomitted forth the hapless figure of Stravides",
["Malevolence"]="Bow down and Cower for Malevolence has arrived..",
["Blumpy"]="From the festering brown froth of the sewers, the Overlord of Faeces, Blumpy, emerges.",
["Morgyn"]="RPGBooks Cymru Welcomes a Guest OP - Morgyn from RPGmadhouse.no-ip.org",
["Kyoya"]="RPGBooks Cymru Welcomes a Guest OP - Kyoya from RPGmadhouse.no-ip.org",
["Sniffy"]="Best be on yer best behaviour as Mrs Sniffy has arrived..",
["Reload3d"]="A large dog looms over, twitches, moans and chuffs up the steaming body of Reload3d - eeeeew",
["Feuer_Frei"]="Misfits & Miscreants beware! Feuer_Frei is here to check your share!!",
["Tumnakitty"]="Welcome, my daughter and servant... soft be your feline footfalls, Tumnakitty",
};

The dataarrival command is !changelogout
that does 2 things, 1 calls the savetables function and 2 runs the same code to SendToAll.

SaveTable Function  is
function SaveTables(user)
--	openfile("welcomeop.txt", "a")
	writeto("welcomeop.txt")
	for key,value in OPLoginTable do
 		write(OPLoginTable[key].."|\n")
	end
	writeto("")
--	closefile("welcomeop.txt")
end

The DataArrival Code is  
function DataArrival(user,data)
	if strsub(data, 1, 1) == "<" then
		data=strsub(data,1,strlen(data)-1)
		s,e,cmd = strfind(data,"%b<>%s+(%S+)")

		if cmd == prefix.."changelogin" then
			_,_,cmd,message = strfind( data, "%b<>%s+(%S+)%s+(.+)" )
			if OPLoginTable[user.sName] then  
				OPLoginTable[user.sName] = message
 				SendToAll(BOTName,"Login changed to: "..OPLoginTable[user.sName])
			end
		[B]elseif cmd == prefix.."changelogout" then
			SaveTables(user)
			for key,value in OPLoginTable do
 				SendToAll(BOTName,OPLoginTable[key])
			end
			return 1[/B] 		elseif cmd == "!rules" then
			user:SendPM(BOTName,rules)
			return 1
		elseif cmd == "!reghelp" then
			user:SendPM(BOTName,reghelp)
			return 1
		elseif (cmd == prefix.."myip" ) then
			user:SendData(BOTName,"Your preciousssss IP issssss: "..user.sIP)
			return 1
		elseif (cmd == prefix.."mmop" ) then
			_,_,cmd,message = strfind( data, "%b<>%s+(%S+)%s+(.+)" )
			if user.iProfile == 1 or user.iProfile == 0 or user.iProfile == 4 then 
			SendPmToOps(user.sName, message)
			return 1
		end end
	end
end

The output from SendToAll is  
 The Heavens hathed opened and thus vomitted forth the hapless figure of Stravides
 Best be on yer best behaviour as Mrs Sniffy has arrived..
 A large dog looms over, twitches, moans and chuffs up the steaming body of Reload3d - eeeeew
 RPGBooks Cymru Welcomes a Guest OP - Kyoya from RPGmadhouse.no-ip.org
 Misfits & Miscreants beware! Feuer_Frei is here to check your share!!
 From the festering brown froth of the sewers, the Overlord of Faeces, Blumpy, emerges.
 RPGBooks Cymru Welcomes a Guest OP - Morgyn from RPGmadhouse.no-ip.org
 Welcome, my daughter and servant... soft be your feline footfalls, Tumnakitty
 Bow down and Cower for Malevolence has arrived..

The File contents of welcomeop.txt is
The Heavens hathed opened and thus vomitted forth the hapless figure of Stravides|
Best be on yer best behaviour as Mrs Sniffy has arrived..|
A large dog looms over, twitches, moans and chuffs up the steaming body of Reload3d - eeeeew|
RPGBooks Cymru Welcomes a Guest OP - Kyoya from RPGmadhouse.no-ip.org|
Misfits & Miscreants beware! Feuer_Frei is here to check your share!!|
From the festering brown froth of the sewers, the Overlord of Faeces, Blumpy, emerges.|
Stravides
For RPG Books, Mp3 & Videos
We host trivia  and the ever failing Smeagolbot

plop

ok i'll explain the saving loop a bit more.

for key, vallue in OPLoginTable do

this means it has 2 proces all entry's in the table, key and vallue are here literaly.
most ppl use for a, b in tablename do.
this simply means the key gets called by a and the matching vallue by b.

try the next script with the lua command line.
OPLoginTable = { 
["Stravides"]="The Heavens hathed opened and thus vomitted forth the hapless figure of Stravides",
["Malevolence"]="Bow down and Cower for Malevolence has arrived..",
["Blumpy"]="From the festering brown froth of the sewers, the Overlord of Faeces, Blumpy, emerges.",
["Morgyn"]="RPGBooks Cymru Welcomes a Guest OP - Morgyn from RPGmadhouse.no-ip.org",
["Kyoya"]="RPGBooks Cymru Welcomes a Guest OP - Kyoya from RPGmadhouse.no-ip.org",
["Sniffy"]="Best be on yer best behaviour as Mrs Sniffy has arrived..",
["Reload3d"]="A large dog looms over, twitches, moans and chuffs up the steaming body of Reload3d - eeeeew",
["Feuer_Frei"]="Misfits & Miscreants beware! Feuer_Frei is here to check your share!!",
["Tumnakitty"]="Welcome, my daughter and servant... soft be your feline footfalls, Tumnakitty",
};

for key, vallue in OPLoginTable do
   print("key = "..key.." and has the vallue: "..vallue)
end
now you should be able 2 see how the line 2 write the stuff 2 the file should be made.

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

Stravides

Many thanks,

ok now just one last error in that bittie :)

ok using the 2 tables for the moment as below, 9 logins, 9 logouts.

OPLoginTable = { 
["Stravides"]="The Heavens hathed opened and thus vomitted forth the hapless figure of Stravides",
["Blumpy"]="From the festering brown froth of the sewers, the Overlord of Faeces, Blumpy, emerges.",
["Morgyn"]="RPGBooks Cymru Welcomes a Guest OP - Morgyn from RPGmadhouse.no-ip.org",
["Findor_Tallwillow"]="Beware, fakers, slot-lockers and other lamers.  Findor_Tallwillow is here to give you a quick trip to the Abyss... If you aren't one of the above, then smile, and have a good day! ",
["Sniffy"]="Best be on yer best behaviour as Mrs Sniffy has arrived",
["Reload3d"]="A large dog looms over, twitches, moans and chuffs up the steaming body of Reload3d - eeeeew",
["Malevolence"]="Bow down and Cower for Malevolence has arrived",
["Feuer_Frei"]="Misfits & Miscreants beware! Feuer_Frei is here to check your share!!",
["Tumnakitty"]="Welcome, my daughter and servant... soft be your feline footfalls, Tumnakitty",
};

OPLogoutTable = { 
["Stravides"]="Stravides farts and ignites the gasses that propel him unto infinity. . .",
["Malevolence"]="Where's that mangy chufter Malevolence off to, no doubt he will return soon",
["Blumpy"]="Blumpy flushes himself back to the kingdom of the Brown River",
["Morgyn"]="Bid Farewell to Guest OP Morgyn from RPGmadhouse.no-ip.org",
["Findor_Tallwillow"]="Necromancer heaves a sigh of relief as Findor leaves and invites the rule-breakers back into the hub. If they Dare.",
["Sniffy"]="Phew now that the wife, Sniffy has left I can relax in my slippers",
["Reload3d"]="The taint of Reload3d is no more...",
["Feuer_Frei"]="Feuer_Frei hath departed!!",
["Tumnakitty"]="Alas, I call to me Tumnakitty,the firecat that follows my lead...",
};

for the Byeop.txt I get 4  
key = Stravides and has the vallue: Stravides farts and ignites the gasses that propel him unto infinity. . .
key = Sniffy and has the vallue: Phew now that the wife, Sniffy has left I can relax in my slippers
key = Findor_Tallwillow and has the vallue: Necromancer heaves a sigh of relief as Findor leaves and invites the rule-breakers back into the hub. If they Dare.
key = Reload3d and has the vallue: The taint of Reload3d is no more.

for the welcomeop.txt I get 7
key = Stravides and has the vallue: The Heavens hathed opened and thus vomitted forth the hapless figure of Stravides
key = Sniffy and has the vallue: Best be on yer best behaviour as Mrs Sniffy has arrived
key = Findor_Tallwillow and has the vallue: Beware, fakers, slot-lockers and other lamers.  Findor_Tallwillow is here to give you a quick trip to the Abyss... If you aren't one of the above, then smile, and have a good day! 
key = Reload3d and has the vallue: A large dog looms over, twitches, moans and chuffs up the steaming body of Reload3d - eeeeew
key = Morgyn and has the vallue: RPGBooks Cymru Welcomes a Guest OP - Morgyn from RPGmadhouse.no-ip.org
key = Feuer_Frei and has the vallue: Misfits & Miscreants beware! Feuer_Frei is here to check your share!!
key = Blumpy and has the vallue: From the festering brown froth of the sewers, the Overlord of Faeces, Blumpy, emerges.

I used as you say, not the print but write and it put it to file not all lines are written any suggestions ?

regards
Stravides
Stravides
For RPG Books, Mp3 & Videos
We host trivia  and the ever failing Smeagolbot

plop

QuoteOriginally posted by Stravides
Many thanks,

ok now just one last error in that bittie :)

ok using the 2 tables for the moment as below, 9 logins, 9 logouts.



for the Byeop.txt I get 4  
key = Stravides and has the vallue: Stravides farts and ignites the gasses that propel him unto infinity. . .
key = Sniffy and has the vallue: Phew now that the wife, Sniffy has left I can relax in my slippers
key = Findor_Tallwillow and has the vallue: Necromancer heaves a sigh of relief as Findor leaves and invites the rule-breakers back into the hub. If they Dare.
key = Reload3d and has the vallue: The taint of Reload3d is no more.

for the welcomeop.txt I get 7
key = Stravides and has the vallue: The Heavens hathed opened and thus vomitted forth the hapless figure of Stravides
key = Sniffy and has the vallue: Best be on yer best behaviour as Mrs Sniffy has arrived
key = Findor_Tallwillow and has the vallue: Beware, fakers, slot-lockers and other lamers.  Findor_Tallwillow is here to give you a quick trip to the Abyss... If you aren't one of the above, then smile, and have a good day! 
key = Reload3d and has the vallue: A large dog looms over, twitches, moans and chuffs up the steaming body of Reload3d - eeeeew
key = Morgyn and has the vallue: RPGBooks Cymru Welcomes a Guest OP - Morgyn from RPGmadhouse.no-ip.org
key = Feuer_Frei and has the vallue: Misfits & Miscreants beware! Feuer_Frei is here to check your share!!
key = Blumpy and has the vallue: From the festering brown froth of the sewers, the Overlord of Faeces, Blumpy, emerges.

I used as you say, not the print but write and it put it to file not all lines are written any suggestions ?

regards
Stravides
i guess key is here just a dummy, as you can only use the same key 1x.

can you post the function which writes the file??
that makes it a bit easyer 2 see what is going wrong.

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

Stravides

heres the lot :)

--    Variables  
BOTName="Smeagol"
HubAdress = "RPGBooks-Cymru.no-ip.org"
ScriptVersion = "Stripped Version V6.99" 
BOTNameInfo = "$MyINFO $ALL "..BOTName.." <++V:1.3 Stravides $ $Black Light"..strchar( 1 ).."$Stravides@RPGBooks-Cymru.no-ip.org$" 
version = BOTName.." "..ScriptVersion 
prefix = "!"

ptokaxcommands = {
	op = 1, drop = 1, ban = 1, unban = 1, nickban = 1, getbanlist = 1,
	getinfo = 1, gag = 1, ungag = 1, banip = 1, ipinfo = 1, iprangeinfo = 1,
	userinfo = 1, clrtempban = 1, stat = 1 }

ptokax2commands = {
	clrpermban = 1, topic = 1, reloadtxt = 1 }

-- dofile("messages.cfg");  -- this will hold the tables below

UserBotTable = {
["Stravides"]="Thanatos",
["Blumpy"]="King Dung",
["Morgyn"]="Guest OP",
["Kyoya"]="Guest OP",
["Reload3d"]="Pug",
["Tumnakitty"]="Bast",
};

OPLoginTable = { 
["Stravides"]="The Heavens hathed opened and thus vomitted forth the hapless figure of Stravides",
["Blumpy"]="From the festering brown froth of the sewers, the Overlord of Faeces, Blumpy, emerges.",
["Morgyn"]="RPGBooks Cymru Welcomes a Guest OP - Morgyn from RPGmadhouse.no-ip.org",
["Sniffy"]="Best be on yer best behaviour as Mrs Sniffy has arrived",
["Reload3d"]="A large dog looms over, twitches, moans and chuffs up the steaming body of Reload3d - eeeeew",
["Malevolence"]="Bow down and Cower for Malevolence has arrived",
["Feuer_Frei"]="Misfits & Miscreants beware! Feuer_Frei is here to check your share!!",
["Tumnakitty"]="Welcome, my daughter and servant... soft be your feline footfalls, Tumnakitty",
["Findor_Tallwillow"]="Beware, fakers, slot-lockers and other lamers.  Findor_Tallwillow is here to give you a quick trip to the Abyss... If you aren't one of the above, then smile, and have a good day! ",
};

OPLogoutTable = { 
["Stravides"]="Stravides farts and ignites the gasses that propel him unto infinity. . .",
["Malevolence"]="Where's that mangy chufter Malevolence off to, no doubt he will return soon",
["Blumpy"]="Blumpy flushes himself back to the kingdom of the Brown River",
["Morgyn"]="Bid Farewell to Guest OP Morgyn from RPGmadhouse.no-ip.org",
["Sniffy"]="Phew now that the wife, Sniffy has left I can relax in my slippers",
["Reload3d"]="The taint of Reload3d is no more.",
["Feuer_Frei"]="Feuer_Frei hath departed!",
["Tumnakitty"]="Alas, I call to me Tumnakitty,the firecat that follows my lead.",
["Findor_Tallwillow"]="Necromancer heaves a sigh of relief as Findor leaves and invites the rule-breakers back into the hub. If they Dare.",
};

VIPLogInTable = {
["Warian"]="Warian - The one who is all that which stands for that which is the epitome` of that which is The World of [Darkness enters!",
["Kyoya"]="RPGBooks Cymru Welcomes a Guest OP - Kyoya from RPGmadhouse.no-ip.org",
["Spider"]="Spider has entered the Hub, put all small mammals away!!!",
["fortywinks"]="The slumbering tones of Fortywinks graces the hub",
};

VIPLogOutTable = {
["Warian"]="Warian - The World of Darkness Guru has left, and taken his Weremidgets with him!",
["Kyoya"]="Bid Farewell to the Guest OP from RPGmadhouse.no-ip.org",
["Spider"]="As the Sun goes down, the reflections cease from Spider as he logs off..",
["fortywinks"]="As Fortywinks leaves, he casts a farewell wave..",
};


reghelp = "\r\n"..
"The command to register a new user is !addreguser   \r\n"..
"Blah Blah\r\n"..
"Moderator	Just lets em kick and gag \r\n"

rules = "\r\n"..
"                                   Rules \r\n"..
"\r\n"..
"Failure to comply with these rules will mean perm bans from this hub.\r\n"..
"\r\n"..
"01. You must share at least 50MB of Applicable Files. (RPG, Video, MP3)\r\n"..
"Blah Blah\r\n"..
"16. Don't ask for OP. we'll ask you :)\r\n"


function Main() 
	frmHub:UnregBot(BOTName) 
	frmHub:UnregBot("Necromancer") 
	frmHub:RegBot(BOTName) 
	SendToAll(BOTNameInfo)
	AddProfile("Moderator", 4269273088)
	AddProfile("Guest", 2148028000)
end 

function DoRead(user)
	while 1 do 
		pline = read() 
		if pline == nil then break end
			user:SendPM(BOTName, pline)
		end 
	readfrom() 
end

function MyInfoString(data)
	s,e,description,speed,email,share = strfind(data, "$MyINFO $ALL ([^$]+)$ $([^$]*)$([^$]*)$([^$]+)")
	speed = strsub(speed,1,strlen(speed)-1) 
	return description,speed,email,share
end

--------- Begin Connection Functions ---------

function OpConnected(user)
	description,speed,email,share=MyInfoString(user.sMyInfoString)
	local share2 = share / (1024*1024*1024)
	local botin = ""
	
	if UserBotTable[user.sName] then
		BotIn = UserBotTable[user.sName]
	else 
		BotIn = BOTName
	end	
	if OPLoginTable[user.sName] then 
		SendToAll(BotIn,OPLoginTable[user.sName])	
	else    
		SendToAll(BOTName, "[OPS] "..user.sName.." has joined the hub") 
	end
end

function OpDisconnected(user)
	description,speed,email,share=MyInfoString(user.sMyInfoString)
	local share2 = share / (1024*1024*1024)
	if UserBotTable[user.sName] then
		BotIn = UserBotTable[user.sName]
	else 
		BotIn = BOTName
	end
	if OPLogoutTable[user.sName] then 
		SendToAll(BotIn,OPLogoutTable[user.sName])	
	elseif user.iProfile == 1 then 
		SendToAll(BOTName, "[OP] "..user.sName.." Has Left the Hub")  
	end
end

function NewUserConnected(user)
	if UserBotTable[user.sName] then
		BotIn = UserBotTable[user.sName]
	else 
		BotIn = BOTName
	end	
	if VIPLogInTable[user.sName] then 
		SendToAll(BotIn,VIPLogInTable[user.sName])	
	elseif user.iProfile == 2 then 
		SendToAll(BotIn, "[VIP] "..user.sName..", has Connected")  
	elseif user.iProfile == nil then 
		SendToNick(BOTName, ""..user.sName..", has Connected" )
	end
end

function UserDisconnected(user)
	if UserBotTable[user.sName] then
		BotIn = UserBotTable[user.sName]
	else 
		BotIn = BOTName
	end
	if VIPLogOutTable[user.sName] then 
		SendToAll(BotIn,VIPLogOutTable[user.sName])	
	elseif (user.sName == "fortywinks") then 
		SendToAll(BotIn, ""..fortywinks2.."") 
	elseif user.iProfile == 2 then 
		SendToAll(BOTName, "[VIP] "..user.sName..", has Disconnected")  
	end
end

--------- End Connection Functions ---------

function SaveTables(user)
	writeto("welcomeop.txt")
	for key, vallue in OPLoginTable do
		write("key = "..key.." and has the vallue: "..vallue.."\n")
	end
	writeto("byeop.txt")
	for key, vallue in OPLogoutTable do
		write("key = "..key.." and has the vallue: "..vallue.."\n")
	end
	writeto("")
end

------ DataArrival Scripts

function DataArrival(user,data)
	if strsub(data, 1, 1) == "<" then
		data=strsub(data,1,strlen(data)-1)
		s,e,cmd = strfind(data,"%b<>%s+(%S+)")

		if cmd == prefix.."changelogin" then
			_,_,cmd,message = strfind( data, "%b<>%s+(%S+)%s+(.+)" )
			if OPLoginTable[user.sName] then  
				OPLoginTable[user.sName] = message
 				SendToAll(BOTName,"Login changed to: "..OPLoginTable[user.sName])
			end
		elseif cmd == prefix.."changelogout" then
			SaveTables(user)
			SendToAll(BOTName,"Data Changed")
			return 1
		elseif cmd == "!rules" then
			user:SendPM(BOTName,rules)
			return 1
		elseif cmd == "!reghelp" then
			user:SendPM(BOTName,reghelp)
			return 1
		elseif (cmd == prefix.."myip" ) then
			user:SendData(BOTName,"Your preciousssss IP issssss: "..user.sIP)
			return 1
		elseif (cmd == prefix.."mmop" ) then
			_,_,cmd,message = strfind( data, "%b<>%s+(%S+)%s+(.+)" )
			if user.iProfile == 1 or user.iProfile == 0 or user.iProfile == 4 then 
			SendPmToOps(user.sName, message)
			return 1
		end end
	end
end
Stravides
For RPG Books, Mp3 & Videos
We host trivia  and the ever failing Smeagolbot

plop

try it like this.
function SaveTables(user) 
	writeto("welcomeop.txt")
	for key, vallue in OPLoginTable do
      OPLoginTable[key]=vallue
		write("key = "..key.." and has the vallue: "..vallue.."\n")
	end
   writeto()
	writeto("byeop.txt")
	for key, vallue in OPLogoutTable do
      OPLogoutTable[key]=vallue
		write("key = "..key.." and has the vallue: "..vallue.."\n")
	end
	writeto()
end
you always have 2 close a open file before opening a new 1.
the other extra line i added is just a safety, shouldn't be necesary 2 add.

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

Stravides

#36
Ok done :D  CHEESY GRIN

ok now please can you assist me in reducing the number of repititions of the loads and saves as this is quite large and hard to read...  
one big thanks to all those that have helped, but now we need to tidy up the code...  suggestions are welcomed  

regards
     Stravides

Oops made a mistake, heres the correct code

--    Variables  
--    Developed By Stravides, tutored by Plop and the Lua boards
--    Many thanks to all that made this possible..
--    OriginalBOTName="Smeagol"
--    OriginalHubAdress = "RPGBooks-Cymru.no-ip.org"

BOTName="Smeagol"
HubAdress = "RPGBooks-Cymru.no-ip.org"
ScriptVersion = "Stripped Version V6.99" 
BOTNameInfo = "$MyINFO $ALL "..BOTName.." <++V:1.3 Stravides $ $Black Light"..strchar( 1 ).."$Stravides@RPGBooks-Cymru.no-ip.org$" 
version = BOTName.." "..ScriptVersion 
prefix = "!"
strGSep = "|" 

opin="welcomeop.txt"
vipin="welcomevip.txt"
opout ="byeop.txt"
vipout="byevip.txt"

ptokaxcommands = {
	op = 1, drop = 1, ban = 1, unban = 1, nickban = 1, getbanlist = 1,
	getinfo = 1, gag = 1, ungag = 1, banip = 1, ipinfo = 1, iprangeinfo = 1,
	userinfo = 1, clrtempban = 1, stat = 1 }

ptokax2commands = {
	clrpermban = 1, topic = 1, reloadtxt = 1 }

-- dofile("messages.cfg");  -- this will hold the tables below

UserBotTable = {
["Stravides"]="Thanatos",
["Blumpy"]="King Dung",
["Morgyn"]="Guest OP",
["Kyoya"]="Guest OP",
["Waylander"]="Scoobie",
["Tumnakitty"]="Bast",
};

OPLogInTable = { 
 };

OPLogOutTable = { 
};

VIPLogInTable = {
};

VIPLogOutTable = {
};

reghelp = "\r\n"..
"The command to register a new user is !addreguser   \r\n"..
"ALL of these parameters are case sensitive\r\n"..
"\r\n"..
"name 		is thier username\r\n"..
"password 	is the pass they must use to get into system\r\n"..
"level 		is one of the below...\r\n"..
"\r\n"..
"Operator	Only Stravides or Reload3d should set this user level\r\n"..
"VIP		Only Stravides or Reload3d should set this user level\r\n"..
"Reg 		Std registered user - please use this \r\n"..
"Moderator	Just lets em kick and gag \r\n"

rules = "\r\n"..
"                                   Rules \r\n"..
"\r\n"..
"Failure to comply with these rules will mean perm bans from this hub.\r\n"..
"\r\n"..
"01. You must share at least 50MB of Applicable Files. (RPG, Video, MP3)\r\n"..
"02. Please speak English *only* in the main chat. We realize that not everyone is fluent in it, be hey, look at it as a learning experience !\r\n"..
"03. Zero Porn Toleration. This means your run-of-the-mill stuff Hentai, Disney toons, or anything similar. You will receive one warning. Then you will be banned. Sick porn, teen porn, and/or kiddie porn will all be banned without warning or absolution. \r\n"..
"04. Don't use excessive Caps in main chat, don't change your nick, do not flood or spam, and do not post ads for other hubs.\r\n"..
"05. Slotlocking or faksesharing will result in an immediate and permanent ban. No questions asked.\r\n"..
"06. Download speed limiters (shown as B: or L: in desc tags) are not allowed in this hub it will lead to a ban. \r\n"..
"07. 3 kicks will lead to automatic ban!\r\n"..
"08. No racist propaganda or music.\r\n"..
"09. Don't share installed Games/Programs files or incomplete files \r\n"..
"10. Don't share .VOB-files \r\n"..
"11. Don't share *.eml or *.pst-files (your e-mail files). Besides being stupid to share your private e-mail, they may contain viruses.\r\n"..
"12. Don't close other users from downloading. (If you must do it, then give them a good reason!)\r\n"..
"13. Don't flood or spam the chat.\r\n"..
"14. Don't attack other hub users in the main chat. Chat nice or don't chat at all!\r\n"..
"15. 6 HUBS MAX, 1 SLOT PER HUB !!!!\r\n"..
"16. Don't ask for OP. we'll ask you :)\r\n"..
"17. 56k users and below please note MAX 2 HUBS MAX 2 Slots\r\n"


function Main() 
	frmHub:UnregBot(BOTName) 
	frmHub:UnregBot("Necromancer") 
	frmHub:RegBot(BOTName) 
	SendToAll(BOTNameInfo)
	AddProfile("Moderator", 4269273088)
	AddProfile("Guest", 2148028000)
	LoadOPLogInTables(user)
	LoadOPLogOutTables(user)
	LoadVIPLogInTables(user)
	LoadVIPLogOutTables(user)
end 

function DoRead(user)
	while 1 do 
		pline = read() 
		if pline == nil then break end
			user:SendPM(BOTName, pline)
		end 
	readfrom() 
end

function MyInfoString(data)
	s,e,description,speed,email,share = strfind(data, "$MyINFO $ALL ([^$]+)$ $([^$]*)$([^$]*)$([^$]+)")
	speed = strsub(speed,1,strlen(speed)-1) 
	return description,speed,email,share
end

--------- Begin Connection/Diconnection Functions ---------
function OpConnected(user)
	description,speed,email,share=MyInfoString(user.sMyInfoString)
	local share2 = share / (1024*1024*1024)
	local botin = ""
	
	if UserBotTable[user.sName] then
		BotIn = UserBotTable[user.sName]
	else 
		BotIn = BOTName
	end	
	if OPLogInTable[user.sName] then 
		SendToAll(BotIn,OPLogInTable[user.sName])	
	else    
		SendToAll(BOTName, "[OPS] "..user.sName.." has joined the hub") 
	end
	user:SendPM(BOTName,rules)
end

function OpDisconnected(user)
	description,speed,email,share=MyInfoString(user.sMyInfoString)
	local share2 = share / (1024*1024*1024)
	if UserBotTable[user.sName] then
		BotIn = UserBotTable[user.sName]
	else 
		BotIn = BOTName
	end
	if OPLogOutTable[user.sName] then 
		SendToAll(BotIn,OPLogOutTable[user.sName])	
	elseif user.iProfile == 1 then 
		SendToAll(BOTName, "[OP] "..user.sName.." Has Left the Hub")  
	end
end

function NewUserConnected(user)
	if UserBotTable[user.sName] then
		BotIn = UserBotTable[user.sName]
	else 
		BotIn = BOTName
	end	
	if VIPLogInTable[user.sName] then 
		SendToAll(BotIn,VIPLogInTable[user.sName])	
	elseif user.iProfile == 2 then 
		SendToAll(BotIn, "[VIP] "..user.sName..", has Connected")  
	elseif user.iProfile == nil then 
		SendToNick(BOTName, ""..user.sName..", has Connected" )
	end
	user:SendPM(BOTName,rules)
end

function UserDisconnected(user)
	if UserBotTable[user.sName] then
		BotIn = UserBotTable[user.sName]
	else 
		BotIn = BOTName
	end
	if VIPLogOutTable[user.sName] then 
		SendToAll(BotIn,VIPLogOutTable[user.sName])	
	elseif (user.sName == "fortywinks") then 
		SendToAll(BotIn, ""..fortywinks2.."") 
	elseif user.iProfile == 2 then 
		SendToAll(BOTName, "[VIP] "..user.sName..", has Disconnected")  
	end
end
--------- End Connection Functions ---------


function tokenize (inString,token) 
	_WORDS = {} 
	local matcher = "([^"..token.."]+)" 
	gsub(inString, matcher, function (w) tinsert(_WORDS,w) end) 
	return _WORDS 
end 

--------- End Load Table Functions ---------
function LoadOPLogInTables(user) 
	local handle = openfile(opin, "r") 
	if (handle) then 
		local line = read(handle) 
		while line do 
			local arrTmp = tokenize(line, strGSep) 
			if ((arrTmp[1] ~= nil) and (arrTmp[2] ~= nil)) then 
				OPLogInTable[arrTmp[1]] = arrTmp[2]
			end 
			line = read(handle) 
		end 
	closefile(handle) 
	end 
end 

function LoadOPLogOutTables(user) 
	local handle = openfile(opout, "r") 
	if (handle) then 
		local line = read(handle) 
		while line do 
			local arrTmp = tokenize(line, strGSep) 
			if ((arrTmp[1] ~= nil) and (arrTmp[2] ~= nil)) then 
				OPLogOutTable[arrTmp[1]] = arrTmp[2]
			end 
			line = read(handle) 
		end 
	closefile(handle) 
	end 
end 

function LoadVIPLogInTables(user) 
	local handle = openfile(vipin, "r") 
	if (handle) then 
		local line = read(handle) 
		while line do 
			local arrTmp = tokenize(line, strGSep) 
			if ((arrTmp[1] ~= nil) and (arrTmp[2] ~= nil)) then 
				VIPLogInTable[arrTmp[1]] = arrTmp[2]
			end 
			line = read(handle) 
		end 
	closefile(handle) 
	end 
end 

function LoadVIPLogOutTables(user) 
	local handle = openfile(vipout, "r") 
	if (handle) then 
		local line = read(handle) 
		while line do 
			local arrTmp = tokenize(line, strGSep) 
			if ((arrTmp[1] ~= nil) and (arrTmp[2] ~= nil)) then 
				VIPLogOutTable[arrTmp[1]] = arrTmp[2]
			end 
			line = read(handle) 
		end 
	closefile(handle) 
	end 
end 
--------- End Load Table Functions ---------

--------- Start Save Table Functions ---------
function SaveOPLogInTables(user) 
	writeto(opin)
	for key, value in OPLogInTable do
	OPLogInTable[key]=value
		write(key.."|"..value.."\n")
	end
   	writeto()
end

function SaveOPLogOutTables(user) 
	writeto(opout)
	for key, value in OPLogOutTable do
	OPLogOutTable[key]=value
		write(key.."|"..value.."\n")
	end
	writeto()
end

function SaveVIPLogInTables(user) 
	writeto(vipin)
	for key, value in VIPLogInTable do
	VIPLogInTable[key]=value
		write(key.."|"..value.."\n")
	end
   	writeto()
end

function SaveVIPLogOutTables(user) 
	writeto(vipout)
	for key, value in VIPLogOutTable do
	VIPLogOutTable[key]=value
		write(key.."|"..value.."\n")
	end
	writeto()
end
--------- End Save Table Functions ---------

------ DataArrival Scripts

function DataArrival(user,data)
	if strsub(data, 1, 1) == "<" then
		data=strsub(data,1,strlen(data)-1)
		s,e,cmd = strfind(data,"%b<>%s+(%S+)")

		if cmd == prefix.."changelogin" then
			_,_,cmd,message = strfind( data, "%b<>%s+(%S+)%s+(.*)" )
			if message == "" then
				user:SendPM(BOTName,"Please supply a new Login Message")
			elseif user.iProfile == 1 or user.iProfile == 0 then
				LoadOPLogInTables(user) 
				if OPLogInTable[user.sName] then  
					OPLogInTable[user.sName] = message
 					SaveOPLogInTables(user)
					user:SendPM(BOTName,"Login Changed to: "..message)
				end
				return 1
			elseif	user.iProfile == 2 then
				LoadVIPLogInTables(user) 
				if VIPLogInTable[user.sName] then  
					VIPLogInTable[user.sName] = message
 					SaveVIPLogInTables(user)
					user:SendPM(BOTName,"Login Changed to: "..message)
				end
				return 1
			end 
		elseif cmd == prefix.."changelogout" then
			_,_,cmd,message = strfind( data, "%b<>%s+(%S+)%s+(.*)" )
			if message == "" then
				user:SendPM(BOTName,"Please supply a new Logout Message")
			elseif user.iProfile == 1 or user.iProfile == 0 then
				LoadOPLogOutTables(user) 
				if OPLogOutTable[user.sName] then  
					OPLogOutTable[user.sName] = message
 					SaveOPLogOutTables(user)
					user:SendPM(BOTName,"Logout Changed to: "..message)
				end
				return 1
			elseif	user.iProfile == 2 then
				LoadVIPLogInTables(user) 
				if VIPLogInTable[user.sName] then  
					VIPLogInTable[user.sName] = message
 					SaveVIPLogInTables(user)
					user:SendPM(BOTName,"Logout Changed to: "..message)
				end
				return 1
			end
		elseif cmd == "!rules" then
			user:SendPM(BOTName,rules)
			return 1
		elseif cmd == "!reghelp" then
			user:SendPM(BOTName,reghelp)
			return 1
		elseif (cmd == prefix.."myip" ) then
			user:SendData(BOTName,"Your preciousssss IP issssss: "..user.sIP)
			return 1
		elseif (cmd == prefix.."mmop" ) then
			_,_,cmd,message = strfind( data, "%b<>%s+(%S+)%s+(.*)" )
			if user.iProfile == 1 or user.iProfile == 0 or user.iProfile == 4 then 
				SendPmToOps(user.sName, message)
				return 1
			end
		end 
	end
end

4 files are also needed
welcomeop.txt, welcomevip.txt, byeop.txt, byevip.txt

format
Username|message
ie
Stravides|Welcomes the OP Stravides

Hope to hear from ya soooon

Stravides
Stravides
For RPG Books, Mp3 & Videos
We host trivia  and the ever failing Smeagolbot

plop

ok couple hints:

lets start @ the top.

nothing wrong there. lol
but it would be handyer if you used txt files for reghelp and rules.

now function main confuses me a little bit, 1st you unreg 2 bots and next you reg 1 of them again.?????
adding of profiles is only needed 1x in your ptokax life, no need 2 do the same thing over and over again on every start of the script.

function DoRead misses a vital part but you don't seem 2 use it so no problem, but you can mod it 2 show the rules/reghelp.

function OpConnected i guess you wanne add or have stripped the share/slots/hub stuff here as it does nothing.
tiny spelling error below that, botin isn't the same as BotIn.
fun idea btw 2 have a botname per op.

function OpDisconnected, here you do the same desc/speed/email/share check, but why i don't know.

the functions for user/vip entering is perfect,nothing wrong there.

hope i don't sound 2 mean so far.

the loading of the tables, i think you should change that a bit.
a strfind can do it all a lot faster as you know 100% how the file looks.
i'll give you a hint on that:
username|text  ---->   "(.+)|(.+)"

now you allready say yourself it's getting big.
you now have 4 save and 4 load functions, why not half that number 2 start with by stuffing the ops and vips in the same table.?
l8er you can even half that again.
no need 2 transfer user 2 these functions as they aren't used anymore SaveVIPLogInTables() whill do fine.

oke finaly DataArrival.
not much 2 say here looks great, got just 2 small things 2 say here.
loading of the tables isn't needed as they are in memory allready, you only need 2 safe here after changing.
which you do.
the other things is even smaller, everywhere you use that nice prefix except on rules and reghelp.
just looks nicer if you use the prefix there 2.

just did a preview on my post and it looks like a lot of homework. lol
take it step for step and maby start with the loading of the files.
so this tread stays in 1 line 2 learn, I bet/hope your not the only 1 trying 2 make this script. lol
but anyway, keep going like this, your doing great.

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

Stravides

QuoteOriginally posted by plop

but it would be handyer if you used txt files for reghelp and rules. Done

now function main confuses me a little bit, 1st you unreg 2 bots and next you reg 1 of them again.?????
adding of profiles is only needed 1x in your ptokax life, no need 2 do the same thing over and over again on every start of the script.
Done legacy code from when I had this changing bot name

function DoRead misses a vital part but you don't seem 2 use it so no problem, but you can mod it 2 show the rules/reghelp. Done not required

function OpConnected i guess you wanne add or have stripped the share/slots/hub stuff here as it does nothing.Done
tiny spelling error below that, botin isn't the same as BotIn.Done
fun idea btw 2 have a botname per op.

function OpDisconnected, here you do the same desc/speed/email/share check, but why i don't know.Done

Not sure on this bit tho...
the loading of the tables, i think you should change that a bit.
a strfind can do it all a lot faster as you know 100% how the file looks.
i'll give you a hint on that:
username|text  ---->   "(.+)|(.+)"
 
 

now you allready say yourself it's getting big.
you now have 4 save and 4 load functions, why not half that number 2 start with by stuffing the ops and vips in the same table.?
l8er you can even half that again.Done
no need 2 transfer user 2 these functions as they aren't used anymore SaveVIPLogInTables() whill do fine.Done

oke finaly DataArrival.
not much 2 say here looks great, got just 2 small things 2 say here.
loading of the tables isn't needed as they are in memory allready, you only need 2 safe here after changing.Done
which you do.
the other things is even smaller, everywhere you use that nice prefix except on rules and reghelp.
just looks nicer if you use the prefix there 2.Done

--    Developed By Stravides, tutored by Plop and the Lua boards
--    Many thanks to all that made this possible..
--    OriginalBOTName		= "Smeagol"
--    OriginalHubAdress 	= "RPGBooks-Cymru.no-ip.org"
--    Variables  

BOTName="Smeagol"
HubAdress = "RPGBooks-Cymru.no-ip.org"
ScriptVersion = "Testing Beta Version V7.00" 
BOTNameInfo = "$MyINFO $ALL "..BOTName.." <++V:7.00 Smeagol $ $the Precioussss"..strchar( 1 ).."$Stravides@RPGBooks-Cymru.no-ip.org$" 
version = BOTName.." "..ScriptVersion 
prefix = "!"
strGSep = "|" 

log_in="logintext.txt"
log_out ="logouttext.txt"

ptokaxcommands = {
	op = 1, drop = 1, ban = 1, unban = 1, nickban = 1, getbanlist = 1,
	getinfo = 1, gag = 1, ungag = 1, banip = 1, ipinfo = 1, iprangeinfo = 1,
	userinfo = 1, clrtempban = 1, stat = 1 }

ptokax2commands = {
	clrpermban = 1, topic = 1, reloadtxt = 1 }

dofile("data.cfg");  -- this holds the rules and text files

UserBotTable = {
["Stravides"]="Thanatos",
["Blumpy"]="King Dung",
["Morgyn"]="Guest OP",
["Kyoya"]="Guest OP",
["Waylander"]="Scoobie",
["Tumnakitty"]="Bast",
};

LogInTable = { };
LogOutTable = { };

function Main() 
	frmHub:UnregBot(BOTName)
	frmHub:RegBot(BOTName) 
	SendToAll(BOTNameInfo)
	LoadLogInTables()
	LoadLogOutTables()

end 

--------- Begin Connection/Diconnection Functions ---------
function OpConnected(user)
	local BotIn = ""
	if UserBotTable[user.sName] then
		BotIn = UserBotTable[user.sName]
	else 
		BotIn = BOTName
	end	
	if LogInTable[user.sName] then 
		SendToAll(BotIn,LogInTable[user.sName])	
	else    
		SendToAll(BOTName, "[OPS] "..user.sName.." has joined the hub") 
	end
	user:SendPM(BOTName,rules)
end

function OpDisconnected(user)
	if UserBotTable[user.sName] then
		BotIn = UserBotTable[user.sName]
	else 
		BotIn = BOTName
	end
	if LogOutTable[user.sName] then 
		SendToAll(BotIn,LogOutTable[user.sName])	
	elseif user.iProfile == 1 then 
		SendToAll(BOTName, "[OP] "..user.sName.." Has Left the Hub")  
	end
end

function NewUserConnected(user)
	if UserBotTable[user.sName] then
		BotIn = UserBotTable[user.sName]
	else 
		BotIn = BOTName
	end	
	if LogInTable[user.sName] then 
		SendToAll(BotIn,LogInTable[user.sName])	
	elseif user.iProfile == 2 then 
		SendToAll(BotIn, "[VIP] "..user.sName..", has Connected")  
	elseif user.iProfile == nil then 
		SendToNick(BOTName, ""..user.sName..", has Connected" )
	end
	user:SendPM(BOTName,rules)
end

function UserDisconnected(user)
	if UserBotTable[user.sName] then
		BotIn = UserBotTable[user.sName]
	else 
		BotIn = BOTName
	end
	if LogOutTable[user.sName] then 
		SendToAll(BotIn,LogOutTable[user.sName])	
	elseif (user.sName == "fortywinks") then 
		SendToAll(BotIn, ""..fortywinks2.."") 
	elseif user.iProfile == 2 then 
		SendToAll(BOTName, "[VIP] "..user.sName..", has Disconnected")  
	end
end
--------- End Connection Functions ---------


function tokenize (inString,token) 
	_WORDS = {} 
	local matcher = "([^"..token.."]+)" 
	gsub(inString, matcher, function (w) tinsert(_WORDS,w) end) 
	return _WORDS 
end 

--------- End Load Table Functions ---------
function LoadLogInTables() 
	local handle = openfile(log_in, "r") 
	if (handle) then 
		local line = read(handle) 
		while line do 
			local arrTmp = tokenize(line, strGSep) 
			if ((arrTmp[1] ~= nil) and (arrTmp[2] ~= nil)) then 
				LogInTable[arrTmp[1]] = arrTmp[2]
			end 
			line = read(handle) 
		end 
	closefile(handle) 
	end 
end 

function LoadLogOutTables() 
	local handle = openfile(log_out, "r") 
	if (handle) then 
		local line = read(handle) 
		while line do 
			local arrTmp = tokenize(line, strGSep) 
			if ((arrTmp[1] ~= nil) and (arrTmp[2] ~= nil)) then 
				LogOutTable[arrTmp[1]] = arrTmp[2]
			end 
			line = read(handle) 
		end 
	closefile(handle) 
	end 
end 
--------- End Load Table Functions ---------

--------- Start Save Table Functions ---------
function SaveLogInTables() 
	writeto(log_in)
	for key, value in LogInTable do
	LogInTable[key]=value
		write(key.."|"..value.."\n")
	end
   	writeto()
end

function SaveLogOutTables() 
	writeto(log_out)
	for key, value in LogOutTable do
	LogOutTable[key]=value
		write(key.."|"..value.."\n")
	end
	writeto()
end
--------- End Save Table Functions ---------

------ DataArrival Scripts

function DataArrival(user,data)
	if strsub(data, 1, 1) == "<" then
		data=strsub(data,1,strlen(data)-1)
		s,e,cmd = strfind(data,"%b<>%s+(%S+)")

		if cmd == prefix.."changelogin" then
			_,_,cmd,message = strfind( data, "%b<>%s+(%S+)%s+(.*)" )
			if message == "" then
				user:SendPM(BOTName,"Please supply a new Login Message")
			elseif user.iProfile == 1 or user.iProfile == 0 or user.iProfile == 2 then
				LoadLogOutTables()
				if LogInTable[user.sName] then  
					LogInTable[user.sName] = message
 					SaveLogInTables()
					user:SendPM(BOTName,"Login Changed to: "..message)
				end
				return 1
			end 
		elseif cmd == prefix.."changelogout" then
			_,_,cmd,message = strfind( data, "%b<>%s+(%S+)%s+(.*)" )
			if message == "" then
				user:SendPM(BOTName,"Please supply a new Logout Message")
			elseif user.iProfile == 1 or user.iProfile == 0 or user.iProfile == 2 then
				LoadLogOutTables()  
				if LogOutTable[user.sName] then  
					LogOutTable[user.sName] = message
 					SaveLogOutTables()
					user:SendPM(BOTName,"Logout Changed to: "..message)
				end
				return 1
			end
		elseif cmd == prefix.."rules" then
			user:SendPM(BOTName,rules)
			return 1
		elseif cmd == prefix.."reghelp" then
			user:SendPM(BOTName,reghelp)
			return 1
		elseif (cmd == prefix.."myip" ) then
			user:SendData(BOTName,"Your preciousssss IP issssss: "..user.sIP)
			return 1
		elseif (cmd == prefix.."mmop" ) then
			_,_,cmd,message = strfind( data, "%b<>%s+(%S+)%s+(.*)" )
			if user.iProfile == 1 or user.iProfile == 0 or user.iProfile == 4 then 
				SendPmToOps(user.sName, message)
				return 1
			end
		end 
	end
end
Stravides
For RPG Books, Mp3 & Videos
We host trivia  and the ever failing Smeagolbot

Stravides

forget that, I suggest that this is whats needed

function LoadLogInTables() 
	local handle = openfile(log_in, "r") 
	if (handle) then 
		local line = read(handle) 
		while line do 
		username,text = strfind(line, "(.+)|(.+)")
			if ((username ~= nil) and (text ~= nil)) then 
				LogInTable[username] = text
			end 
			line = read(handle) 
		end 
	closefile(handle) 
	end 
end 

function LoadLogOutTables() 
	local handle = openfile(log_out, "r") 
	if (handle) then 
		local line = read(handle) 
		while line do 
		username,text = strfind(line, "(.+)|(.+)")
			if ((username ~= nil) and (text ~= nil)) then 
				LogInTable[username] = text
			end 
			line = read(handle) 
		end 
	closefile(handle) 
	end 
end
Stravides
For RPG Books, Mp3 & Videos
We host trivia  and the ever failing Smeagolbot

Stravides

EEEEEEK

Thats not working am I losing my mind.... :(  ;(
Stravides
For RPG Books, Mp3 & Videos
We host trivia  and the ever failing Smeagolbot

plop

#41
QuoteOriginally posted by Stravides
forget that, I suggest that this is whats needed

function LoadLogInTables() 
	local handle = openfile(log_in, "r") 
	if (handle) then 
		local line = read(handle) 
		while line do 
		username,text = strfind(line, "(.+)|(.+)")
			if ((username ~= nil) and (text ~= nil)) then 
				LogInTable[username] = text
			end 
			line = read(handle) 
		end 
	closefile(handle) 
	end 
end 

function LoadLogOutTables() 
	local handle = openfile(log_out, "r") 
	if (handle) then 
		local line = read(handle) 
		while line do 
		username,text = strfind(line, "(.+)|(.+)")
			if ((username ~= nil) and (text ~= nil)) then 
				LogInTable[username] = text
			end 
			line = read(handle) 
		end 
	closefile(handle) 
	end 
end
your really close but your forgetting a vital part for strfind 2 work.
for a hint, check how you find the commands in DataArrival

i personaly never use handles on loading/saving.
if readfrom(file) then
   readfrom(file)
does the same as opening with handles in read mode.
1st line is just a check 2 see if the file excists.
but this a real personal thing, most scripters are using the handles way.

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

Stravides

#42
QuoteOriginally posted by plop

function LoadLogInTables() 
	local handle = openfile(log_in, "r") 
	if (handle) then 
		local line = read(handle) 
		while line do 
		username,text = strfind(line, "(.+)|(.+)")
			if ((username ~= nil) and (text ~= nil)) then 
				LogInTable[username] = text
			end 
			line = read(handle) 
		end 
	closefile(handle) 
	end 
end

your really close but your forgetting a vital part for strfind 2 work.  for a hint, check how you find the commands in DataArrival
plop

ok I think the code below is missing, but does that mean that i need to pass data to the load function ?

if strsub(data, 1, 1) == "<" then
		data=strsub(data,1,strlen(data)-1)
		s,e,cmd = strfind(data,"%b<>%s+(.+)|(.+)")
Stravides
For RPG Books, Mp3 & Videos
We host trivia  and the ever failing Smeagolbot

plop

compair these 2.
s,e,cmd = strfind(data,"%b<>%s+(%S+)")   <--- from DataArrival.
username,text = strfind(line, "(.+)|(.+)")  <---- from your load function.

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

Stravides

QuoteOriginally posted by plop
compair these 2.
s,e,cmd = strfind(data,"%b<>%s+(%S+)")   <--- from DataArrival.
username,text = strfind(line, "(.+)|(.+)")  <---- from your load function.

plop
having said that, is this the corect syntax ?

s,e,cmd,username,text = strfind(data,"%b<>%s+(.+)|(.+)")
Stravides
For RPG Books, Mp3 & Videos
We host trivia  and the ever failing Smeagolbot

plop

QuoteOriginally posted by Stravides
QuoteOriginally posted by plop
compair these 2.
s,e,cmd = strfind(data,"%b<>%s+(%S+)")   <--- from DataArrival.
username,text = strfind(line, "(.+)|(.+)")  <---- from your load function.

plop
having said that, is this the corect syntax ?

s,e,cmd,username,text = strfind(data,"%b<>%s+(.+)|(.+)")
now your mixing them up.
the strfind in DataArrival is correct, but the 1 on loading of the file is wrong.
the s,e, part is missing there, which results in username and text getting the vallue which normaly s and e would get.

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

Stravides

Sorry 2Watt bulb here again, musta played with this in any number of ways.. .still doesnt work..

The pattern that I am looking for is (.+)|(.+),
Now if I read your post on pattern matching
All of those chars are Magic except for the | Is this causing me a problem as I'm not using an escape char ?  I really am not sure on this one at all.

again in waiting

Stravides
The Dim Padawan
Stravides
For RPG Books, Mp3 & Videos
We host trivia  and the ever failing Smeagolbot

plop

this 1 is correct, don't touch it. lol
s,e,cmd = strfind(data,"%b<>%s+(%S+)")   <--- from DataArrival.

this 1 is just missing the s,e, part.
username,text = strfind(line, "(.+)|(.+)")  <---- from your load function.

this is all you need 2 do 2 fix it.
s,e,username,text = strfind(line, "(.+)|(.+)")

1 side note, i'm working on part 2 of the pattern matching howto which explains the magic stuff.

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

Stravides

Excellent, await magics, ammends code to this... sure I've tried this before :)

but will post results here :)
Stravides
For RPG Books, Mp3 & Videos
We host trivia  and the ever failing Smeagolbot

plop

QuoteOriginally posted by Stravides
Excellent, await magics, ammends code to this... sure I've tried this before :)

but will post results here :)
pattern matching part 2 is posted, same thread as part 1.

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

SMF spam blocked by CleanTalk