this function work
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) == "<" ) and user.bOperator then
data=strsub(data,1,strlen(data)-1)
_,_,cmd=strfind(data, "%b<>%s+(%S+)")
if not cmd then cmd = "0" end
cmd = strlower(cmd)
cmdprefix = strsub(cmd, 1,1)
if cmdprefix == "!" or cmdprefix == "+" or cmdprefix == "#" or cmdprefix == "?" then
cmd = strsub(cmd, 2,strlen(cmd))
if cmd == "say" then
_,_,as,message = strfind(data, "%b<>%s+%S+%s+(%S+)%s+(.+)")
SendToAll(as, message)
return 1
end
end
this function not work
function DataArrival(user, data)
if (strsub(data, 1, 1) == "<" ) then
local data=strsub(data,1,strlen(data)-1)
local _,_,cmd=strfind(data, "%b<>%s+(%S+)")
local Commands = (UserCommands(user, data, cmd) or OpCommands(user, data, cmd) or MasterCommands(user, data, cmd))
return Commands
elseif (strsub(data, 1, 12) == "$OpForceMove") or (strsub(data, 1, 10) == "$ForceMove") and (user.iProfile < 0 or user.iProfile > 0)then
return 1
elseif strsub(data, 1, 5) == "$To: " then
local s, e, to = strfind(data, "$To: (%S+)")
if to ~= BotName and to ~= OpChat then
return 0
else
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 = (UserCommands(user, data, cmd) or OpCommands(user, data, cmd) or MasterCommands(user, data, cmd))
return Commands
end
end
end
elseif to == OpChatName then
if user.iProfile == 0 or user.iProfile == 1 then
local s,e,msg = strfind(arg,"^%b<>%s+(.+)")
OpChatRoom(user,msg)
end
end
if (strsub(data, 1, 1) == "<" ) then
data=strsub(data,1,strlen(data)-1)
_,_,cmd=strfind(data, "%b<>%s+(%S+)")
if not cmd then cmd = "0" end
cmd = strlower(cmd)
cmdprefix = strsub(cmd, 1,1)
if cmdprefix == "!" or cmdprefix == "+" or cmdprefix == "#" or cmdprefix == "?" then
cmd = strsub(cmd, 2,strlen(cmd))
if cmd == "say" then
_,_,as,message = strfind(data, "%b<>%s+%S+%s+(%S+)%s+(.+)")
SendToAll(as, message)
return 1
end
end
end
if (strsub(data,1,7) == "$MyINFO") then
Tag,Speed,Share = Parse(data)
TagCheck(Tag,Speed,Share,user)
end
end
i have create a command fil but it do not work :s
plz i need all the help i can get
hey USE the [ c o d e ] code in here [ / c o d e ]
pls keep it tidy in here we like it as much as u do ...
k then...can you see what i have an error on it ....
i still don't what i do wrong :s
what is the file u are getting from like ?
is it layed out as variables ?
I mean is it like this :
acmd = "!you"
bcmd = "!can"
ccmd = "!edit"
dcmd = "!your"
ecmd = "!posts"
...?
btw it is l8 over here .. so I am off to bed ..
I am holding a friends gathering for bbq, lots of drinks and such in my house ..
any1 invited details about my location in my profile ( lol )
he he ok then
what are the contents of ur commands.lua ?
need a little help with my Commands.lua....this is not working :s...what is wrong i can't get it right
plz help me
and here are my assert file
assert(dofile("blade/Commands.lua"))
this is my DataArrival
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
data=strsub(data,1,strlen(data)-1)
_,_,cmd=strfind(data, "%b<>%s+(%S+)")
if not cmd then cmd = "0" end
cmd = strlower(cmd)
cmdprefix = strsub(cmd, 1,1)
if cmdprefix == "!" or cmdprefix == "+" or cmdprefix == "#" or cmdprefix == "?" then
cmd = strsub(cmd, 2,strlen(cmd))
if cmd == "say" then
_,_,as,message = strfind(data, "%b<>%s+%S+%s+(%S+)%s+(.+)")
SendToAll(as, message)
return 1
end
end
end
if strsub(data, 1, 5) == "$To: " then
local s,e,to,from,text = strfind(data, "%$To:%s(%S+)%sFrom:%s(%S+)%s$(.*)$")
if to == OpChat then
if user.bOperator then
local s,e,msg = strfind(text,"^%b<>%s+(.+)")
OpChatRoom(user,msg)
end
end
end
if (strsub(data, 1, 1) == "<" ) then
data=strsub(data,1,strlen(data)-1)
_,_,cmd=strfind(data, "%b<>%s+(%S+)")
s,e,arg = strfind(data,"%b<>%s+%S+%s+(%S+)")
local Commands = (UserCommands(user, data, cmd) or OpCommands(user, data, cmd) or MasterCommands(user, data, cmd))
return Command
end
end
and this is my Commands.lue
function UserCommands(user, arg, cmd)
if cmd == "myip" then
SendToUser(BotName, "Your IP is *** "..user.sIP)
return 1
elseif cmd == "version" then
SendToAll("The Script ", " "..Version ..Build .. Creators)
return 1
end
end
function OpCommands(user,arg, cmd)
-----------------------------------------------------------------------------------------------------------------------------------------------
-- only [OPERATORS] and [MASTERS] can do the following commands
if user.iProfile == 0 or user.iProfile == 1 then
end
end
function MasterCommands(user, arg, cmd)
-------------------------------------------------------------------------------------------------------------------------------------------------
-- only [MASTERS] can do the following commands
if user.iProfile == 0 then
end
end
plz help me....:)
i can't get my command function to work.
i need some help i'm stuck on it now:s
assert(dofile("blade/Commands.lua"), "blade/Commands.lua not found")
this are in my DataArrival
if (strsub(data,1,1) == "<") then
data=strsub(data,1,strlen(data)-1)
local s,v, cmd = strfind(data, "%b<>%s+(%S+)")
local Commands = (UserCommands(user, data, cmd) or OpCommands(user, data, cmd) or MasterCommands(user, data, cmd))
return Command
end
end
and here are my Command.lua function
function UserCommands(user, arg, cmd)
if cmd == "myip" then
user:SendData(BotName, "Your IP is *** "..user.sIP)
return 1
elseif cmd == "version" then
user:SendData("The Script ", " "..Version ..Build .. Creators)
return 1
end
end
you have 2x.
if (strsub(data, 1, 1) == "<" ) then
clean up dataarival 1st, then it becomes easyer 2 see whats going wrong.
plop
i don't that now.. and it still not working
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
data=strsub(data,1,strlen(data)-1)
local Commands = (UserCommands(user, data, cmd) or OpCommands(user, data, cmd) or MasterCommands(user, data, cmd))
return Command
else
local s,v, cmd = strfind(data, "%b<>%s+(%S+)")
_,_,cmd=strfind(data, "%b<>%s+(%S+)")
if not cmd then cmd = "0" end
cmd = strlower(cmd)
cmdprefix = strsub(cmd, 1,1)
if cmdprefix == "!" or cmdprefix == "+" or cmdprefix == "#" or cmdprefix == "?" then
cmd = strsub(cmd, 2,strlen(cmd))
if cmd == "say" then
_,_,as,message = strfind(data, "%b<>%s+%S+%s+(%S+)%s+(.+)")
SendToAll(as, message)
return 1
end
end
end
if strsub(data, 1, 5) == "$To: " then
local s,e,to,from,text = strfind(data, "%$To:%s(%S+)%sFrom:%s(%S+)%s$(.*)$")
if to == OpChat then
if user.bOperator then
local s,e,msg = strfind(text,"^%b<>%s+(.+)")
OpChatRoom(user,msg)
end
end
end
end
check closely what you are doing here, added comments to help you.
if (strsub(data, 1, 1) == "<" ) then -- if this is a mainchat msg then do the next
data=strsub(data,1,strlen(data)-1)
local Commands = (UserCommands(user, data, cmd) or OpCommands(user, data, cmd) or MasterCommands(user, data, cmd))
return Command
else -- if it's not a main chat msg then do the next
local s,v, cmd = strfind(data, "%b<>%s+(%S+)")
_,_,cmd=strfind(data, "%b<>%s+(%S+)") -- this line does the same as the line above
if not cmd then
cmd = "0"
end
cmd = strlower(cmd)
cmdprefix = strsub(cmd, 1,1)
if cmdprefix == "!" or cmdprefix == "+" or cmdprefix == "#" or cmdprefix == "?" then
cmd = strsub(cmd, 2,strlen(cmd))
if cmd == "say" then
_,_,as,message = strfind(data, "%b<>%s+%S+%s+(%S+)%s+(.+)")
SendToAll(as, message)
return 1
end
end
end
plop
Ok...but i still don't now what i miss on it now...It still not working..i tried anything now and i still miss something on it
if (strsub(data, 1, 1) == "<" ) then
data=strsub(data,1,strlen(data)-1)
local Commands = (UserCommands(user, data, cmd) or OpCommands(user, data, cmd) or MasterCommands(user, data, cmd))
return Command
else
the ' return Command ' part ...
It doesnt exist as a variable anywhere ... so it is logical that it doesnt return anything ..
and the local Commands = (UserCommands(user, data, cmd) or OpCommands(user, data, cmd) or MasterCommands(user, data, cmd))
this line in theory stands correct .. since those functions return 1 if any of the cmds is found ..
although the operation of the script halts there ..
It do exist i can't get into main now only this coming op in the main now "wrong use read !help menu !!"
Need still help to my Commands.lua i can't get it wright..i only got this in main wrong use read !help menu !!
you had Commands and Command.
but 2 get you on your way try the next dataarival.
function DataArrival(user, data)
if (strsub(data, 1, 1) == "<" ) then
data=strsub(data,1,strlen(data)-1)
local s,v, cmd = strfind(data, "%b<>%s+(%S+)")
if cmd then
cmd = strlower(cmd)
local cmdprefix = strsub(cmd, 1,1)
if cmdprefix == "!" or cmdprefix == "+" or cmdprefix == "#" or cmdprefix == "?" then
cmd = strsub(cmd, 2,strlen(cmd))
if cmd == "say" then
_,_,as,message = strfind(data, "%b<>%s+%S+%s+(%S+)%s+(.+)")
SendToAll(as, message)
return 1
end
end
end
end
end
plop
it still a problem on it :s...My Commands do not come in main
edited plops post a bit, this function must work
added some help
function DataArrival(user, data) -- fired when hub gets data from client(s)
if (strsub(data, 1, 1) == "<" ) then -- any mainchat event
data=strsub(data,1,strlen(data)-1) -- remove end pipe ("|")
local _,_,cmd = strfind(data, "%b<>%s+([%!%+%#%?]%S+)") -- sees if there is a non-space string after > and it starts with ! or # or + or ?
if cmd then -- if so then
cmd = strlower(cmd) -- puts into lowercase ---> case-insensitive
cmd = strsub(cmd, 2,strlen(cmd)) -- remove 1st char
if cmd == "says" then
local _,_,as,message = strfind(data, "%b<>%s+%S+%s+(%S+)%s+(.+)") -- finding params
SendToAll(as, message) -- doing job
return 1 -- blocking appearance of command in main
end
end
end
end
thx now i got it work...thx for all of you help i'm happy now....THX :]
i still got a small problem with the command's
i can get 2 things working on it but when i try to pass more command's on it..then it made a syntax error
Syntax error: attempt to index global `awayArray' (a nil value)
stack traceback:
1: function `UserCommands' at line 14 [file `blade/Commands.lua']
2: function `DataArrival' at line 85 [file `...ngs\ scripts\Blade?.lua']
if (strsub(data, 1, 1) == "<" ) then -- any mainchat event
data=strsub(data,1,strlen(data)-1) -- remove end pipe ("|")
local _,_,cmd = strfind(data, "%b<>%s+([%!%+%#%?%?]%S+)") -- sees if there is a non-space string after > and it starts with ! or # or + or ?
if cmd then -- if so then
cmd = strlower(cmd) -- puts into lowercase ---> case-insensitive
cmd = strsub(cmd, 2,strlen(cmd)) -- remove 1st char
if cmd == "says" then
local _,_,as,message = strfind(data, "%b<>%s+%S+%s+(%S+)%s+(.+)") -- finding params
SendToAll(as, message) -- doing job
return 1 -- blocking appearance of command in main
end
local Commands = (UserCommands(user, data, cmd) or OperatorCommands(user, data, cmd) or MasterCommands(user, data, cmd))
return Commands
end
end
function UserCommands(user, data, cmd)
if cmd == "myip" then
user:SendData(BotName, "Your IP is *** "..user.sIP)
return 0
elseif cmd == "version" then
user:SendData("The Script ", " "..Version ..Build .. Creators)
return 0
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
end
end
inh the 1st line of your script, include this:
awayArray={}
with this, you create the table, which is a must do thing to use it :)
no it do not work...maybe i miss something on it
ups sry my fall
i just wont to get some off the things on my script and now i got this
Syntax error: `end' expected (to close `if' at line 76);
last token read: `if' at line 81 in file `...uments and Settings\den lille\Skrivebord\Hub\scripts\Blade? 1.0.lua'
No syntax errors in script file RightClicker.lua
and here are the settings there are errow on it
if (strsub(data, 1, 1) == "<" ) then
local data=strsub(data,1,strlen(data)-1)
local _,_,cmd=strfind(data, "%b<>%s+([%!%+%#%?%?]%S+)")
local Commands = UserCommands(user, data, cmd)
return Commands
if cmd then
cmd = strlower(cmd)
cmd = strsub(cmd, 2,strlen(cmd))
if cmd == "says" then
local _,_,as,message = strfind(data, "%b<>%s+%S+%s+(%S+)%s+(.+)")
SendToAll(as, message)
return 1
end
end
end
plz little bit off help
Quotereturn and break statements can only be written as the last statements of a block
So try to put an "end" after 'return Commands'
now i got to work..But my OpChat it do not ?
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 = UserCommands(user, data, cmd)
return Commands
end
end
if strsub(data, 1, 5) == "$To: " then
local s,e,to,from,text = strfind(data, "%$To:%s(%S+)%sFrom:%s(%S+)%s$(.*)$")
if to == OpChat then
if user.bOperator then
local s,e,msg = strfind(text,"^%b<>%s+(.+)")
OpChatRoom(user,msg)
end
end
end
end
i got a problem now again i can't get my rules to work
it made a error
[/code]
Syntax error: attempt to call global `ShowRules' (a nil value)
stack traceback:
1: function `Commands' at line 24 [file `blade/Commands.lua']
2: function `DataArrival' at line 89 [file `...\Blade? 1.0.lua']
[/code]
and here is where is the make the error
elseif cmd == "rules" then
ShowRules(user)
return 1
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
end
end
I Got this function
rules = "blade/txt/rules.txt"
network = "blade/txt/network.txt"
faq = "blade/txt/faq.txt"
function advert(message, where)
tosend = ""
border = strrep ("~", strlen (message)*2/3+2)
tosend = "\r\n\r\n"..border.."\r\n"..message.."\r\n"..border.."\r\n"
if (where == "PM") then
SendPmToAll(BotName, tosend)
else
SendToAll(BotName, tosend)
end
end
function Readtextfile(user, file)
local filecontents = ""
local handle = openfile(file, "r")
if (handle ~= nil) then
local line = read(handle)
while line do
filecontents = filecontents..line.."\r\n"
line = read(handle)
end
closefile(handle)
user:SendPM(Bot, filecontents)
end
end
well I couldnt notice any function named ' ShowRules ' in the script parts that u provide ...
so I suspect that is the problem ...
my suggestion is to change this elseif cmd == "rules" then
ShowRules(user)
return 1
to elseif cmd == "rules" then
Readtextfile(user, rules)
return 1
I can get another DataArrival on that i make...et get a error
this is my data
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
end
end
and here are the next data is from kenny...
if (strsub(data,1,1) == "<") then
data=strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(data,"%b<>%s+(%S+)")
if user.bOperator then
So what is the error ?
Help i got a wrong stoff when i log on to my hub in main.. i just wont to have word replace on my script at now this get in main when log on
[17:52:46] $MyINFO $ALL Themaster? Blade? Creator$ $DSL$$12042852195$
here are this on my dataarrival
replaced = nil
local newmsg = gsub(data,"(%w+)",
function (word)
if tWords[strlower( word )] then
replaced = 1
return tWords[strlower( word )]
else
return word
end
end)
if replaced then
SendToAll(" "..newmsg.."|")
return 1
end
sorry that lil bit of script doesnt help to understand what is going on ..
here are all my Data
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
replaced = nil
local newmsg = gsub(data,"(%w+)",
function (word)
if tWords[strlower( word )] then
replaced = 1
return tWords[strlower( word )]
else
return word
end
end)
if replaced then
SendToAll(" "..newmsg.."|")
return 1
end
if strsub(data, 1, 5) == "$To: " then
local s,e,to,from,text = strfind(data, "%$To:%s(%S+)%sFrom:%s(%S+)%s$(.*)$")
if to == OpChat then
if user.bOperator then
local s,e,msg = strfind(text,"^%b<>%s+(.+)")
OpChatRoom(user,msg)
end
end
end
end
i have made it now
if (strsub(data,1,7) == "$MyINFO") then
Tag,Speed,Share = Parse(data)
TagCheck(Tag,Speed,Share,user)
end
This can be like
if (strsub(data,1,7) == "$MyINFO") then
TagCheck(Parse(data),user)
end
also this
if Tprefix[prefix] and cmd then
prefixcmd = Tprefix[prefix]..cmd
local Commands = Commands(user, data, cmd)
return Commands
can be like this
if Tprefix[prefix] and cmd then
prefixcmd = Tprefix[prefix]..cmd
return Commands(user, data, cmd)
And this ...
if (to == OpChat) then
if (user.bOperator) then
to this ..
if (to == OpChat) and (user.bOperator) then
all the changes that I propose target to shorten the code ,...
this ofcourse has some disadvantage in reading the code ...
so while developing it is better to keep everything not so packed in like I mention ... but ofcourse thats up to you to see ...
PS : Glad you could find the problem ;)
hmmm now i got this error when i use ? on my hub
Syntax error: table index is nil
stack traceback
1: function `DataArrival' at line 101 [file `...den lille\Skrivebord\Hub\scripts\Blade? 1.0.lua']
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
[COLOR=red] prefixcmd = Tprefix[prefix]..cmd[/COLOR]
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
replaced = nil
local newmsg = gsub(data,"(%w+)",
function (word)
if tWords[strlower( word )] then
replaced = 1
return tWords[strlower( word )]
else
return word
end
end)
if replaced then
SendToAll(""..newmsg.."|")
return 1
end
if strsub(data, 1, 5) == "$To: " then
local s,e,to,from,text = strfind(data, "%$To:%s(%S+)%sFrom:%s(%S+)%s$(.*)$")
if to == OpChat then
if user.bOperator then
local s,e,msg = strfind(text,"^%b<>%s+(.+)")
OpChatRoom(user,msg)
end
end
end
end
The red is there when error are
lets see the Tprefix table
yeah .. that variable ('prefix') is refering to an index in the table ... if the table doesnt contain the value of 'prefix' then it returns that "table index is nil" message ... simply because it isnt there ...
--// Commands prefix
Tprefix = {
["!"]=1,
["+"]=1,
["#"]=1,
["?"]=1,
["-"]=1,
}
master ... try this 1 ...
change this
if Tprefix[prefix] and cmd then
to this ..
if Tprefix[prefix] ==1 then
if cmd then
still the same error
then try a
for i , v in tPrefix do .... end
thing ...
local _,_,cmd=strfind(data,"%b<>%s+([%!%+%#%?%-]%S+)")
safest way, no need 4 prefix table, its like using a cannon for hunting sparrows
i can't get it work write
my command do not work when i chance to your's line sry
Now i have fin out is not write in my DataArrival it do whith the first i made :S
i Realy need Some help
i don't now why it do it when i past ? in the main it get's a nil function in ptokax...plz help
QuoteOriginally posted by Themaster
i don't now why it do it when i past ? in the main it get's a nil function in ptokax...plz help
Uhm ... how about posting your Main() ?
Hmm...i can't fix that error
i still have the same problem when ? come in main..how can i get it work so there are no problem ????
function Main()
loadfile(savekicks)
frmHub:UnregBot(BotName)
frmHub:RegBot(BotName)
frmHub:RegBot(OpChat)
TimeSpanInMinutes = 60
SendToAll(BotName,"?-=-=-=-? Script Reloaded at: "..date(" %X -- %d/%m-%Y").." ?Version? "..Version.." ?Build? "..Build.." ?Creators? "..Creators.." ?-=-=-=-?")
BotNameInfo = "$MyINFO $ALL "..BotName.." <++V:1.0 Blade? 1.0,C:Themaster? $ $LAN(T3)"..strchar( 1 ).."$$"
OpChatInfo = "$MyINFO $ALL "..OpChat.." <++V:1.0 Blade? 1.0,C:Themaster? $ $LAN(T3)"..strchar( 1 ).."$$"
SendToAll(ScriptRestart)
SendToAll(BotNameInfo)
SendToAll(OpChatInfo)
SetTimer(TimeSpanInMinutes*60000)
StartTimer()
end
oooh now I get it ... you mean the MainChat ! :)
that fault has to be data arrival ...
check the line the error happens ...
identify what variables are used ...
and make sure they all have values in them ( meaning that they should be declared at some point before that line ... )
if they have all been declared by a function
then try to make sure that the function returns real values ... (not nil)
SendToAll, SendToNick and so on should
help you "scan" through the various part and the various variable values ...
that i mean is when i do this ? in main is get a nil in ptokax how can i fix it
now i got what is made that error and i need help to get it write
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
Try this!
if (strsub(data, 1, 1) == "<" ) then
local data = strsub(data,1,strlen(data)-1)
local _,_,prefix,cmd=strfind(data, "%b<>%s+(.)(%S+)")
if Tprefix[prefix] and cmd then
prefixcmd = Tprefix[prefix]..cmd
local Commands = Commands(user, data, cmd)
return Commands
i still got the same error :s
post me the tprefix table
but already told u not 2 make a table 4 this
i have try to get it short but it still made the error
in DataArrival
if (strsub(data, 1, 1) == "<" ) then
local data = strsub(data,1,strlen(data)-1)
local _,_,prefix,cmd=strfind(data, "%b<>%s+(.)(%S+)")
if Tprefix[prefix] and cmd then
prefixcmd = Tprefix[prefix]..cmd
local Commands = Commands(user, data, cmd)
return Commands
in Setup
--// Prefix
Tprefix = {
["!"] = 1,
["+"] = 1,
["-"] = 1,
["/"] = 1,
}
If prefix is a control charackter you could use %c in reg.exp
like what ?
if (strsub(data, 1, 1) == "<" ) then
local data = strsub(data,1,strlen(data)-1)
local _,_,cmd=strfind(data, "%b<>%s+(%S+)")
if cmd and Tprefix[strsub(cmd,1,1)] then -- gets the 1st char of the cmd string and sees if its in the table
prefixcmd = cmd
local Commands = Commands(user, data, strsub(cmd,2,strlen(cmd))) -- stripping the prefix
return Commands
Now some notes:
/ as prefix is bad, not all clients send it 2 hub
Dont use a table when u can use:
local _,_,cmd=strfind(data,"%b<>%s+[%!%+%-%/](%S+)) -- checks if the 1st word in main is starting with ! or - or / or +
k...now i got it..but why can't i made so there are a table to change it else ??
whats the use of having it all in a table? or whats the harm, if u dont prevent users using +help instead of !help?
Hmm....now my commands is dead !!!!
i dont understand what u r up to so please post the entire script
you have post this
local _,_,cmd=strfind(data,"%b<>%s+[%!%+%-%/](%S+)) -- checks if the 1st word in main is starting with ! or - or / or +
it just need a "
local _,_,cmd=strfind(data,"%b<>%s+[%!%+%-%/](%S+)") -- checks if the 1st word in main is starting with ! or - or / or +
that why it was dead
ah sry just bought my new HDD and im moving about 100G data, so i am attending to 6 things - sry
ok...hmm...damn now when i do +help there is nothing going on :s
hm i can't Not get it work write now... here is my script
sec = 1000
min = 60*sec
hour = 60*min
day = 24*hour
Version ="Blade? 1.0"
Build ="?1.7?"
Creators ="Themaster?"
HubName = frmHub:GetHubName()
HubDesc = frmHub:GetHubDescr()
Redirect = frmHub:GetRedirectAddress()
MaxUsers = frmHub:GetMaxUsers()
MinShare = frmHub:GetMinShare(3)
pmArray={}
awayArray={}
MainArray={}
Symbol = { "%c", "?", "|" }
maxkicks = 3
kicks = {}
warn = {}
ScriptRestart = {}
Kennylizednicks = {}
savekicks = "blade/logs/count.kicks.txt"
WriteKickBan = "blade/logs/writekickban.txt"
rules = "blade/txt/rules.txt"
network = "blade/txt/network.txt"
Guard_File = "blade/PeerGuardian/Guarding.P2P"
function Main()
loadfile(savekicks)
frmHub:UnregBot(BotName)
frmHub:RegBot(BotName)
frmHub:RegBot(OpChat)
TimeSpanInMinutes = 60
SendToAll(BotName,"?~~~~? Script ReStart at: "..date(" %X -- %d/%m-%Y").." ? Version ? "..Version.." ? Build ? "..Build.." ? Creators ? "..Creators.." ?~~~~?")
BotNameInfo = "$MyINFO $ALL "..BotName.." <++V:1.0 Blade? 1.0,C:Themaster? $ $LAN(T3)"..strchar( 1 ).."$$"
OpChatInfo = "$MyINFO $ALL "..OpChat.." <++V:1.0 Blade? 1.0,C:Themaster? $ $LAN(T3)"..strchar( 1 ).."$$"
SendToAll(ScriptRestart)
SendToAll(BotNameInfo)
SendToAll(OpChatInfo)
SetTimer(TimeSpanInMinutes*60000)
StartTimer()
end
function OnTimer()
SendAdMessage()
end
function SendAdMessage()
upline = "~~~~~~~~~~~~H~U~B~~S~T~A~T~S~~~~~~~~~~"
underline = "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
hubstats = "\r\n\r\n"..upline.."\r\n"..
" ?Script Version: "..Version.."\r\n"..
" ?Build: "..Build.."\r\n"..
" ?Script Creator: "..Creators.."\r\n"..
" ?Hub Name: "..HubName.."\r\n"..
" ?Hub Description: "..HubDesc.."\r\n"..
" ?Hub Adress: "..HubAdress.."\r\n"..
" ?Web Adress: "..WebAdress.."\r\n"..
" ?Owner: "..HubOwner.."\r\n"..
" ?Online Users: "..frmHub:GetUsersCount().."\r\n"..
" ?Redirect Adress: "..Redirect.."\r\n"..
" ?Maximum Users: "..MaxUsers.."\r\n"..
" ?Hub Network: !network".."\r\n"..
" ?Hub Rules: !rules".."\r\n"..underline.."\r\n".." "
SendToAll(BotName, hubstats)
end
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+)")
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
replaced = nil
local newmsg = gsub(data,"(%w+)",
function (word)
if tWords[strlower( word )] then
replaced = 1
return tWords[strlower( word )]
else
return word
end
end)
if replaced then
SendToAll(""..newmsg.."|")
return 1
end
if strsub(data, 1, 5) == "$To: " then
local s,e,to,from,text = strfind(data, "%$To:%s(%S+)%sFrom:%s(%S+)%s$(.*)$")
if to == OpChat then
if user.bOperator then
local s,e,msg = strfind(text,"^%b<>%s+(.+)")
OpChatRoom(user,msg)
end
end
end
end
function NewUserConnected(user,data)
user:SendData(" Use !help in main for your Command! ")
Connected(user)
end
OpConnected = NewUserConnected
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
function BlockGuard(ip)
local _,_,a,b,c,d = strfind(ip "(%d*).(%d*).(%d*).(%d*)")
if ( tonumber(a) and tonumber(b) and tonumber (c) and tonumber (d) ) then
local uip = Computer(ip)
if uip then
for ranger,comp in Guard do
local _,_,r1,r2 = strfind(ranger, "(.*)-(.*)")
r1 = ComputeIP(r1)
r2 = ComputeIP(r2)
if uip>=r1 and uip <=r2 then
return 1,comp
end
end
end
end
end
function Computer(curIP)
local _,_,a,b,c,d = strfind (curIP, "(%d+).(%d+).(%d+).(%d+)")
return a*16777216 + b*65536 + c+256 + d
end
function DeComputeIP(cIP)
local temp1 = mod(cIP,16777216)
local temp2 = mod(temp1,65536)
return (floor(cIP/16777216).."."..floor(temp1/65536).."."..floor(temp2/256).."."..floor(mod(temp2,256)))
end
function LoadGuard(table,file)
local handle = openfile(file, "r")
if (handle) then
local line = read(handle)
while line do
s,e,ind,val = strfind( line, "(.*):(.*)")
if ind and val then
table[val]=ind
end
line = read(handle)
end
closefile(handle)
end
end
function Readtextfile(user, file)
local filecontents = ""
local handle = openfile(file, "r")
if (handle ~= nil) then
local line = read(handle)
while line do
filecontents = filecontents..line.."\r\n"
line = read(handle)
end
closefile(handle)
user:SendPM(Bot, filecontents)
end
end
function Readtextfile(user,file)
local filecontents = ""
local line
ret,err = readfrom("blade/txt/"..file)
if ret then
while 1 do
line = read()
if line == nil then
break
end
filecontents = filecontents..line.."\r\n"
end
user:SendPM(BotName, filecontents)
readfrom()
else
user:SendData(BotName, "Error: "..file.." not found")
end
end
function WriteKickBan(what)
appendto("blade/logs/banned.txt")
write(what.."\n")
writeto()
end
function WriteKicked(what)
appendto("blade/logs/kicked.txt")
write(what.."\n")
writeto()
end
function ReadKicked(user, data)
readfrom("blade/logs/kicked.txt")
local message = ""
while 1 do
local line = read()
if line == nil then break
else
message = message..line.."\r\n"
end
end
user:SendPM(BotName, "\r\n"..message)
end
function WriteKickBan(what)
appendto("blade/logs/banned.txt")
write(what.."\n")
writeto()
end
function ReadKickBan(user, data)
readfrom("blade/logs/banned.txt")
local message = ""
while 1 do
local line = read()
if line == nil then break
else
message = message..line.."\r\n"
end
end
user:SendPM(BotName, "\r\n"..message)
end
plz test it and tell me where bug is
it still a problem with ?
its only me that cant see Commands function?
And also i suggest you take more care in your tabbing ...
example :function LoadGuard(table,file)
local handle = openfile(file, "r")
if (handle) then
local line = read(handle)
while line do
s,e,ind,val = strfind( line, "(.*):(.*)")
if ind and val then
table[val]=ind
end
line = read(handle)
end
closefile(handle)
end
end
would read very very bad comparing to this :function LoadGuard(table,file)
local handle = openfile(file, "r")
if (handle) then
local line = read(handle)
while line do
s,e,ind,val = strfind( line, "(.*):(.*)")
if ind and val then
table[val]=ind
end
line = read(handle)
end
closefile(handle)
end
end
Also look out for globals ... try and keep their count to as low as possible ...example
somevariable = 1 --- this is a global
local somevariable = 1 --- this is a local
this has an impact on the memory the script consumes ...
have a lillte problem again.
it is my word replaced i have this bot if i writ some stoff in PM then they send the replaced word to all users
replaced = nil
local newmsg = gsub(data,"(%w+)",
function (word)
if tWords[strlower( word )] then
replaced = 1
return tWords[strlower( word )]
else
return word
end
end)
if replaced then
SendToAll(""..newmsg.."|")
return 1
end
this fuction probably isnt notified if the conversation goes in PM - and the SendToAll isnt a lucky choice :P
if i do m8 in PM then they come a other PM with Mate
Sry i don't post that
i have that code
replaced = nil
local newmsg = gsub(data,"(%w+)",
function (word)
if tWords[strlower( word )] then
replaced = 1
return tWords[strlower( word )]
else
return word
end
end)
if replaced then
SendToAll(""..newmsg.."|")
return 1
end
if i do 1 off the thing in word replace in PM then it show it to all...and that i have a problem i just only want 2 have in main