Ok guys I have this script I'm trying to make and I'm having some problems with commands. All the commands work except for commands after my mass message command. I probably missed something but I'm sure you guys can pick it out.
function DataArrival(user,data)
if (strsub(data, 1, 1) == "$" and SearchAllow == 0 and strfind(data,"Search")) then
SendToNick(user.sName,"<"..Bot.."> Searching in this hub has been disabled.")
return 1
end
if (strsub(data, 1, 1) == "$" and DownloadAllow == 0 and strfind(data,"ConnectToMe")) then
SendToNick(user.sName,"<"..Bot.."> Downloading in this hub has been disabled.")
return 1
end
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.."death" then
deathfunction(user)
return 1
elseif (cmd==prefix.."mm") 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 send.")
end
SendPmToAll(MMBot,"-#####- "..message.." -#####-")
end
elseif (cmd=="hubinfo") then
user:SendPM(Bot, "The Hub Name is: "..frmHub:GetHubName().."")
user:SendPM(user.sName, Bot, "The Hub Description is set to: "..frmHub:GetHubDescr().."")
end
end
end
this one should work:
function DataArrival(user,data)
if (strsub(data, 1, 1) == "$" and SearchAllow == 0 and strfind(data,"Search")) then
SendToNick(user.sName,"<"..Bot.."> Searching in this hub has been disabled.")
return 1
end
if (strsub(data, 1, 1) == "$" and DownloadAllow == 0 and strfind(data,"ConnectToMe")) then
SendToNick(user.sName,"<"..Bot.."> Downloading in this hub has been disabled.")
return 1
end
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.."death" then
deathfunction(user)
return 1
elseif (cmd==prefix.."mm") and user.bOperator then
s,e,cmd,message = strfind(data,"%s+(%S+)%s+(.*)")
if message == nil then
user:SendData(Bot,"Please enter a message to send.")
return 1
else
SendPmToAll(MMBot,"-#####- "..message.." -#####-")
return 1
end
elseif (cmd=="hubinfo") then
user:SendPM(Bot, "The Hub Name is: "..frmHub:GetHubName().."")
user:SendPM(user.sName, Bot, "The Hub Description is set to: "..frmHub:GetHubDescr().."")
return 1
end
end
end
I hope ;-)
A little notice right now...
Think the script has always worked...
noticed that this might be your prob.
elseif (cmd=="hubinfo") then
and
your other commands
if cmd == prefix.."death" then
maybe you just forgot prefix..
infront off your hubinfo command...
Thanks Nightlitch, I already checked the way i did the elseif's I just forgot to do an else on the mass message and a few returns, now everything is working again, Thanks :D
Btw, what is the difference in using elseif (cmd=="hubinfo") then
or elseif cmd == "hubinfo" then
?
QuoteOriginally posted by Josh_J
Btw, what is the difference in using elseif (cmd=="hubinfo") then
or elseif cmd == "hubinfo" then
?
not much and still something, sounds weird doesn't it. lol
(cmd=="hubinfo") if they are not the same it returns nil, if not nil the elseif is procesed.
cmd == "hubinfo" checks if they are the same, if they are the same the elseif is procesed.
basicly you tell by adding something between ( ) that lua has 2 proces them as 1 in a polite way.
for example:
BigString = tinystring..moretinystring..eventinyer
can be done but better 2 use:
BigString = (tinystring..moretinystring..eventinyer)
plop
in my experience i think cmd == "wharever" seems to do just as mushc as (cmd== "whaver")
either way its getting checked
QuoteOriginally posted by (uk-kingdom)pH?tt?
in my experience i think cmd == "wharever" seems to do just as mushc as (cmd== "whaver")
either way its getting checked
yep the result is the same.
like they say, there's more then 1 way 2 rome.
without the () it's a tiny bit faster as lua processes every character and it needs 2 read 2 less characters.
plop
yep eheh :))