HOW-TO: Write you own bot = Lesson 9
 

News:

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

HOW-TO: Write you own bot = Lesson 9

Started by pHaTTy, 19 December, 2003, 20:36:44

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

pHaTTy

Ok i am going to be more advanced here, and i will notice alot of things that are alot different to other scripters, you will see my style of programming





ok what we had from long time ago :

Bot = "Keiko" 

version = "0.8" 
NEWCON = 1 
prefix = "!"
TimeMins = 5  --set it to 5 mins
SendC = SendToAll

MessageTimer = 1
BadWord={}

TheBadWords = { "fuck", "twat", "suck", "fucker" }

function Main() 
	frmHub:RegBot(Bot) 
	SetTimer(TimeMins*60000)
	StartTimer()
end 

function OnTimer()
	if MessageTimer == 1 then 
		randomtimer = random(2) --only 2 data's
		if randomtimer == 1 then
			SendC(Bot,"-------------------------------")
			SendC(Bot,"--Write your own bot lesson "..version.."--")
			SendC(Bot,"-------------------------------")
		elseif randomtimer == 2 then
			SendC(Bot,"-----------------------------------------")
			SendC(Bot,"--This lesson bot was created by Phatty--")
			SendC(Bot,"-----------------------------------------")
		end
	end
end

function NewUserConnected(user) 
	if NEWCON == 1 then 
		user:SendData (Bot,"A User has connected") 
	end 
end 

function OpConnected(user) 
Pillock = GetProfileName(user.iProfile)
thisisthevariable = random(5)
	if thisisthevariable == 1 then
		SendC(Bot,user.sName.." has entered the hub") 

	elseif thisisthevariable == 2 then
		SendC(Bot,Pillock.." "..user.sName..",has entered, feel his wrath")  

	elseif thisisthevariable == 3 then
		SendC(Bot,user.sName.." is one of the big bosses, who just entered") 

	elseif thisisthevariable == 4 then
		SendC(Bot,user.sName.." has sneaked into the hub")  

	elseif thisisthevariable == 5 then
		SendC(Bot,user.sName.." has just kicked down the door") 
	end
end

function deathfunction(user) -- reciving name of user from deathfunction(user)
	dead = random(5)
	if dead == 1 then
		SendC(Bot,user.sName.." has killed their self, and fell out the hub")
	elseif dead == 2 then
		SendC(Bot,user.sName.." has killed their self, what a pillock")
	elseif dead == 3 then
		SendC(Bot,user.sName.." is a total nutter, they killed em'self")
	elseif dead == 4 then
		SendC(Bot,user.sName.." is now dead, falling from the hub")
	elseif dead == 5 then
		SendC(Bot,user.sName.." jumps a mile high with a rope around their nech and drops down a hole, thats the last we seen of em")
	end
	user:Disconnect()
end


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+)") 
		for key,checkWord in TheBadWords do
			if (strfind(data, checkWord, 1, 1)) then
				if BadWord[user.sName]==nil then
					BadWord[user.sName]=0
				elseif BadWord[user.sName]== 3 then
					user:Disconnect()
				else
					BadWord[user.sName]=BadWord[user.sName]+1
				end
			return 1
			end
		end
		if cmd == prefix.."version" then 
			user:SendData(Bot,"This bot is Learn to write a bot version: "..version.." by Phatty") 
		return 1 
		elseif cmd == prefix.."help" then 
			user:SendData(Bot,"This is where the help text wud go, bt im not gonna waste my time :P") 
		return 1 
		elseif cmd == prefix.."death" then 
			deathfunction(user)
		return 1 
		end 
	end
end

now im gonna show some of the most common functions such as mass message and some i have been asked for.....


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+)") 
		for key,checkWord in TheBadWords do
			if (strfind(data, checkWord, 1, 1)) then
				if BadWord[user.sName]==nil then
					BadWord[user.sName]=0
				elseif BadWord[user.sName]== 3 then
					user:Disconnect()
				else
					BadWord[user.sName]=BadWord[user.sName]+1
				end
			return 1
			end
		end
		if cmd == prefix.."version" then 
			user:SendData(Bot,"This bot is Learn to write a bot version: "..version.." by Phatty") 
		return 1 
		elseif cmd == prefix.."help" then 
			user:SendData(Bot,"This is where the help text wud go, bt im not gonna waste my time :P") 
		return 1 
		elseif cmd == prefix.."death" then 
			deathfunction(user)
		return 1 
		elseif (cmd==prefix.."mass") then
			if user.bOperator then
			s,e,cmd,message = strfind(data,"%s+(%S+)%s+(.*)")
				SendC(Bot," "..user.sName..": "..message)
				end
			end
		end 
	end
