need help with this function...
 

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 help with this function...

Started by blackwings, 11 September, 2005, 23:44:03

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

blackwings

I have 2 problems with this client checker script =
1) if user's client version is above the minversion set by script and acces,
I get this error message, but only if there are 2 or more clients in tClient =
[23:17] Syntax C:\ptokax03321\scripts\clientchecker.lua:13: attempt to concatenate global `xTag2' (a nil value)
2) if its a NewUserConnected instead MyINFOArrival, then pm from bots will be sent to user before
the user get disconnected, which I don't want it to.
Bot = "#clientCheck"

tClient = {
	["zDC%+%+%[(%d)%.(%d+)"] = {0.666,"*** Please upgrade your client, min version for  in this hub is <0.666>"},
	[""] = {1.2,"*** Please upgrade your client, min version for  in this hub is <1.3>"},
}

function MyINFOArrival(user)
	if not user.bOperator then
		if user.bHasTag then
			for k,v in tClient do
				s,e,xTag1,xTag2 = string.find(user.sDescription, k)
				xTag =xTag1.."."..xTag2
				if tonumber(xTag)


Corayzon

sBot = "#ClientCheck"

tClient =
{
	["%<%+%+%sV%:(%d)%.(%d+)"] = {1.100,"*** Please upgrade your client, min version for DC++ in this hub is 1.100"},
	["%"] = {1.2,"*** Please upgrade your client, min version for  in this hub is <1.2>"},
}

function MyINFOArrival(user)
	if not user.bOperator then
		if user.bHasTag then
			for sSearchPattern,tData in tClient do
				-- Search for client pattern
				local _,_, xTag1, xTag2 = string.find(user.sTag, sSearchPattern)
				-- Check if version was found in tag
				if xTag1 and xTag2 then
					local xTag = tonumber(xTag1 .. "." .. xTag2)
					--user:SendData("xTag = " .. xTag)
					--user:SendData("tData[1] = " .. tData[1])
					-- Check if client version is to old
					if xTag < tonumber(tData[1]) then
						user:SendData(sBot,tData[2])
						user:Disconnect()
						return 1
					end
				end
			end
		else
			user:SendData(sBot,"*** Use Original DC++, fulDC, or DCTC(for linux users)")
			user:SendData(sBot,"*** Original DC++ Homepage: [URL]http://dcplusplus.sourceforge.net/[/URL] <<< Double Click To Open Page")
			user:Disconnect()
		end 
	end
end

Answers to your questions:

1 - Bad programming of course. These where what i fixed:

* Pattern seach was checking user.sDescription not user.sTag
* There was no check if client version was found or not! (giving u an error if the pattern wasnt matched!)
* Made local variables LOCAL!!!!!!!!!!!!!
* Changed some variable names to make it easier to read

2 - U dont want a disconnecting user to see why they have been kicked?

blackwings

QuoteOriginally posted by Corayzon
2 - U dont want a disconnecting user to see why they have been kicked?
yes I want them to see why they are kicked. What I meant is that for example I have in my hub a script that sends a login message in PM to user when the user connects. This login message sent to user before user gets disconnected, which doesn't happend with MyINFOArrival, because its faster. But I dont want it to check users all the time, just when they connect, but I dont want disconnected users to see the login msg pm.


Corayzon

Gotcha,

Well in the old versions of PtokaX, if u sent data in this function it would be before PtokaX's motd. Meaning u would need to add timers for sending things like welcome messages ontop of PtokaX's motd.

But this doesnt relate if its ur script sending the motd and not PtokaX. Soooo: ...

Make sure this function executes before ur welcome message is sent. And then ur problem will be solved.

Anyways:

I dont think u need to worry about this to much, because the $MyINFO string is only sent when a user connects or a user changes there settings. And the processing invloved in this script is very minor. So its not like ur gonna have cpu\packet lag because of it =]

SMF spam blocked by CleanTalk