help with minversion script
 

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

help with minversion script

Started by blackwings, 28 February, 2005, 20:12:14

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

blackwings

I saw the script that checks for min version in DC++, but does this also work, or does it only work for DC++? =
-- Simply script to disallow old DC++ clients without TTH support by PPK
-- Changed into a minversion script by blackwings

function NewUserConnected(curUser)
	if curUser.bHasTag then
		if curUser.sClient == "DC++" then
			if tonumber(curUser.sClientVersion) < 0.401 then
				curUser:SendData("Please upgrade your client, min version for  in this hub is <0.401>")
				curUser:Disconnect()
				return 1
			end 
		elseif curUser.sClient == "oDC" then
			if tonumber(curUser.sClientVersion) < 5.0 then
				curUser:SendData("Please upgrade your client, min version for  in this hub is <5.0>")
				curUser:Disconnect()
				return 1
			end 
		elseif curUser.sClient == "DCGUI" then
			if tonumber(curUser.sClientVersion) < 0.2.20 then
				curUser:SendData("Please upgrade your client, min version for  in this hub is <0.2.20>")
				curUser:Disconnect()
				return 1
			end 
		elseif curUser.sClient == "NMDC2" then
			if tonumber(curUser.sClientVersion) < 2.02 then
				curUser:SendData("Please upgrade your client, min version for  in this hub is <2.02>")
				curUser:Disconnect()
				return 1
			end 
		elseif curUser.sClient == "iDC++" then
			if tonumber(curUser.sClientVersion) < 1.03 then
				curUser:SendData("Please upgrade your client, min version for  in this hub is <1.03>")
				curUser:Disconnect()
				return 1
			end 
		end
	end 
end


Herodes

hm I thought saying it with tables would help ...
I apologise for the lack of testing on this one but many things need a piece of my time ...
-- Simply script to disallow old DC++ clients without TTH support by PPK
-- Changed into a minversion script by blackwings
-- Made It Into Tables by Herodes ( not tested @all but hopefully it works )

tCl = {
	["DC++"] = { 0.401, "Please upgrade your client, min version for  in this hub is <0.401>" } ,
	["oDC"] = { 5.0, "Please upgrade your client, min version for  in this hub is <5.0>" } ,
	["DCGUI"] = { 0.2.20, "Please upgrade your client, min version for  in this hub is <0.2.20>" } ,
	["NMDC2"] = { 2.02, "Please upgrade your client, min version for  in this hub is <2.02>" },
	["iDC"] = { 1.03,  "Please upgrade your client, min version for  in this hub is <1.03>" } ,
}

function NewUserConnected(curUser)
	if curUser.bHasTag and tCl[curUser.sClient] then
		if tonumber(curUser.sClientVersion) < tCl[curUser.sClient][1] then
			curUser:SendData(tCl[curUser.sClient][2])
			curUser:Disconnect()
			return 1
		end 
	end 
end

blackwings

#2
Hmm, ptokax doesn't like DCGUI min version =
["DCGUI"] = { 0.2.20, "Please upgrade your client, min version for  in this hub is <0.2.20>" } ,


Herodes

Fastest of patches dont always work .. but should be tried nevertheless...
-- Simply script to disallow old DC++ clients without TTH support by PPK
-- Changed into a minversion script by blackwings
-- Made It Into Tables by Herodes ( not tested @all but hopefully it works )

tCl = {
	["DC++"] = { "0.401", "Please upgrade your client, min version for  in this hub is <0.401>" } ,
	["oDC"] = { "5.0", "Please upgrade your client, min version for  in this hub is <5.0>" } ,
	["DCGUI"] = { "0.2.20", "Please upgrade your client, min version for  in this hub is <0.2.20>" } ,
	["NMDC2"] = { "2.02", "Please upgrade your client, min version for  in this hub is <2.02>" },
	["iDC"] = { "1.03",  "Please upgrade your client, min version for  in this hub is <1.03>" } ,
}

function NewUserConnected(curUser)
	if curUser.bHasTag and tCl[curUser.sClient] then
		if tonumber(curUser.sClientVersion) < tonumber(tCl[curUser.sClient][1]) then
			curUser:SendData(tCl[curUser.sClient][2])
			curUser:Disconnect()
			return 1
		end 
	end 
end

blackwings

I added a bad client function. Unfortunely the same method for minversion detection cannot be used. So I mad a similar thing to my Deny detection script. Because clients like DCDM doesn't have their "identification" in the usual tag, but in description. Anyway, here is the new code =
-- Simply script to disallow old DC++ clients without TTH support by PPK
-- Changed into a minversion script by blackwings
-- Made It Into Tables by Herodes ( not tested @all but hopefully it works )
-- FIXED:version numbers with more than one numbers work - by Herodes & blackwings
-- ADDED: Bad clients to be blocked

tCl = {
	["DC++"] = {"0.401","Please upgrade your client, min version for  in this hub is <0.401>"},
	["oDC"] = {"5.0","Please upgrade your client, min version for  in this hub is <5.0>"},
	["DCGUI"] = {"0.2.20","Please upgrade your client, min version for  in this hub is <0.2.20>"},
	["NMDC2"] = {"2.02","Please upgrade your client, min version for  in this hub is <2.02>"},
	["iDC"] = {"1.03", "Please upgrade your client, min version for  in this hub is <1.03>"},
}

tClBad = {
{"<%.%P>","Phantom DC++","cccc"},
{""},
}

function NewUserConnected(curUser)
	if not curUser.bOperator then
		if curUser.bHasTag and tCl[curUser.sClient] then
			if tonumber(curUser.sClientVersion) < tonumber(tCl[curUser.sClient][1]) then
				curUser:SendData(tCl[curUser.sClient][2])
				curUser:Disconnect()
				return 1
			end 
		end 
	end
end


function MyINFOArrival(User , data)
	if not User.bOperator then
		for i=1,table.getn(tClBad) do
			tClBad[i][1] = string.gsub(tClBad[i][1], "<" , "")
			if string.find(data,tClBad[i][1]) and not string.find(data,tClBad[i][3]) then
				local Client=tClBad[i][2]
				User:SendData("------------------------------------------------------------------------------")
				User:SendData("*** The Client <"..Client.."> isn't allowed in this hub.")
				User:SendData("*** Use Original DC++, NMDC, oDC or DCGUI")
				User:SendData("------------------------------------------------------------------------------")
				User:Disconnect()
			end
		end
	end
end


SMF spam blocked by CleanTalk