end


now lets add a message if they dont enter a message to send

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+)") 
		for key,checkWord in TheBadWords do
			if (strfind(data, checkWord, 1, 1)) then
				if BadWord[user.sName]==nil then
					BadWord[user.sName]=0
				elseif BadWord[user.sName]== 3 then
					user:Disconnect()
				else
					BadWord[user.sName]=BadWord[user.sName]+1
				end
			return 1
			end
		end
		if cmd == prefix.."version" then 
			user:SendData(Bot,"This bot is Learn to write a bot version: "..version.." by Phatty") 
		return 1 
		elseif cmd == prefix.."help" then 
			user:SendData(Bot,"This is where the help text wud go, bt im not gonna waste my time :P") 
		return 1 
		elseif cmd == prefix.."death" then 
			deathfunction(user)
		return 1 
		elseif (cmd==prefix.."mass") then
			if user.bOperator then
				s,e,cmd,message = strfind(data,"%s+(%S+)%s+(.*)")
				if message == nil then
					user:SendData(Bot,"Please enter a message to mass")
					return 1
				end
				SendC(Bot," "..user.sName..": "..message)
				end
			end
		end 
	end
end


Now we will add a kick/kicktempban/ban

Bot = "Keiko" 

version = "0.9" 
NEWCON = 1 
prefix = "!"
TimeMins = 5  --set it to 5 mins
TimeToBan = "15" -- the tempban time
SendC = SendToAll

MessageTimer = 1
BadWord={}

TheBadWords = { "fuck", "twat", "suck", "fucker" }

function Main() 
	frmHub:RegBot(Bot) 
	SetTimer(TimeMins*60000)
	StartTimer()
end 

function OnTimer()
	if MessageTimer == 1 then 
		randomtimer = random(2) --only 2 data's
		if randomtimer == 1 then
			SendC(Bot,"-------------------------------")
			SendC(Bot,"--Write your own bot lesson "..version.."--")
			SendC(Bot,"-------------------------------")
		elseif randomtimer == 2 then
			SendC(Bot,"-----------------------------------------")
			SendC(Bot,"--This lesson bot was created by Phatty--")
			SendC(Bot,"-----------------------------------------")
		end
	end
end

function NewUserConnected(user) 
	if NEWCON == 1 then 
		user:SendData (Bot,"A User has connected") 
	end 
end 

function OpConnected(user) 
Pillock = GetProfileName(user.iProfile)
thisisthevariable = random(5)
	if thisisthevariable == 1 then
		SendC(Bot,user.sName.." has entered the hub") 

	elseif thisisthevariable == 2 then
		SendC(Bot,Pillock.." "..user.sName..",has entered, feel his wrath")  

	elseif thisisthevariable == 3 then
		SendC(Bot,user.sName.." is one of the big bosses, who just entered") 

	elseif thisisthevariable == 4 then
		SendC(Bot,user.sName.." has sneaked into the hub")  

	elseif thisisthevariable == 5 then
		SendC(Bot,user.sName.." has just kicked down the door") 
	end
end

function deathfunction(user) -- reciving name of user from deathfunction(user)
	dead = random(5)
	if dead == 1 then
		SendC(Bot,user.sName.." has killed their self, and fell out the hub")
	elseif dead == 2 then
		SendC(Bot,user.sName.." has killed their self, what a pillock")
	elseif dead == 3 then
		SendC(Bot,user.sName.." is a total nutter, they killed em'self")
	elseif dead == 4 then
		SendC(Bot,user.sName.." is now dead, falling from the hub")
	elseif dead == 5 then
		SendC(Bot,user.sName.." jumps a mile high with a rope around their nech and drops down a hole, thats the last we seen of em")
	end
	user:Disconnect()
