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
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
Oh I'm sorry :D I know what is it ...
twat = user :D
lol, yep ;)
well technically whotokick = twat / if whotokick is nil then its nothink, if > 0 then twat = user ;)
I think this script don't work
twat nil value ......
well a mistake on ur end or you using an old ptokax ;)
works for me :P
I type !kick somebody and the error in the ptoka
--
Syntax Error: attempt to index global `twat' (a nil value)
--
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
IT's Gooood :D
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
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 :)
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
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 :)
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 ?
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....
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....
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 :)
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
phatty how long till the next lesson
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 ...
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]||")
user:SendData("$UserCommand 1 2 "..HubMenu.."\\Bot Admin\\Remove Bot $<%[mynick]> !killbot %[nick]||")
user:SendData("$UserCommand 1 3 "..HubMenu.."\\Bot Admin\\Restore Bot $<%[mynick]> !listbot %[line:BotNick]||")
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 ^_^
ThX !! Damn u were fast ...
Welcome ;)
Is there a function or smth like ... delay ? like ... make it w8 a few seconds / miliseconds before moving on with the script ...
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
Here a Script Noobs try ;D
Not quite sure where to place the StartTimer(Delay*1000) so here 2 possibilities - maybe 1 is correct ^^
Try Nr. 1
--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"
Delay = 3 -- Delay in Seconds
--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]||")
user:SendData("$UserCommand 1 2 "..HubMenu.."\\Bot Admin\\Remove Bot $<%[mynick]> !killbot %[nick]||")
user:SendData("$UserCommand 1 3 "..HubMenu.."\\Bot Admin\\Restore Bot $<%[mynick]> !listbot %[line:BotNick]||")
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+)")
StartTimer(Delay*1000)
if cmd=="!killbot" then
OnTimer()
frmHub:UnregBot(name)
StopTimer()
return 1
elseif cmd=="!listbot" then
OnTimer()
frmHub:RegBot(name)
StopTimer()
return 1
end
end
end
or
Try Nr. 2
--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"
Delay = 3 -- Delay in Seconds
--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]||")
user:SendData("$UserCommand 1 2 "..HubMenu.."\\Bot Admin\\Remove Bot $<%[mynick]> !killbot %[nick]||")
user:SendData("$UserCommand 1 3 "..HubMenu.."\\Bot Admin\\Restore Bot $<%[mynick]> !listbot %[line:BotNick]||")
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
StartTimer(Delay*1000)
OnTimer()
frmHub:UnregBot(name)
StopTimer()
return 1
elseif cmd=="!listbot" then
StartTimer(Delay*1000)
OnTimer()
frmHub:RegBot(name)
StopTimer()
return 1
end
end
end
Is there any way in which I can select a character from a variable? :D
Example : a="asdfgh" ... smth like a[2] should be equal to "s"
Does this exist ? (sry my noobness ... im very new to LUA ... and it barely resembles a bit of C++ ... which I pretty am familiar with ...)
Indeed there is,
string.sub("asdfgh",2)
Znupi: Thats one hell of an avatar... :)
Bot = "PalaSh"
SendC = SendToAll
i=1
mes = " PalaSh e un mare idiot"
a = ""
function Main()
SetTimer(10000)
StartTimer()
end
function OnTimer()
a = string.sub(mes,i)
SendC(Bot,a)
i = i + 1
if ( i == 22 ) then
i = 1
end
end
Tryed this ... but id don't work :( ... :
stack traceback:
1: function `OnTimer' at line 21 [file `...op\Quickie\PtokaX_0.330_15.25\scripts\TimeR.lua']
Why ... ? :D (sorry if im annoying ...)
I tried it, just set timer to 1 secs:
[2006. 05. 30. - 23:29:16] <PalaSh>? PalaSh e un mare idiot
[2006. 05. 30. - 23:29:17] <PalaSh> PalaSh e un mare idiot
[2006. 05. 30. - 23:29:18] <PalaSh> alaSh e un mare idiot
[2006. 05. 30. - 23:29:19] <PalaSh> laSh e un mare idiot
[2006. 05. 30. - 23:29:20] <PalaSh> aSh e un mare idiot
[2006. 05. 30. - 23:29:21] <PalaSh> Sh e un mare idiot
[2006. 05. 30. - 23:29:22] <PalaSh> h e un mare idiot
[2006. 05. 30. - 23:29:23] <PalaSh>? e un mare idiot
[2006. 05. 30. - 23:29:24] <PalaSh> e un mare idiot
[2006. 05. 30. - 23:29:25] <PalaSh>? un mare idiot
[2006. 05. 30. - 23:29:26] <PalaSh> un mare idiot
[2006. 05. 30. - 23:29:27] <PalaSh> n mare idiot
[2006. 05. 30. - 23:29:28] <PalaSh>? mare idiot
[2006. 05. 30. - 23:29:29] <PalaSh> mare idiot
[2006. 05. 30. - 23:29:30] <PalaSh> are idiot
[2006. 05. 30. - 23:29:31] <PalaSh> re idiot
[2006. 05. 30. - 23:29:32] <PalaSh> e idiot
[2006. 05. 30. - 23:29:33] <PalaSh>? idiot
[2006. 05. 30. - 23:29:34] <PalaSh> idiot
[2006. 05. 30. - 23:29:35] <PalaSh> diot
[2006. 05. 30. - 23:29:36] <PalaSh> iot
[2006. 05. 30. - 23:29:37] <PalaSh>? PalaSh e un mare idiot
and so on..
So it works? ;D
Maybe a little thing to change:
if ( i == 22 ) then
to
if ( i == string.len(mes) ) then
Seems I had some old version of PtokaX ... coz i got the latest 1 and it worked :D
Ok ... I made this pretty cool bot ... I was thinking maybe it can be used as Lesson 10 :D ... Where can I post it so it can be analized and accepted / denied ? ;D
I got pretty dissapointed 'coz someone revealed to me my coding inability ... I will not post my bot
And it pretty much doesn't resemble the bot developed so far ... I kind of started from scratch ... don't think it would be suitable ... dunno ...
phatty how long till next lesson its bin a while :)
Quote from: ((KMN))Gazza-95 on 20 August, 2006, 22:44:46
phatty how long till next lesson its bin a while :)
I think that phatty sadly has turned his interest on other places .. he hasn't been on the board for a long time .. possibly for about a year now ..