PtokaX forum

Archive => Archived 4.0 boards => Help with Lua 4 scripts => Topic started by: ((UKSN))shad_dow on 31 December, 2003, 21:20:19

Title: Help With command !rembot
Post by: ((UKSN))shad_dow on 31 December, 2003, 21:20:19
Hi every one, hope this in right place

Snowman can u tell me if this is right :-

function DataArrival(user, data)
if( strsub(data, 1, 1) == "<" ) then
if( strfind( strlower(data), strlower("!removebotname")) ) then
frmHub:UnregBot(bot)
SendPmToNick(user.sName, Bot, " "Command" "done)

end
end

was trying to have the !rembot command on its on ,was going to give full creadits in the script since i got the idea from Ur mean machine script, i wont so i can test deffent bots out in privet hub with out running meanmachine in it just for 1 command that il use :)

thx if u can do it snowman :D
Title:
Post by: NightLitch on 01 January, 2004, 01:05:08
Yepp looks nice...

Remember One Thing...

frmHub:UnregBot(bot)
                            -----     Obseverve the letters


SendPmToNick(user.sName, Bot, " "Command" "done)
                                            -----
 
Make sure you have Bot and not bot...
Title:
Post by: ((UKSN))shad_dow on 01 January, 2004, 02:08:04
Thanks NightLitch for that 1 :))

only prob now is i get this when i do a syntax check >

Syntax Error: `)' expected;
  last token read: `Command' at line 5 in string "function DataArrival(user, data)
..."

sorry to be a pain but i just cant see where to put the )

 ?(
Title:
Post by: ((UKSN))shad_dow on 01 January, 2004, 02:17:15
well i correct that error and change the code sligtly to :-


function DataArrival(user, data)
if( strsub(data, 1, 1) == "<" ) then
if( strfind(strlower(data),strlower("!removebotname") ) ) then
frmHub:UnregBot(Bot)
SendPmToNick(user.sName, Bot, "Command done")

end
end
end

but i think theres something missing , but i cant find it  X(  

(new to lua , so this be a second script for me , first was simple welcome meassge when ops log in)
Title:
Post by: ((UKSN))shad_dow on 01 January, 2004, 03:36:48
heresit is ,so it only kills the bot named , just need to get it to do it on this command

!kil (any bots nick)

heres the script

--  Kill Bot Nick script by ((UKSN))shad_dow
-- idea from Snowman`s meanmachine script
-- help from NightLich




Bot = "Killer"

function Main()
frmHub:RegBot(Bot)
end

function DataArrival(user, data)
if( strsub(data, 1, 1) == "<" ) then
if( strfind( strlower(data), strlower("!kil")) ) then   
frmHub:UnregBot(Bot)
end
end
end
Title:
Post by: pHaTTy on 01 January, 2004, 04:27:37
Im not a big fan of lots of text and dislike using strsub etc so i usual try and cut down on using it, use as less text as possible, and it is quite much easier todo something like this if you are adding to a bot


Bot = "TheBotName"

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 == "!rembot" then
frmHub:UnregBot(Bot)
user:SendData(Bot, "Unregistered bot succesful")
return 1
end
end
end


SendPmToNick ive never liked using this 1 little bit, so i usually never use it..its supposed to be faster but not in my views of it.....

l8rr
Title:
Post by: ((UKSN))shad_dow on 01 January, 2004, 05:31:15
Thankxs (uk-kingdom)pH?tt?

thats actuly loks alot clearner than mine :)))

and works a treat

expect for > Syntax Error: attempt to index global `frm' (a nil value) on ur code .

, all i got to do now is work out how to make it work on any bot namewhen i type the command like this in main ;_

!rembot (botsname) < as if it were type in main :)

:)
Title:
Post by: pHaTTy on 01 January, 2004, 06:31:25
oops sorry

change this line

         frm:UnregBot(Bot)


to

         frmHub:UnregBot(Bot)
Title:
Post by: pHaTTy on 01 January, 2004, 06:33:42
QuoteOriginally posted by ((UKSN))shad_dow
Thankxs (uk-kingdom)pH?tt?

thats actuly loks alot clearner than mine :)))

and works a treat

expect for > Syntax Error: attempt to index global `frm' (a nil value) on ur code .

, all i got to do now is work out how to make it work on any bot namewhen i type the command like this in main ;_

!rembot (botsname) < as if it were type in main :)

:)


ok heres a start



Bot = "TheBotName"

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 == "!rembot" then
s,e,cmd,botsname = strfind(data,"%b<>%s+(%S+)%s+(%S+)")
frmHub:UnregBot(botsname)
user:SendData(Bot, "Unregistered bot succesful")
return 1
end
end
end



but now you need it to stop unregging users, only bots, or it can cause an nick taken error
Title:
Post by: pHaTTy on 01 January, 2004, 06:35:13
hmm try this


--Unregister bot by Phatty
--v1.50

Bot = "TheBotName"

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 == "!rembot" then
s,e,cmd,botsname = strfind(data,"%b<>%s+(%S+)%s+(%S+)")
if GetItemByName(botsname) then
user:SendData(Bot, "Unregister bot unsuccesful")
return 1
else
frmHub:UnregBot(botsname)
user:SendData(Bot, "Unregistered bot succesful")
end
return 1
end
end
end





enjoy ;)
Title:
Post by: pHaTTy on 01 January, 2004, 06:39:35

--Unregister bot by Phatty
--v1.51

Bot = "TheBotName"
Command = "!rembot" -- +
Success = "Unregistered bot succesful"
Unsuccess = "Unregister bot unsuccesful"


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 == Command then
s,e,cmd,botsname = strfind(data,"%b<>%s+(%S+)%s+(%S+)")
if GetItemByName(botsname) then
user:SendData(Bot,Unsuccess)
return 1
else
frmHub:UnregBot(botsname)
user:SendData(Bot,Success)
end
return 1
end
end
end


Title:
Post by: ((UKSN))shad_dow on 01 January, 2004, 08:05:41
cheers M8ty , il try it and get back to u asap ..
oh and happy new year :)))
Title:
Post by: ((UKSN))shad_dow on 01 January, 2004, 08:11:58
:D  :D back ....yep just wot i wonted it to do phatty , BIG CHEERS for that 1 m8ty ,  :D  :D  :D  :D
Title:
Post by: pHaTTy on 01 January, 2004, 08:53:53
QuoteOriginally posted by ((UKSN))shad_dow
:D  :D back ....yep just wot i wonted it to do phatty , BIG CHEERS for that 1 m8ty ,  :D  :D  :D  :D

yw welcome ;)

thats what i joined this forum for, (and the last one), to get help and to give help ;)

l8rr