Archive => Archived 4.0 boards => Help with Lua 4 scripts => Topic started by: Themaster on 16 November, 2004, 16:57:07
Title: need help with my Bot
Post by: Themaster on 16 November, 2004, 16:57:07
i have a problem when i do my command in my PM. the only thing i can do is +help. That i want is i can use all my command on my PM in the script...plz PPL do help me on that
if strsub(data, 1, 5) == "$To: " then local s,e,to,from,text = strfind(data, "%$To:%s(%S+)%sFrom:%s(%S+)%s$(.*)$") if to == BotName then local data=strsub(data,1,strlen(data)-1) local _,_,cmd = strfind(data,"$%b<>%s+(%S+)") if user.iProfile == 1 or user.iProfile == 0 then local Commands = (AlmHelp(user, data, cmd) or OpHelp(user, data, cmd) or Masterhelp(user, data, cmd)) return Commands end end if to == OpChat then if user.bOperator then local s,e,msg = strfind(text,"^%b<>%s+(.+)") OpChatRoom(user,msg) end end if to == PmToOps then local data=strsub(data,1,strlen(data)-1) local _,_,message = strfind(data,"$%b<>%s+(.+)") SendPmToOps(OpChat, "The user "..user.sName.." wants to inform us about : "..message) user:SendPM(PmToOps,"Your Message has been delivered to "..OpChat.." and Ops will handle it !! ") end end
Title:
Post by: bastya_elvtars on 16 November, 2004, 19:57:14
local Commands = (AlmHelp(user, data, cmd) or OpHelp(user, data, cmd) or Masterhelp(user, data, cmd))
use a table instead
tbl={[-1]=AlmHelp,[1]=OpHelp,[0]=Masterhelp}
and return tbl[user.iProfile](user,data,cmd)
Title:
Post by: Themaster on 16 November, 2004, 21:01:44
i have all my command : assert(dofile("blade/Commands.lua", "blade/Commands.lua not found"))
do you mean i shell made it a table ???
Title:
Post by: bastya_elvtars on 16 November, 2004, 21:06:30
QuoteOriginally posted by Themaster i have all my command : assert(dofile("blade/Commands.lua", "blade/Commands.lua not found"))
do you mean i shell made it a table ???
it is faster any way but dunno exactly
Title:
Post by: Themaster on 16 November, 2004, 21:11:21
Ok...But My problem is i still not can add a user in PM on my script....That is my biggest Problem
Title:
Post by: Themaster on 17 November, 2004, 16:18:27
my problem is i can't get add user function work in PM to the bot and the other command i have made...help me ppl
function DataArrival(user,data) if (strsub(data,1,7) == "$MyINFO") then Tag,Speed,Share = Parse(data) TagCheck(Tag,Speed,Share,user) end if (strsub(data, 1, 1) == "<" ) then local data = strsub(data,1,strlen(data)-1) local _,_,prefix,cmd=strfind(data, "%b<>%s+(%S)(%S+)") if Tprefix[prefix] and cmd then prefixcmd = Tprefix[prefix]..cmd local Commands = Commands(user, data, cmd) return Commands elseif Kennylizednicks[user.sName] == 1 then text=kennytext[random(1, getn(kennytext))] SendToAll(user.sName, text) return 1 end end [COLOR=red]if strsub(data, 1, 5) == "$To: " then local s,e,whoTo,from,text = strfind(data, "%$To:%s(%S+)%sFrom:%s(%S+)%s$(.*)$") if whoTo == BotName then local data=strsub(data,1,strlen(data)-1) local _,_,cmd = strfind(data,"$%b<>%s+(%S+)") if user.iProfile == 1 or user.iProfile == 0 then local Commands = Commands(user, data, cmd) return Commands end end[/COLOR] if whoTo == OpChat then if user.bOperator then local s,e,msg = strfind(text,"^%b<>%s+(.+)") OpChatRoom(user,msg) end end if whoTo == PmToOps then local data=strsub(data,1,strlen(data)-1) local _,_,message = strfind(data,"$%b<>%s+(.+)") SendPmToOps(OpChat, "The user "..user.sName.." wants to inform us about : "..message) user:SendPM(PmToOps,"Your Message has been delivered to "..OpChat.." and Ops will handle it !! ") end end local tmp = strsub(data,1,1) if tmp == "<" then local s, e, str = strfind(data,"%b<> (.*)|") if not iscommand(str) then if (user.bOperator) then DoUpdOpStats(user,str) else DoUpdUserStats(user,str) end end end if (strsub(data,1,1) == "<" ) then data=strsub(data,1,strlen(data)-1) s,e,cmd = strfind( data,"%b<>%s+(%S+)" ) if (cmd=="stats")then pm = 0 ShowTop15(user) end end end
Title:
Post by: Themaster on 17 November, 2004, 18:38:25
please PPL i do need Help to get it work...
My problem is a whoto function
whoto BotName.....
when i past a +time on PM to the Bot i Get The help function instead
Title:
Post by: Themaster on 17 November, 2004, 22:24:42
What is my problem on the DataArrival..
i have a assert command file
Please help me
Title:
Post by: nErBoS on 18 November, 2004, 02:51:29
Hi,
Your DataArrival is a bit confused. Question why do you do this "return Commands" ?? Do you now that, when you do that you are comming out of DataArrival the rest of the conditions won't be checked.
Best regards, nErBoS
Title:
Post by: Themaster on 18 November, 2004, 15:55:35
no i did not no that... maybe i need a edit on it
Title:
Post by: Themaster on 18 November, 2004, 18:26:27
can some whon edit my DataArrival so it work again...
Title:
Post by: nErBoS on 19 November, 2004, 01:59:42
Hi,
Its your script you have to understand why is not working. We are here to help. Now tell us why did you have this...
assert(dofile("blade/Commands.lua", "blade/Commands.lua not found"))
Maybe is wrong..
Title:
Post by: nErBoS on 20 November, 2004, 04:08:57
Hi,
OK, if i have understood you are saying that when you do this "local Commands = Commands(user, data, cmd)" you are calling the function that has this "assert(dofile("blade/Commands.lua", "blade/Commands.lua not found"))". Am i right ???
Best regards, nErBoS
Title:
Post by: Themaster on 20 November, 2004, 08:59:41
yes something like that....but it dosen't work wright..
Title:
Post by: nErBoS on 20 November, 2004, 15:55:07
Hi,
Yes its wrong, the function dofile() only "shares" code from other files, that is why that you see many dofile() in the begin of a script. When you share tables or other vars you must have the var with the same name on the script you did the dofile(). About sharing functions you should put the dofile() in the beggining of your script code (NOTE: when you make a dofile() the function can't have the same functions as the script).
Best regards, nErBoS
Title:
Post by: Themaster on 20 November, 2004, 16:24:26
What is my problem i can't use all my command in PM ??? That is my problem
Title:
Post by: nErBoS on 20 November, 2004, 22:24:36
Hi,
The problem is not that, the problem is that you are using in the wrong away the function dofile() . Read my post with attention.
Best regards, nErBoS
Title:
Post by: Themaster on 20 November, 2004, 22:38:36
Ok i but now i have test Something and it now come that on my main chat
[22:41:58] <-Wesly?-> You are not allowed to use this command
Title:
Post by: nErBoS on 21 November, 2004, 02:57:33
Hi,
In the file that you have the commands function, you have only the commands functions right ??? Show me how is the function of choosing the command function.
Best regards, nErBoS
Title:
Post by: Themaster on 21 November, 2004, 12:53:41
function DataArrival(user,data) if (strsub(data,1,7) == "$MyINFO") then Tag,Speed,Share = Parse(data) TagCheck(Tag,Speed,Share,user) end if (strsub(data, 1, 1) == "<" ) then local data = strsub(data,1,strlen(data)-1) local _,_,prefix,cmd=strfind(data, "%b<>%s+(%S)(%S+)") if Tprefix[prefix] and cmd then prefixcmd = Tprefix[prefix]..cmd local Commands = Commands(user, data, cmd) return Commands elseif Kennylizednicks[user.sName] == 1 then text=kennytext[random(1, getn(kennytext))] SendToAll(user.sName, text) return 1 elseif Mutes[user.sName] == 1 then user:SendData(BotName,"You are muted. your message has been blocked ! ! !") return 1 end end if strsub(data, 1, 5) == "$To: " then local s,e,whoTo,from,text = strfind(data, "%$To:%s(%S+)%sFrom:%s(%S+)%s$(.*)$") if whoTo == BotName then local data=strsub(data,1,strlen(data)-1) local _,_,cmd = strfind(data,"$%b<>%s+(%S+)") if user.iProfile == 1 or user.iProfile == 0 then local Commands =Commands(user, data, cmd) return Commands end end if whoTo == OpChat then if user.bOperator then local s,e,msg = strfind(text,"^%b<>%s+(.+)") OpChatRoom(user,msg) end end if whoTo == PmToOps then local data=strsub(data,1,strlen(data)-1) local _,_,message = strfind(data,"$%b<>%s+(.+)") SendPmToOps(OpChat, "The user "..user.sName.." wants to inform us about : "..message) user:SendPM(PmToOps,"Your Message has been delivered to "..OpChat.." and Ops will handle it !! ") end end local tmp = strsub(data,1,1) if tmp == "<" then local s, e, str = strfind(data,"%b<> (.*)|") if not iscommand(str) then if (user.bOperator) then DoUpdOpStats(user,str) else DoUpdUserStats(user,str) end end end if (strsub(data,1,1) == "<" ) then data=strsub(data,1,strlen(data)-1) s,e,cmd = strfind( data,"%b<>%s+(%S+)" ) if (cmd=="stats")then pm = 0 ShowTop15(user) end end end
Title:
Post by: Themaster on 21 November, 2004, 13:01:19
function Commands(user, data, cmd) if cmd == "myip" then user:SendData(BotName, " ?Your IP Are? --->"..user.sIP) return 1 elseif cmd == "version" then user:SendData(BotName, " "..Version ..Build .. Creator) return 1 elseif cmd == "away" then s,e,cmd,arg = strfind( data, "%b<>%s+(%S+)%s+(.*)" ) if (not (arg)) then arg = "Default away msg" end SendToAll(BotName,date("user "..user.sName.." told us at %T that he is away! He left this message: ")..arg.." .") awayArray[user.sName]=arg return 1 elseif cmd == "back" then if (awayArray[user.sName]==nil) then end SendToAll(BotName,date("user "..user.sName.." returned at %T and back from ")..arg..".") awayArray[user.sName]=nil return 1 elseif cmd == "rules" then user:SendPM(BotName, filecontents) Readtextfile(user, "rules.txt") return 1 elseif cmd =="newdk" then user:SendPM(BotName,filecontents) Readtextfile(user,"new dk.txt") return 1 elseif cmd == "newen" then user:SendPM(BotName,filecontents) Readtextfile(user,"new en.txt") return 1 elseif cmd == "network" then user:SendData(BotName, filecontents) Readtextfile(user, "network.txt") return 1 elseif cmd == "link" then local s,e,sLink,sDesc = strfind(data, "%b<>%s+%S+%s+(%S+)%s+(.+)") if (sLink == nil or sDesc == nil) then user:SendPM(BotName, "Syntax Error, addlink , you must write a link and a description.") elseif (arrLink[strlower(sLink)] ~= nil) then user:SendPM(BotName, "The Link "..sLink.." is already in our Link List.") else arrLink[strlower(sLink)] = {["BY"] = user.sName, ["DESC"] = sDesc} user:SendPM(BotName, "The Link "..sLink.." has been added to our Link List, thank you.") if (uLaterPtokax == 1) then OnExit() end end return 1 elseif user.bOperator and cmd == "dellink" then local s,e,sLink = strfind(data, "%b<>%s+%S+%s+(.+)") if (sLink == nil) then user:SendPM(BotName, "Syntax Error, dellink , you must write a link.") elseif (arrLink[strlower(sLink)] == nil) then user:SendPM(BotName, "The Link "..sLink.."isn't in our Link List.") else arrLink[strlower(sLink)] = nil user:SendPM(BotName, "The Link "..sLink.." has been removed from our Link List.") if (uLaterPtokax == 1) then OnExit() end end return 1 elseif cmd == "showlink" then local sTmp,sLink,arrTable = "The Link List of our HUB:\r\n\r\n" for sLink, arrTable in arrLink do sTmp = sTmp.."LINK: "..sLink.." POSTED BY: "..arrTable["BY"].." DESCRIPTION: "..arrTable["DESC"].."\r\n" end user:SendPM(BotName, sTmp) return 1 elseif cmd == "help" then if user.iProfile == 0 then MasterHelp(user) elseif user.iProfile == 1 then OpHelp(user) else AlmHelp(user) return 1 end return 1 elseif cmd == "adduser" then local s,e,cmd,mode,AddName,AddPass = strfind( data, "%b<>%s+(%S+)%s+(%S+)%s+(%S+)%s+(%S+)" ) local usr=GetItemByName(AddName) if mode == "reg" then level = 3 level1 = "REG" elseif mode == "vip" then level = 2 level1 = "VIP" elseif mode == "op" then level = 1 level1 = "Operator" elseif mode == "adm" then level = 0 level1= "Master" end if AddPass == nil or mode == nil then user:SendData(BotName,"Wrong Syntax read the help menu before you try to use commands !") elseif not strfind(AddPass, "%d") then user:SendData(BotName,"Hello "..user.sName.." ,For security issues , please use some numbers in the password ! !") elseif strfind(AddPass, "?") then user:SendData(BotName,"Hello "..user.sName.." ,The password can not be with spaces ! !") elseif strlen(AddPass) < 3 then user:SendData(BotName,"Hello "..user.sName.." the inserted password is to short, below 3 characters is not allowed") else for i = 1, getn(Symbol) do pass = gsub(AddPass, Symbol[i], "") end AddRegUser(AddName, pass, level) SendToOps(BotName,"Op-Msg : "..user.sName.." *** have succesfully registered the user > "..AddName.." < as "..level1.."!! ***") local user=GetItemByName(AddName) if user ~= nil then user:SendPM(BotName," ".. "\r\nWelcome to "..frmHub:GetHubName().."\r\n\r\n".. "Please add these details to your favourites:\r\n\r\n".. "Hub Name:\t "..frmHub:GetHubName().."\r\n".. "User Name:\t"..AddName.."\r\n".. "Password:\t"..pass.."\r\n\r\n".. "Enjoy your stay .......") SendToAll(BotName,"We have a new "..level1.." in the hub and it is "..AddName) end end return 1 elseif cmd == "flood" then Flood(user,data) return 1 elseif cmd == "userinfo" then local s,e,Name = strfind( data, "%b<>%s+%S+%s+(.+)") UserInfo(user, GetItemByName(Name)) return 1 elseif cmd=="warn" then local s,e,cmd,Name,reason = strfind( data, "%b<>%s+(%S+)%s+(%S+)%s*(.*)" ) local victim = GetItemByName(Name) if victim ~= nil then victim:SendPM(user.sName, "You are being warned because: "..reason) SendToAll(BotName, user.sName.." is warning <"..Name.."> because: "..reason) return 1 else user:SendData(BotName" No such nick in the userlist !! ") end elseif cmd=="unregme" then frmHub:DelRegUser(user.sName) SendPmToNick(user.sName, BotName, "You have now deleted "..user.sName.." as a reguser") return 1 elseif cmd == "hubinfo" then hubinfo(user) return 1 elseif cmd=="ban" then Ban(user, data, cmd) return 1 elseif cmd=="nameban" then NameBan(user, data, cmd) return 1 elseif cmd=="kick" then Kick(user, data, cmd) return 1 elseif cmd=="showbanlog" then ReadKickBan(user, data) return 1
it not all my command i can't pass it
Title:
Post by: nErBoS on 21 November, 2004, 15:01:38
function DataArrival(user,data) if (strsub(data,1,7) == "$MyINFO") then Tag,Speed,Share = Parse(data) TagCheck(Tag,Speed,Share,user) end if (strsub(data, 1, 1) == "<" ) then local data = strsub(data,1,strlen(data)-1) local _,_,prefix,cmd=strfind(data, "%b<>%s+(%S)(%S+)") if Tprefix[prefix] and cmd then prefixcmd = Tprefix[prefix]..cmd Commands(user, data, cmd) elseif Kennylizednicks[user.sName] == 1 then text=kennytext[random(1, getn(kennytext))] SendToAll(user.sName, text) return 1 elseif Mutes[user.sName] == 1 then user:SendData(BotName,"You are muted. your message has been blocked ! ! !") return 1 end end if strsub(data, 1, 5) == "$To: " then local s,e,whoTo,from,text = strfind(data, "%$To:%s(%S+)%sFrom:%s(%S+)%s$(.*)$") if whoTo == BotName then local data=strsub(data,1,strlen(data)-1) local _,_,cmd = strfind(data,"$%b<>%s+(%S+)") if user.iProfile == 1 or user.iProfile == 0 then Commands(user, data, cmd) end end if whoTo == OpChat then if user.bOperator then local s,e,msg = strfind(text,"^%b<>%s+(.+)") OpChatRoom(user,msg) end end if whoTo == PmToOps then local data=strsub(data,1,strlen(data)-1) local _,_,message = strfind(data,"$%b<>%s+(.+)") SendPmToOps(OpChat, "The user "..user.sName.." wants to inform us about : "..message) user:SendPM(PmToOps,"Your Message has been delivered to "..OpChat.." and Ops will handle it !! ") end end local tmp = strsub(data,1,1) if tmp == "<" then local s, e, str = strfind(data,"%b<> (.*)|") if not iscommand(str) then if (user.bOperator) then DoUpdOpStats(user,str) else DoUpdUserStats(user,str) end end end if (strsub(data,1,1) == "<" ) then data=strsub(data,1,strlen(data)-1) s,e,cmd = strfind( data,"%b<>%s+(%S+)" ) if (cmd=="stats")then pm = 0 ShowTop15(user) end end end Try out this DataArrival.
Best regards, nErBoS
Title:
Post by: Themaster on 21 November, 2004, 15:33:00
function DataArrival(user,data) if (strsub(data,1,7) == "$MyINFO") then Tag,Speed,Share = Parse(data) TagCheck(Tag,Speed,Share,user) end if (strsub(data, 1, 1) == "<" or strsub(data,1,5+strlen(BotName)) == "$To: "..BotName) then local data = strsub(data,1,strlen(data)-1) local _,_,cmd= strfind(data, "%b<>%s+(%S+)") local _,_,talk = strfind(data, "%b<>%s+(.*)") SendToAll(BotName, "DATA: "..data) -- To see dat sent SendToAll(BotName, "CMD: "..cmd) -- To see command typed Commands(user, data, cmd) if not iscommand(talk) then if (user.bOperator) then DoUpdOpStats(user,talk) else DoUpdUserStats(user,talk) end end end if strsub(data, 1, 5) == "$To: " then local s,e,whoTo,from,text = strfind(data, "%$To:%s(%S+)%sFrom:%s(%S+)%s$(.*)$") if whoTo == OpChat then if user.bOperator then local s,e,msg = strfind(text,"^%b<>%s+(.+)") OpChatRoom(user,msg) end elseif whoTo == PmToOps then local data=strsub(data,1,strlen(data)-1) local _,_,message = strfind(data,"$%b<>%s+(.+)") SendPmToOps(OpChat, "The user "..user.sName.." wants to inform us about : "..message) user:SendPM(PmToOps,"Your Message has been delivered to "..OpChat.." and Ops will handle it !! ") end end if (strsub(data,1,1) == "<" ) then data=strsub(data,1,strlen(data)-1) s,e,cmd = strfind( data,"%b<>%s+(%S+)" ) if (cmd=="stats")then pm = 0 ShowTop15(user) elseif Kennylizednicks[user.sName] == 1 then text=kennytext[random(1, getn(kennytext))] SendToAll(user.sName, text) return 1 elseif Mutes[user.sName] == 1 then user:SendData(BotName,"You are muted. your message has been blocked ! ! !") return 1 end end end Best regards, nErBoS
Title:
Post by: Themaster on 23 November, 2004, 14:50:59
Nope it dosen't work..all my command is DEAD now
Title:
Post by: nErBoS on 24 November, 2004, 01:04:17
Hi,
When you type anything or a command in main or PM the bot doesn't send anything ???
Best regards, nErBoS
Title:
Post by: Themaster on 24 November, 2004, 07:11:48
function DataArrival(user,data) if (strsub(data,1,7) == "$MyINFO") then Tag,Speed,Share = Parse(data) TagCheck(Tag,Speed,Share,user) end if (strsub(data, 1, 1) == "<" or strsub(data,1,5+strlen(BotName)) == "$To: "..BotName) then local data = strsub(data,1,strlen(data)-1) local _,_,cmd= strfind(data, "%b<>%s+(%S+)") local _,_,talk = strfind(data, "%b<>%s+(.*)") if (Tprefix[strsub(cmd,1,1)] ~= nil) then cmd = strsub(cmd,2,strlen(cmd)) end SendToAll(BotName, "DATA: "..data) -- To see dat sent SendToAll(BotName, "CMD: "..cmd) -- To see command typed Commands(user, data, cmd) if not iscommand(talk) then if (user.bOperator) then DoUpdOpStats(user,talk) else DoUpdUserStats(user,talk) end end end if strsub(data, 1, 5) == "$To: " then local s,e,whoTo,from,text = strfind(data, "%$To:%s(%S+)%sFrom:%s(%S+)%s$(.*)$") if whoTo == OpChat then if user.bOperator then local s,e,msg = strfind(text,"^%b<>%s+(.+)") OpChatRoom(user,msg) end elseif whoTo == PmToOps then local data=strsub(data,1,strlen(data)-1) local _,_,message = strfind(data,"$%b<>%s+(.+)") SendPmToOps(OpChat, "The user "..user.sName.." wants to inform us about : "..message) user:SendPM(PmToOps,"Your Message has been delivered to "..OpChat.." and Ops will handle it !! ") end end if (strsub(data,1,1) == "<" ) then data=strsub(data,1,strlen(data)-1) s,e,cmd = strfind( data,"%b<>%s+(%S+)" ) if (cmd=="stats")then pm = 0 ShowTop15(user) elseif Kennylizednicks[user.sName] == 1 then text=kennytext[random(1, getn(kennytext))] SendToAll(user.sName, text) return 1 elseif Mutes[user.sName] == 1 then user:SendData(BotName,"You are muted. your message has been blocked ! ! !") return 1 end end end
Best regards, nErBoS
Title:
Post by: nErBoS on 25 November, 2004, 14:50:37
Hi,
I have fixed a little code error on the code above.
Best regards, nErBoS
Title:
Post by: Themaster on 25 November, 2004, 15:34:16
Sry mate but now my command is dead.. Nothing work
Title:
Post by: nErBoS on 26 November, 2004, 00:46:38
Hi,
Does the script editor shows any error ???
Best regards, nErBoS
Title:
Post by: Themaster on 26 November, 2004, 07:16:33
there are no error on the ptokax
Title:
Post by: Themaster on 17 December, 2004, 00:31:31
if to == OpChatName then if user.iProfile == 0 or user.iProfile == 1 or user.iProfile == 4 then local s,e,msg = strfind(arg,"^%b<>%s+(.+)") OpChatRoom(user,msg) end end
function OpChatRoom(user,msg) local allprofiles = GetProfiles() local index, profile, index2, nick for index, profile in allprofiles do local users = GetUsersByProfile(profile) for index2, nick in users do local usr = GetItemByName(nick) if usr ~= nil then if user.sName == usr.sName then else if usr.iProfile == 0 or usr.iProfile == 1 or usr.iProfile == 4 then usr:SendData("$To: "..usr.sName.." From: "..OpChat.." $<"..user.sName.."> " ..msg) end end end end end end
Title:
Post by: bastya_elvtars on 17 December, 2004, 01:30:25