end


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+)") 
		for key,checkWord in TheBadWords do
			if (strfind(data, checkWord, 1, 1)) then
				if BadWord[user.sName]==nil then
					BadWord[user.sName]=0
				elseif BadWord[user.sName]== 3 then
					user:Disconnect()
				else
					BadWord[user.sName]=BadWord[user.sName]+1
				end
			return 1
			end
		end
		if cmd == prefix.."version" then 
			user:SendData(Bot,"This bot is Learn to write a bot version: "..version.." by Phatty") 
		return 1 
		elseif cmd == prefix.."help" then 
			user:SendData(Bot,"This is where the help text wud go, bt im not gonna waste my time :P") 
		return 1 
		elseif cmd == prefix.."death" then 
			deathfunction(user)
		return 1 
		elseif (cmd==prefix.."mass") then
			if user.bOperator then
				s,e,cmd,message = strfind(data,"%s+(%S+)%s+(.*)")
				if message == nil then
					user:SendData(Bot,"Please enter a message to mass")
					return 1
				else
					SendC(Bot," "..user.sName..": "..message)
				end
			end
		elseif (cmd==prefix.."kick") then
			s,e,cmd,whotokick = strfind(data,"%s+(%S+)%s+(%S+)")
			if whotokick == nil then
				return 1
			else
				twat = GetItemByName(whotokick)
				twat:Disconnect() --without tempban
			end
		elseif (cmd==prefix.."temp") then
			s,e,cmd,whotokick = strfind(data,"%s+(%S+)%s+(%S+)")
			if whotokick == nil then
				return 1
			else
				twat = GetItemByName(whotokick)
				twat:TimeBan(TimeToBan) --ban for specified
			end
		elseif (cmd==prefix.."ban") then
			s,e,cmd,whotokick = strfind(data,"%s+(%S+)%s+(%S+)")
			if whotokick == nil then
				return 1
			else
				twat = GetItemByName(whotokick)
				twat:Ban() --perm ban
			end	
		end 
	end
end


enjoy this little lesson and try add some kick messages ;)

bbl for more

-phatty
Resistance is futile!

Tarokkk

What is TWAT in the script ?

elseif (cmd==prefix.."temp") then
			s,e,cmd,whotokick = strfind(data,"%s+(%S+)%s+(%S+)")
			if whotokick == nil then
				return 1
			else
				twat = GetItemByName(whotokick)
				twat:TimeBan(TimeToBan) --ban for specified
			end

Tarokkk

Oh I'm sorry :D I know what is it ...

twat = user :D

pHaTTy

lol, yep ;)

well technically whotokick = twat / if whotokick is nil then its nothink, if > 0 then twat = user ;)
Resistance is futile!

Tarokkk

I think this script don't work

twat nil value ......

pHaTTy

well a mistake on ur end or you using an old ptokax ;)

works for me :P
Resistance is futile!

Tarokkk

I type !kick somebody and the error in the ptoka

