PtokaX forum

Archive => Archived 5.0 boards => Finished Scripts => Topic started by: blackwings on 02 March, 2005, 22:56:33

Title: Simple slot check script (LUA 5)
Post by: blackwings on 02 March, 2005, 22:56:33
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
Title:
Post by: bastya_elvtars on 02 March, 2005, 23:00:24
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.
Title:
Post by: blackwings on 02 March, 2005, 23:05:00
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)
Title:
Post by: Optimus on 03 March, 2005, 00:26:47
i think this 1 is even better lets say more secure

strfind(user.sMyInfoString,"<.+S:(%d+).*>%$")
Title:
Post by: blackwings on 03 March, 2005, 01:44:21
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)
Title:
Post by: PPK on 03 March, 2005, 04:43:25
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 :))
Title:
Post by: blackwings on 03 March, 2005, 05:47:58
Thank you PPK :D
That does really improve my script :)

(The script above has been updated)