Hi all,
I am having troblems with the args for example
function GetArgML(data)
s,e,cmd,arg = strfind(data, "%b<>%s+(%S+)%s+(%S+)%s*")
return arg
function XXXX(user, data)
GetArgML(data)
local xpto = GetItemByName(arg)
--and any function
This works fine, but some times the script editor gives me this error:
"Syntax Error: attempt to index local `xpto' (a nil value)"
And the functions stop working !
Am I doing somthing wrong ???
Best regrads, nErBoS
Is there anyone who can help me in this problem ???
QuoteOriginally posted by nErBoS
Hi all,
I am having troblems with the args for example
function GetArgML(data)
s,e,cmd,arg = strfind(data, "%b<>%s+(%S+)%s+(%S+)%s*")
return arg
function XXXX(user, data)
GetArgML(data)
local xpto = GetItemByName(arg)
--and any function
This works fine, but some times the script editor gives me this error:
"Syntax Error: attempt to index local `xpto' (a nil value)"
And the functions stop working !
Am I doing somthing wrong ???
Best regrads, nErBoS
test this
function GetArgML(data)
s,e,cmd,arg = strfind(data, "%b<>%s+(%S+)%s+(%S+)%s*")
return arg
end
function XXXX(user, data)
local arg = GetArgML(data)
local xpto = GetItemByName(arg)
--and any function
No, got the same error :(
are you sure the user is online??
GetItemByName(arg) only works on online users
Check it with a if nil statement
Quoteare you sure the user is online??
GetItemByName(arg) only works on online users
yes i know !!
QuoteCheck it with a if nil statement
didn?t understand !!
function XXXX(user, data)
local arg = GetArgML(data)
if arg == nil then
user:SendData("No such user")
end
else
local xpto = GetItemByName(arg)
--whatever
-phatty
function XXXX(user, data)
local arg = GetArgML(data)
if arg == nil then
user:SendData("No argument")
else
local xpto = GetItemByName(arg)
if xpto then
-- your code
else
user:SendData("Couldn't find "..arg.." online")
end
--whatever
Still gives me the same error !! :(
is it possible to see more of your code???
elseif (cmd=="!gag") then
local arg = GetArgML(data)
if arg == nil then
user:SendData(Bot, "N?o foi encontrado user !!")
else
local gagged = GetItemByName(arg)
gagged:SendPM(Bot, "Foste impedido de falar no Main-Chat !")
SendPmToOps(Bot, "O utilizador "..gagged.sName.." foi impedido de falar no Main-Chat por "..user.sName.." !")
end
return 0
This is one of the functions where e get the error
Try as i did in my example code..
I think the probel is this i typed
"!gag nerbos"
and aperas this..
[21:37] Couldn't find nerbo online
[21:37] *** nErBoS has gagged: nErBoS
there for the problem i think is with the function arg do you know a function for long args ??
long args??
!gag skrollster because he doesn't know a damn thing
s,e,cmd,arg = strfind(data, "%b<>%s+(%S+)%s+(.+)")
will return
cmd = "!gag"
arg = "skrollster because he doesn't know a damn thing"
s,e,cmd,arg = strfind(data, "%b<>%s+(%S+)%s+(%S+%s+%S+)")
will return
cmd = "!gag"
arg = "skrollster because"
i know why it doesn't work, lua is case sensitive
SkRoLlStEr isnt the same thing as Skrollster
sorry a bad explaintion from my part !!
if you notice i wrote in the comand my nick and on the retrive the bot sends my nick without the "s"
i think this must be a problem with the arg function !!
i think i know what the problem is but i'm not sure..
i guess that you cut the end of data 2 times
do you do this twice??
-- remove end pipe
data=strsub(data,1,strlen(data)-1)
i think is this that you are meaning...
if (strsub(data, 1, 1) == "<") or (strsub(data,1,4) == "$To:") then
data=strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(data,"%b<>%s+(%S+)")
what i asked was if you did cut it of twice
sorry but my english is not very good !!
i am not understandig you question !!!!
is it possible for me to see your whole script??
it would help me a lot
Great !! I will send you the script in pm, becuase is big !!
Some of the functions you will reconize because i got from your bot : )
ok, hurry up, i have to get som sleep =)
Done =)
Problem solved, thanks to Skrollster
if anyone have the same problem just do this ..
where you have this
if (strsub(data, 1, 1) == "<") then
data=strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(data,"%b<>%s+(%S+)")
put this
if (strsub(data, 1, 1) == "<") then
s,e,cmd = strfind(data,"%b<>%s+(%S+)")
Thanks to all you tryed to help me !!
Best regards, nErBoS
P.S:"Great to have you back Skrollster"
No,no,no,no..
DO NOT remove that part from your scripts if you don't know what you are doing..
the reason why you should remove it was that you did already do that erlier in the script!!!
Having a problem again with the commands they are only working with ops the users can?t use then ,
where is my data arraival..
function DataArrival(user, data)
if (Slots == "Activo") then
if strfind(data, "%b<>%s+("..Command..").*|") then
s, e, nr = strfind(data, "%b<>%s+"..Command.."%s+([0-9]+)")
if s then nr = tonumber(nr) else nr = 1 end
doSlots(user, nr) return 1
end
if strfind(data, "^%$SR") then
slotsOnHub(user, data)
end
end
if (Slots == "Desactivo") then
user:SendPM(Bot, "O comando !slots est? desactivado.")
return 1
end
if (not user.bOperator) then
----------------------------------- Anti-Pub -------------------------------------------
if (AntiPUB == "Activo") then
if (( strsub(data, 1, 1) == "<" ) or ( strsub(data, 1, 4) == "$To:" )) then
for key,a in trigs do
if( strfind( strlower(data), key) ) then
local word = strlower(data), key
SendToAll(Bot, "O utilizador "..user.sName.." foi desconectado e kickado por publicidade." )
user:SendData(Bot, "Foste desconectado e kickado por publicidade.")
SendPmToOps(Bot, "O utilizador "..user.sName.." foi desconectado e kickado por publicidade.")
SendPmToOps(Bot, "O IP do utilizador era "..user.sIP.." .")
SendPmToOps(Bot, "O utilizador escreveu o seguinte: "..word)
user:Disconnect()
user:TempBan()
end
end
end
end
if (AntiPUB == "Desactivo") then
return
end
----------------------------------- Bad Files -------------------------------------------
if (BadFiles == "Activo") then
if( strsub(data, 1, 3) == "$SR" ) then
_,_,nick = strfind( data, "\05(%S*)|$" )
local s = 5 + strlen(user.sName)
local e = strfind(data, "%d+%s%d+/%d+") - 2
local path = strsub(data, s, e)
if( nick == Bot and Kicked[user.sName] == nil ) then
Kicked[user.sName] = 1
Reason = FindWhat(data)
if (Reason == "Other files") then return end
user:SendData(Bot, "V?ce foi desconectado e banido. Raz?o: "..Reason)
user:SendData(Bot, "O file em causa encontra-se em: "..path.. ".")
user:SendData(Bot, "Desconectado....")
user:Disconnect()
user:TempBan()
end
end
end
if(BadFiles == "Desactivo") then
return
end
----------------------------------- Open Extra Slot ------------------------------------------
if (OES == "Activo") then
if strfind(user.sMyInfoString,"O:%x+") then
user:SendData(Bot, "Settings do DC->Sharing , Open extra slot tem de estar em zero.")
user:SendData(Bot, "Desconectado...")
user:Disconnect()
end
end
if (OES == "Desactivo") then
return
end
end
if (strsub(data,1,1)=="<") or (strsub(data,1,5+strlen(Bot))=="$To: "..Bot) then
data=strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(data,"%b<>%s+(%S+)")
if (cmd=="!help") then
if (GetProfileName(user.iProfile) == "Operador" or GetProfileName(user.iProfile) == "Moderador") then
user:SendPM(Bot, help:utilizadores())
user:SendPM(Bot, help:operadores())
return 1
elseif (GetProfileName(user.iProfile) == "Administrador" or GetProfileName(user.iProfile) == "Master" or GetProfileName(user.iProfile) == "Fundador da Rede") then
user:SendPM(Bot, help:utilizadores())
user:SendPM(Bot, help:operadores())
user:SendPM(Bot, help:administradores())
return 1
else
user:SendPM(Bot, help:utilizadores())
return 1
end
elseif (cmd=="!rede") then
Readtextfile(user, rede)
return 1
elseif (cmd=="!regras") then
Readtextfile(user, regras)
return 1
elseif (cmd=="!hubinfo") then
HubInfo(user,data)
return 1
elseif (cmd=="!myip") then
user:SendPM(Bot, "O teu IP ? : "..user.sIP.." !")
return 1
elseif (cmd=="!ops")then
msg = "Lista de Operadores:\r\n\r\n"
for i = 1, getn(opLevels) do
local tmp = GetUsersByProfile(opLevels[i])
foreach(tmp, function(id, op)
if GetItemByName(op) then
msg=msg.."\t"..op.."\t\tOnline\r\n"
else
msg=msg.."\t"..op.." \t\tOffline\r\n"
end end)
end
user:SendPM(Bot, msg)
return 1
elseif (cmd=="!time") then
GetTime()
user:SendPM(Bot, Date)
return 1
elseif user.bOperator then
if (cmd=="!userinfo") then
UserInfo(user, data)
return 1
elseif (cmd=="!kickban") then
KickBan(user,data)
return 1
elseif (cmd=="!warn") then
Warn(user,data)
return 1
elseif (cmd=="!disconnect") then
Disconnect(user,data)
return 1
elseif (cmd=="!kick") then
Kick(user,data)
return 1
elseif (cmd=="!redirect") then
Redirect(user,data)
return 1
elseif (cmd=="!mm") then
_,_,message = strfind( data, "%b<>%s+%S+%s+(.+)" )
SendPmToAll(Bot, "\r\n\r\n\----------------------------------------[Assunto do Hub]----------------------------------------\r\n\r\n"..message.."\r\n\r\nMensagem enviada por: "..user.sName)
return 1
elseif (cmd=="!mmop") then
_,_,message = strfind( data, "%b<>%s+%S+%s+(.+)" )
SendPmToOps(Bot, "\r\n\r\n\----------------------------------------[Mensgem para OPs]----------------------------------------\r\n\r\n"..message.."\r\n\r\nMensagem enviada por: "..user.sName)
return 1
elseif (cmd=="!clrtempban") then
ClearTempBan()
SendPmToOps(Bot, "A lista de ban?s temporarios foi limpa por : " .. user.sName)
return 1
elseif (cmd=="!mred") then
MudarMoradaRedir(user,data)
return 1
elseif (cmd=="!mshare") then
MudarShare(user,data)
return 1
elseif (cmd=="!mnome") then
MudarNomeHub(user,data)
return 1
elseif (cmd=="!mdesc") then
HubDesc(user,data)
return 1
elseif (cmd=="!mregmorada") then
MudarMoradaReg(user,data)
return 1
elseif (cmd=="!redtodos") then
RedirecionarTodos(user,data)
return 1
elseif (cmd=="!mmaxusers") then
MudarMaxUsers(user,data)
return 1
elseif (cmd=="!argredtodos") then
MudarRedAll(user,data)
return 1
elseif (cmd=="!argredcheio") then
MudarRedFull(user,data)
return 1
elseif (cmd=="!clrpermban") then
if (GetProfileName(user.iProfile) == "Master" or GetProfileName(user.iProfile) == "Fundador da Rede") then
SendPmToOps(Bot, "A lista de ban?s permanentes foi limpa por : " .. user.sName)
return 0
else
user:SendPM(Bot, "N?o tens permiss?o para aceder a este comando !")
end
return 1
elseif (cmd=="!restart") then
if (GetProfileName(user.iProfile) == "Master" or GetProfileName(user.iProfile) == "Fundador da Rede") then
SendPmToOps(Bot, "O Hub vai ser reinicializado por : " .. user.sName)
return 0
else
user:SendPM(Bot, "N?o tens permiss?o para aceder a este comando !")
end
return 1
elseif (cmd=="!restartscripts") then
if (GetProfileName(user.iProfile) == "Master" or GetProfileName(user.iProfile) == "Fundador da Rede") then
SendPmToOps(Bot, "Os scripts do Hub v?o ser reinicializado por : " .. user.sName)
return 0
else
user:SendPM(Bot, "N?o tens permiss?o para aceder a este comando !")
end
return 1
elseif (cmd=="!gag") then
local arg = GetArgML(data)
if arg == nil then
user:SendData(Bot, "O utilizador "..arg.." n?o foi encontrado !")
else
local gagged = GetItemByName(arg)
gagged:SendPM(Bot, "Foste impedido de falar no Main-Chat !")
SendPmToOps(Bot, "O utilizador "..gagged.sName.." foi impedido de falar no Main-Chat por "..user.sName.." !")
end
return 0
elseif (cmd=="!ungag") then
local arg = GetArgML(data)
if arg == nil then
user:SendData(Bot, "O utilizador "..arg.." n?o foi encontrado !")
else
local gagged = GetItemByName(arg)
gagged:SendPM(Bot, "J? podes falar de novo no Main-Chat !")
SendPmToOps(Bot, "O utilizador "..gagged.sName.." foi de novo autorizado a falar no Main-Chat por "..user.sName.." !")
end
return 0
elseif (cmd=="!timeban") then
TimeBan(user,data)
return 1
elseif (cmd=="!ban") then
Ban(user,data)
return 1
elseif (cmd=="!aduser") then
RegistrarUsers(user, data)
return 1
elseif (cmd=="!rmuser") then
RemoverRegistro(user, data)
return 1
elseif (cmd=="!banip") then
BanIP(user,data)
return 0
elseif (cmd=="!unban") then
UnBan(user, data)
return 0
elseif (cmd=="!bloquear") then
SendAddGag(user,data)
return 1
elseif (cmd=="!desbloquear") then
SendDelGag(user,data)
return 1
elseif (cmd=="!bloqueados") then
SendGetGag(user,data)
return 1
elseif (cmd=="!banlist") then
Readtextfile(user, Banlist)
return 1
elseif (cmd=="!rmban") then
RemoveBan(user, data)
return 1
elseif (cmd=="!rmkick") then
RemoveKick(user, data)
return 1
elseif (cmd=="!kicklist") then
Readtextfile(user, Kicklist)
return 1
elseif (cmd=="!lmbanlist") then
LimparBan(user, data)
return 1
elseif (cmd=="!lmkicklist") then
LimparKicks(user, data)
return 1
end
end
end
----------------------------------- Client Kick -------------------------------------------
if strsub(data,1,6) == "$Kick " then
return 1
end
if strfind(data,"is kicking") then
local _,_, kicker,name,reason = strfind(data,"<%S+>%s(%S*)%sis kicking%s(%S*)%sbecause:%s(.*)")
local userToBeKicked = GetItemByName(name)
local operador = GetItemByName(kicker)
SendToAll(Bot, "O utilizador "..userToBeKicked.sName.." foi kickado por "..operador.sName.." porque: "..reason)
userToBeKicked:SendPM(Bot, "Foste kickado por "..operador.sName.." porque: "..reason)
appendto(Kicklist)
write("\r\n"..userToBeKicked.sName.."\t"..userToBeKicked.sIP.."\t"..operador.sName.."\t"..reason.."\t"..GetTime())
writeto()
userToBeKicked:TempBan()
return 1
end
if strfind(data,"You are being kicked because:") then
return 1
end
----------------------------------- Gag Downloads -------------------------------------------
if strsub(data,1,12) == "$ConnectToMe" then
local _,_, From,ToIp = strfind(data,"$ConnectToMe%s+(%S+)%s+(%d+.%d+.%d+.%d+):.*")
readfrom(Gags)
while 1 do
local line = read()
if line then
ip = strsub(line, strfind(line, "|") + 1)
if ip == ToIp then
return 1
end
else
break
end
end
end
readfrom()
end
can anyone help me ??
Best regards, nErBoS
I have this problem sometimes its works perfectly somtimes the users commands stop working. It?s possible to be a bug in the software hub ?? i doubt problay is mine please help !
In your case i wouln't use
if (not user.bOperator) then
It's not needed
i would have put the
if user.bOperator then
at the top, above all commands.
(Can't see much of your script, else i could show about where)
You've created new functions for each command of yours.
In that function, Let me take one for etc:
elseif (cmd=="!mmaxusers") then
MudarMaxUsers(user,data)
return 1
^^ -- That is the function you've created, Nothing wrong with it
function MudarMaxUsers(user,data)
if not user.bOperator then -- Notice this line
-- ToDO
^ --- so, let's say this command is for user's, Then, if im right, both users and Op's are able to use it... As you stated "if user.bOperator" before...
Sorry, i need som more coffee now...
though, i hope this helped you at least a little, wether im wrong or right on the subject..
Cause i do exactly the same as i've tried to explain in my script
I agree with everthing you said keep but the script gives me this error trow time to time, that was i a questioned, if isn?t a bug on the software !!
Best regards, nErBoS