--
Syntax Error: attempt to index global `twat' (a nil value)
--

NotRabidWombat

#7
s,e,cmd,whotokick = strfind(data,"%s+(%S+)%s+(%S+)")

This regex isn't safe. You never change data so its still in the same form, msg, less the pipe. I would suggest you extract the message and make it the new data like so:

local s,e,data, cmd = strfind(data,"%b<>%s+((%S+).+)")

Now you won't have the nick part that is causing the problem. Additionally, you can reuse variables that you no longer need such as:

whotokick = GetItemByName(whotokick);

Plus the use of local variables and variable names that make sense (twat?) would be a lot more helpful. It is also good practice to check ALL user input dependent variables for nil results. A person could type !kick NonExistantNick and this will restult in a nil returned from GetItemByName.

-NotRabidWombat


I like childish behavior. Maybe this post will be deleted next.

Tarokkk

IT's Gooood :D

Tarokkk

I did that but I don't understand the new strfind.. :(

So the script is stopped when the user name isn't real

Bot = "Keiko" 

-------
version = "0.9" 
NEWCON = 1 
prefix = "!"
TimeMins = 5  --set it to 5 mins
TimeToBan = "15" -- the tempban time
SendC = SendToAll

MessageTimer = 1
BadWord={}

TheBadWords = { "fuck", "twat", "suck", "fucker" }

function Main() 
	frmHub:RegBot(Bot) 
	SetTimer(TimeMins*60000)
	StartTimer()
end 

function OnTimer()
	if MessageTimer == 1 then 
		randomtimer = random(2) --only 2 data's
		if randomtimer == 1 then
			SendC(Bot,"-------------------------------")
			SendC(Bot,"--Write your own bot lesson "..version.."--")
			SendC(Bot,"-------------------------------")
		elseif randomtimer == 2 then
			SendC(Bot,"-----------------------------------------")
			SendC(Bot,"--This lesson bot was created by Phatty--")
			SendC(Bot,"-----------------------------------------")
		end
	end
end

function NewUserConnected(user) 
	if NEWCON == 1 then 
		user:SendData (Bot,"A User has connected") 
	end 
end 

function OpConnected(user) 
Pillock = GetProfileName(user.iProfile)
thisisthevariable = random(5)
	if thisisthevariable == 1 then
		SendC(Bot,user.sName.." has entered the hub") 

	elseif thisisthevariable == 2 then
		SendC(Bot,Pillock.." "..user.sName..",has entered, feel his wrath")  

	elseif thisisthevariable == 3 then
		SendC(Bot,user.sName.." is one of the big bosses, who just entered") 

	elseif thisisthevariable == 4 then
		SendC(Bot,user.sName.." has sneaked into the hub")  

	elseif thisisthevariable == 5 then
		SendC(Bot,user.sName.." has just kicked down the door") 
	end
end

function deathfunction(user) -- reciving name of user from deathfunction(user)
	dead = random(5)
	if dead == 1 then
		SendC(Bot,user.sName.." has killed their self, and fell out the hub")
	elseif dead == 2 then
		SendC(Bot,user.sName.." has killed their self, what a pillock")
	elseif dead == 3 then
		SendC(Bot,user.sName.." is a total nutter, they killed em'self")
	elseif dead == 4 then
		SendC(Bot,user.sName.." is now dead, falling from the hub")
	elseif dead == 5 then
		SendC(Bot,user.sName.." jumps a mile high with a rope around their nech and drops down a hole, thats the last we seen of em")
	end
	user:Disconnect()
end


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+)") 
		for key,checkWord in TheBadWords do
			if (strfind(data, checkWord, 1, 1)) then
				if BadWord[user.sName]==nil then
					BadWord[user.sName]=0
				elseif BadWord[user.sName]== 3 then
					user:Disconnect()
				else
					BadWord[user.sName]=BadWord[user.sName]+1
				end
			return 1
			end
		end
		if cmd == prefix.."version" then 
			user:SendData(Bot,"This bot is Learn to write a bot version: "..version.." by Phatty") 
		return 1 
		elseif cmd == prefix.."help" then 
			user:SendData(Bot,"This is where the help text wud go, bt im not gonna waste my time :P") 
		return 1 
		elseif cmd == prefix.."death" then 
			deathfunction(user)
		return 1 
		elseif (cmd==prefix.."mass") then
			if user.bOperator then
				s,e,cmd,message = strfind(data,"%s+(%S+)%s+(.*)")
				if message == nil then
					user:SendData(Bot,"Please enter a message to mass")
					return 1
				else
					SendC(Bot," "..user.sName..": "..message)
				end
			end

		elseif (cmd==prefix.."kick") then
			local s,e, cmd,whotokick,mess = strfind(data,"%s+(%S+)%s+(%S+)%s+(.*)")

			if whotokick == nil then
				user:SendData (Bot, "The User isn't in the HUB!")
				return 1 
			elseif mess == nil then
				user:SendData (Bot, "You forgot the reason...")
				return 1
			else
			twat = GetItemByName(whotokick)
			twat:SendPM (Bot, "You are being kicked by  "..user.sName.." because:   "..mess)
			twat:Disconnect()
		end		

	
		elseif (cmd==prefix.."temp") then
			s,e,cmd,whotokick,mess = strfind(data,"%s+(%S+)%s+(%S+)%s+(.*)")
			if whotokick == nil then
				return 1
			else
				twat = GetItemByName(whotokick)
				twat:SendPM (Bot, "You are being timbanned for "..TimeToBan.." minutes by  "..user.sName.." because:   "..mess)
				twat:TimeBan(TimeToBan) --ban for specified
			end
		elseif (cmd==prefix.."ban") then
			s,e,cmd,whotokick,mess = strfind(data,"%s+(%S+)%s+(%S+)%s+(.*)")
			if whotokick == nil then
				return 1
			else
				twat = GetItemByName(whotokick)
				twat:SendPM(Bot, "YOUR ASS IS BANNED !!!          because:   "..mess)
				twat:Ban() --perm ban
			end	
		end 
	end
end

Intel

Cool I went trough all And Got many explanations + and good overview of how it functions and how to write a bit :) mainly thanks to (uk-kingdom)pH?tt? and a few others who corrected & ASked a few question which i might asked if i was apart of the forum 1 month back..

But I have a Small question...

prefix = "!" if i want, cause i change it to prefix = "#" or what ever i want it to be ?? I am 99 % sure i can but asking for a safty reason...hehe

Also Where can I find the commands for Lua such as
SendC , NEWCON , OpConnected ....  Many their are many thousand others which we dont use, which i want to use ....

Once again Thanks :) If their are more lessons, Me in 2 :)
Punnakku

SaintSinner

#11
QuoteOriginally posted by Intel
Cool I went trough all And Got many explanations + and good overview of how it functions and how to write a bit :) mainly thanks to (uk-kingdom)pH?tt? and a few others who corrected & ASked a few question which i might asked if i was apart of the forum 1 month back..

But I have a Small question...

prefix = "!" if i want, cause i change it to prefix = "#" or what ever i want it to be ?? I am 99 % sure i can but asking for a safty reason...hehe

Also Where can I find the commands for Lua such as
SendC , NEWCON , OpConnected ....  Many their are many thousand others which we dont use, which i want to use ....

Once again Thanks :) If their are more lessons, Me in 2 :)



Ok im not a lua expert yet...but i will try to explain as good as i can, from what i learned...
prefix = "!" yes you can use whatever prefix you want, that is why its defined as prefix equals "this", just make sure that its in the "".
you could have:
prefix = "!"
elseif cmd == prefix.."help" then
--hubowners can define the prefixes themselves.
--if you have
elseif cmd == "!help" then
--then the hubowners have to use ! or edit each
--command himself.

SendC is defined in the script as
SendC = SendToAll
so instead of typing SendToAll() all the time you will just type SendC().


OpConnected and other functions are listed in the Docs folder of the hubsoft.
i

m still not sure on the NEWCON
but from what i gathered its new connection
function NewUserConnected(user)
   if NEWCON == 1 then
   user:SendData (Bot,"A User has connected")
im guessing its there to be able to
shut is to shut it on and off, for when you need it.
0=off     will not send a message
1=on     will send a message

   


pHaTTy

QuoteOriginally posted by SaintSinner
QuoteOriginally posted by Intel
Cool I went trough all And Got many explanations + and good overview of how it functions and how to write a bit :) mainly thanks to (uk-kingdom)pH?tt? and a few others who corrected & ASked a few question which i might asked if i was apart of the forum 1 month back..

But I have a Small question...

prefix = "!" if i want, cause i change it to prefix = "#" or what ever i want it to be ?? I am 99 % sure i can but asking for a safty reason...hehe

Also Where can I find the commands for Lua such as
SendC , NEWCON , OpConnected ....  Many their are many thousand others which we dont use, which i want to use ....

Once again Thanks :) If their are more lessons, Me in 2 :)



Ok im not a lua expert yet...but i will try to explain as good as i can, from what i learned...
prefix = "!" yes you can use whatever prefix you want, that is why its defined as prefix equals "this", just make sure that its in the "".
you could have:
prefix = "!"
elseif cmd == prefix.."help" then
--hubowners can define the prefixes themselves.
--if you have
elseif cmd == "!help" then
--then the hubowners have to use ! or edit each
--command himself.

SendC is defined in the script as
SendC = SendToAll
so instead of typing SendToAll() all the time you will just type SendC().


OpConnected and other functions are listed in the Docs folder of the hubsoft.
i

m still not sure on the NEWCON
but from what i gathered its new connection
function NewUserConnected(user)
   if NEWCON == 1 then
   user:SendData (Bot,"A User has connected")
im guessing its there to be able to
shut is to shut it on and off, for when you need it.
0=off     will not send a message
1=on     will send a message



very well explained, well done :)
Resistance is futile!

Intel

Cool I am 100 into it now, are their more lessons ? I guess I have to try and try and try and suddenly i will be able to help many people in this forum...
is lua used anywhere else than scripting ? What else can we use Lua to ? Does anyone knows ?
Punnakku

pHaTTy

lua is a scripting langauge, you can integrate it into games, its often used in games such as homeworld and things like that, i am currently thinking of using it in a game for the AI Units....
Resistance is futile!

Intel

so lua is mainly for games...why has the author of Ptokax Choosen Lua and not Vb or C++...cause their their are many other  cool things we can make, not because i am much into scriptings but..if the new version can be both Vb & Lua then it would be cool.. ?


Quotemaybe wrong question in the wrong place but just shootes it out in the blue air....
Punnakku

pHaTTy

altho i find vb a nice language its pretty slow, and c++ has to many things you can do i guess i a popup window, so a good way to stop that is by using lua i suppose, and lua is a natural scripting language :)
Resistance is futile!

NotRabidWombat

VB is not as rich of language as lua (I usually find vbscript very cumbersome). C++ isn't really a scripting language because it has to be compiled (like the dlls used in winamp).
Lua is used in a lot more places than games. I've recently wrote a program that used lua as a scripting language to create robot navigational code.
It's becoming very popular because it is very easy to integrate and can be supported on many different OS platforms. You can also write your own lua standalone scripts that can do just about anything. Go to http://www.lua.org to find out all about it.

-NotRabidWombat


I like childish behavior. Maybe this post will be deleted next.

Gazza-95

phatty how long till the next lesson

Znupi

Hello ppl, glad 2 be here ... this is me first post here ... so here I go ...

Is there a command that logs out a bot ?? ... here's what i mean :

is there the oposite of frmHub:RegBot(Bot) ? if there is , pls tell me ...

6Marilyn6Manson6

Quote from: Znupi on 28 May, 2006, 23:04:21
Hello ppl, glad 2 be here ... this is me first post here ... so here I go ...

Is there a command that logs out a bot ?? ... here's what i mean :

is there the oposite of frmHub:RegBot(Bot) ? if there is , pls tell me ...

--Killbot LUA5
--
--by Mutor
--
--Removes a bot from main user listing by typing
--!killbot <botname>
--in main or...
--!listbot <botname>
--to restore botname.

SendMenu = "yes"    -- Send Command Menu? "yes"/"no"
--
--Set your profiles here
--[profileidx#] = 0 or 1
--0=No Menu, No Command / 1=Send Menu & Can use Command
Profiles = {
[-1] = 0, --Unregistered User
[0] = 1, --Master
[1] = 1, --Operator
[2] = 0, --Vip
[3] = 0, --Registered User
[4] = 1, --Moderator
[5] = 1, --NetFounder
}

--Set menu name or leave as is for hubname set in PtokaX
HubMenu = frmHub:GetHubBotName()

function NewUserConnected(user)
    if SendMenu == "yes" then
	   if Profiles[user.iProfile] ==1 then
		  customCMDS(user)
	   end
    end
end

OpConnected = NewUserConnected

--$UserCommand 1 X  Where -> 1=Hub Menu 2=User Menu 3=Hub/User Menu
function customCMDS(user)
	--user:SendData("$UserCommand 255 7")	--clear the menu first
	user:SendData("$UserCommand 1 1 "..HubMenu.."\\Bot Admin\\Remove Bot $<%[mynick]> !killbot %[line:BotNick]&#124;|")
	user:SendData("$UserCommand 1 2 "..HubMenu.."\\Bot Admin\\Remove Bot $<%[mynick]> !killbot %[nick]&#124;|")
	user:SendData("$UserCommand 1 3 "..HubMenu.."\\Bot Admin\\Restore Bot $<%[mynick]> !listbot %[line:BotNick]&#124;|")
end

function ChatArrival(user, data)
	if Profiles[user.iProfile] ==1 then
		data=string.sub(data,1,string.len(data)-1)
			s,e,cmd,name = string.find(data,"%b<>%s+(%S+)%s+(%S+)")
				if cmd=="!killbot" then
					frmHub:UnregBot(name)
					return 1
				elseif cmd=="!listbot" then
					frmHub:RegBot(name)
					return 1
				end
		end
end


You can study this script ^_^


6Marilyn6Manson6


Znupi

Is there a function or smth like ... delay ? like ... make it w8 a few seconds / miliseconds before moving on with the script ...

CrazyGuy

You'll have to work with timers.

SetTimer(timerinterval in miliseconds)

StartTimer()   --starts the timer

OnTimer()  --code to be executes when timerinterval has passed

StopTimer()  --stops the timer

SMF spam blocked by CleanTalk