Need some help with DataArrival
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

Need some help with DataArrival

Started by Josh_J, 01 January, 2004, 21:01:53

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Josh_J

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

NightLitch

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 ;-)
//NL

NightLitch

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

Josh_J

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

Josh_J

Btw, what is the difference in using
elseif (cmd=="hubinfo") then
or
elseif cmd == "hubinfo" then
?

plop

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
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 <----<<

pHaTTy

in my experience i think cmd == "wharever" seems to do just as mushc as (cmd== "whaver")

either way its getting checked
Resistance is futile!

plop

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
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 <----<<

pHaTTy

Resistance is futile!

SMF spam blocked by CleanTalk