Author Topic: Need some help with DataArrival  (Read 2461 times)

0 Members and 1 Guest are viewing this topic.

Offline Josh_J

  • Junior Member
  • **
  • Posts: 15
  • Karma: +0/-0
Need some help with DataArrival
« on: 01 January, 2004, 21:01:53 »
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.

Code: [Select]
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

PtokaX forum

Need some help with DataArrival
« on: 01 January, 2004, 21:01:53 »

Offline NightLitch

  • Emperor
  • **
  • Posts: 1 455
  • Karma: +16/-0
(No subject)
« Reply #1 on: 01 January, 2004, 21:08:08 »
this one should work:

Code: [Select]
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 ;-)
//NL

Offline NightLitch

  • Emperor
  • **
  • Posts: 1 455
  • Karma: +16/-0
(No subject)
« Reply #2 on: 01 January, 2004, 21:10:48 »
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...
//NL

Offline Josh_J

  • Junior Member
  • **
  • Posts: 15
  • Karma: +0/-0
(No subject)
« Reply #3 on: 01 January, 2004, 21:18:44 »
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

Offline Josh_J

  • Junior Member
  • **
  • Posts: 15
  • Karma: +0/-0
(No subject)
« Reply #4 on: 01 January, 2004, 21:27:56 »
Btw, what is the difference in using
Code: [Select]
elseif (cmd=="hubinfo") then or
Code: [Select]
elseif cmd == "hubinfo" then?

Offline plop

  • Forum God
  • ****
  • Posts: 2 464
  • Karma: +37/-0
(No subject)
« Reply #5 on: 02 January, 2004, 03:36:05 »
Quote
Originally posted by Josh_J
Btw, what is the difference in using
Code: [Select]
elseif (cmd=="hubinfo") then or
Code: [Select]
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
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

Offline pHaTTy

  • Forum Legend
  • ***
  • Posts: 1 916
  • Karma: +5/-1
(No subject)
« Reply #6 on: 02 January, 2004, 11:07:00 »
in my experience i think cmd == "wharever" seems to do just as mushc as (cmd== "whaver")

either way its getting checked
Resistance is futile!

Offline plop

  • Forum God
  • ****
  • Posts: 2 464
  • Karma: +37/-0
(No subject)
« Reply #7 on: 02 January, 2004, 15:35:54 »
Quote
Originally 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
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

Offline pHaTTy

  • Forum Legend
  • ***
  • Posts: 1 916
  • Karma: +5/-1
(No subject)
« Reply #8 on: 02 January, 2004, 15:57:42 »
yep eheh :))
Resistance is futile!

PtokaX forum

(No subject)
« Reply #8 on: 02 January, 2004, 15:57:42 »