Problem with My LUA 5 Slot checker
 

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

Problem with My LUA 5 Slot checker

Started by blackwings, 02 March, 2005, 22:02:33

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

blackwings

I'm making a slots checker. But I have one problem, the max slot check doesn't work :( I log in with 5 slots, but even so it says I have to many slots open (max is 30 as you see.)

The min version works as it should anyway :)

-- Simple Slot checker by blackwings LUA 5
-- version 1.0

Bot = "#slot-checker"

-- ["Profile"] = {minSlot,maxSlot},
tlSlots = {
	[2] = {"2","30"},
	[3] = {"2","30"},
	[-1] = {"2","30"},
}

function MyINFOArrival(user,data) 
	if tlSlots[user.iProfile] then
		local s,e,tag=string.find(user.sMyInfoString, "(%b<>)%$")
		if tag ~= nil then
			s,e,slots = string.find(tag,"S:(%d+)")
			return slotchecking(user,slots)
		end
	end
end

function slotchecking(user,slots)
	local minSlot = tlSlots[user.iProfile][1]
	local maxSlot = tlSlots[user.iProfile][2]
	if slots < minSlot then
		user:SendData(Bot, "Minimum "..minSlot.." slots!!!")
		user:Disconnect()
	elseif slots > maxSlot then
		user:SendData(Bot, "Maximum "..maxSlot.." slots!!!")
		user:Disconnect()
	end
end


bastya_elvtars

Posting my myinfo parsing routine in lua4. Please convert and adapt it.

-- myinfo scanning routine
-- bastya_elvtars
-- used code from consolemoon by [NL]Pur

checks.scanmyinfo=function(myinfo) ----------
	local _,_,Hubs,Slots,speed = strfind(myinfo, "H:([^,]+),S:(%d+).*>$ $([^$]+)[^$]%$")
	local Guest,Reg,OP,slots,hubs,ratio
	local Maxslotsforconn,Ratioforconn,Maxhubsforconn,minlimitforconn=slotperhub[speed].max_slots,slotperhub[speed].min_ratio,slotperhub[speed].max_hubs,slotperhub[speed].min_limit
	local _,_,limit1=strfind(myinfo,"[BLU]:(%d+)")
	local _,_,limit2 = strfind(myinfo,"F:%d+/(%d+)")
	local _,_,temp = strfind(myinfo, "$(%d+)%$")
	if tonumber (Hubs) then
		if Hubs=="0" then
			Guest,Reg,OP= "0", "1" , "0"
		else
			Guest,Reg,OP=  Hubs, "0", "0"
		end
	else
		_,_, Guest,Reg,OP = strfind(Hubs,"(%d+)/(%d+)/(%d+)")
	end
	if ophubscount==1 then
		hubs = tonumber(Guest)+tonumber(Reg)+tonumber(OP)
		slots=tonumber(Slots)
		ratio=slots/hubs
	else
		hubs = tonumber(Guest)+tonumber(Reg)
		slots=tonumber(Slots)
		if hubs==0 then
			ratio=slots
		else
			ratio=slots/hubs
		end
	end
	local Share = format("%0.2f", tonumber(temp)/gb)
	if limit1 then
		return hubs,slots,Guest,Reg,OP,speed,limit1,Maxslotsforconn,Ratioforconn,Maxhubsforconn,minlimitforconn,ratio,Share
	elseif limit2 then
		return hubs,slots,Guest,Reg,OP,speed,limit2,Maxslotsforconn,Ratioforconn,Maxhubsforconn,minlimitforconn,ratio,Share
	else
		return hubs,slots,Guest,Reg,OP,speed,nil,Maxslotsforconn,Ratioforconn,Maxhubsforconn,minlimitforconn,ratio,Share
	end
end
Everything could have been anything else and it would have just as much meaning.

blackwings

ok, didn't understand to much of it.

the parts with share,hubs,limit1,limit2 and temp has nothing to do with my script.

The only thing that has to do with my script is the "slots=tonumber(Slots)" .

But I'm not sure how I should use it.


bastya_elvtars

I just presented a generic way to show how slots count can be determined. If you do not want to use it, you won't. But the expression 'thank you' is always worth using. I have talked about this before.
Everything could have been anything else and it would have just as much meaning.

blackwings

#4
QuoteOriginally posted by bastya_elvtars
I just presented a generic way to show how slots count can be determined. If you do not want to use it, you won't. But the expression 'thank you' is always worth using. I have talked about this before.
sorry, I appreciate you giving it to me. I didn't mean to sound rude.

Anyway, checked at your script again and now my script works perfectly :D


bastya_elvtars

local _,_,Slots = string.find(myinfo, "S:(%d+)")

Let's repeat what we have learned from last time:
we search for a string value in the myinfo that consists of 1 or more digits (%d+) and comes after S:.

Hope I was clear.

And yes, you sometimes seem rude. It does not matter for me, but I like to see people who are happy that I helped them. And your words seem sometimes hmm... dissatisfied.
Everything could have been anything else and it would have just as much meaning.

blackwings

#6
QuoteOriginally posted by bastya_elvtars
local _,_,Slots = string.find(myinfo, "S:(%d+)")

Let's repeat what we have learned from last time:
we search for a string value in the myinfo that consists of 1 or more digits (%d+) and comes after S:.

Hope I was clear.

And yes, you sometimes seem rude. It does not matter for me, but I like to see people who are happy that I helped them. And your words seem sometimes hmm... dissatisfied.
well, maybe I will try to sound less "objective" next time I post :)

Anyway, my script works now and I thank you for your help :D


SMF spam blocked by CleanTalk