Simple slot check script (LUA 5)
 

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

Simple slot check script (LUA 5)

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

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

blackwings

Here is a simple Slot checker script I made =
-- Simple Slot checker by blackwings LUA 5
-- Thanx to bastya_elvtars for helping me :)
-- version 2.0
-- Changed: Optimized the slot detecting - thanx bastya_elvtars
-- Changed: Made the slot detecting more secure - thanx Optimus
-- Changed: Optimized the slot detecting - thanx PPK

Bot = "#slot-checker"

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

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


bastya_elvtars

IMHO it's useless to do a separate pattern matching on the tag. Preferably there is only 1 S: in the user's myinfo, but for safety, I'd use
strfind(user.sMyInfoString,"<.+S:(%d+).*>")

No offences, just a suggestion.
Everything could have been anything else and it would have just as much meaning.

blackwings

#2
QuoteOriginally posted by bastya_elvtars
IMHO it's useless to do a separate pattern matching on the tag. Preferably there is only 1 S: in the user's myinfo, but for safety, I'd use
strfind(user.sMyInfoString,"<.+S:(%d+).*>")

No offences, just a suggestion.
no offense taken ;)

Done, thanx for the suggestion bastya_elvtars :D

(The script above has been updated)


Optimus

i think this 1 is even better lets say more secure

strfind(user.sMyInfoString,"<.+S:(%d+).*>%$")

blackwings

QuoteOriginally posted by Optimus
i think this 1 is even better lets say more secure

strfind(user.sMyInfoString,"<.+S:(%d+).*>%$")
thank you, I will make the change :)

(The script above has been updated)


PPK

Here is no reason to get slots from myinfo, use PtokaX lua interface  ;)
Quotereturn slotchecking(user, user.iSlots)
and if you want to know if user have tag
Quoteuser.bHasTag
is your friend :))
"Most of you are familiar with the virtues of a programmer. There are three, of course: laziness, impatience, and hubris." - Larry Wall

blackwings

#6
Thank you PPK :D
That does really improve my script :)

(The script above has been updated)


SMF spam blocked by CleanTalk