Help me A Redirect For Too open Slot
 

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 me A Redirect For Too open Slot

Started by DorianG, 12 February, 2004, 10:21:46

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

DorianG

I want to do an autoredirect of user that have many slots opened. I have tried to create it but i haven't understood like the redirect works in general :)
Can you help me?
Please, if is possible, write me the shorts examples.

nErBoS

Hi,

Hope it helps...

--Requested by DorianG 
--Made by nErBoS

Bot = "MmSlot-Checker"

minSlot = 3 
maxSlot = 5 
addredirect = "llllaa.mine.nu"

function Main()
SetTimer(3*1000)
frmHub:RegBot(Bot)
end

--This function takes more memory, but searches the user slots when they speak or refresh userlist, in case if you want to remove.
function DataArrival(user, data) --remove from here
		local _,b, slt = strfind(user.sMyInfoString,"S:(%x+)")
		slt = slt*1
		if (slt < minSlot) then
			user:SendPM(Bot, "You must have "..minSlot.." slot open at least.")
			user:SendPM(Bot, "You are been redirected...")
			user:SendData("$ForceMove "..addredirect)
		elseif (slt > maxSlot) then
			user:SendPM(Bot, "You must have "..maxSlot.." slot open in max.")
			user:SendData("$ForceMove "..addredirect)
			user:SendPM(Bot, "You are been redirected...")
		end
end --to here

-- This function only checks when the users connects
function NewUserConnected(user, data)
	if strfind(user.sMyInfoString, "S:%x+") then
		local _,b, slt = strfind(user.sMyInfoString,"S:(%x+)")
		slt = slt*1
		if (slt < minSlot) then
			user:SendPM(Bot, "You must have "..minSlot.." slot open at least.")
			user:SendData("$ForceMove "..addredirect)
			user:SendPM(Bot, "You are been redirected...")
		elseif (slt > maxSlot) then
			user:SendPM(Bot, "You must have "..maxSlot.." slot open in max.")
			user:SendData("$ForceMove "..addredirect)
			user:SendPM(Bot, "You are been redirected...")
		end
	end
end

It's working but you will get this error on the script editor...

Syntax Error: attempt to perform arithmetic on local `slt' (a nil value)

I gone to see what is it.

Best regrads, nErBoS
--## nErBoS Spot ##--

DorianG

I have tried your script.
the script is good. But the problem about "slt" i haven't solved.
But i have replied to thank you :D
If i'll find the error, i post you the solution here ;)

NightLitch

This is how your dataArrival should look like:
function DataArrival(user, data) --remove from here
	if (strsub(data,1,7) == "$MyINFO") then
		local _,b, slt = strfind(data,"S:(%x+)")
		if (slt == nil) then
			user:SendPM(Bot, "You are hiding your tag for checking slots.")
			user:SendPM(Bot, "You are Disconnected...")
			user:Disconnect()
		elseif (slt < minSlot) then
			user:SendPM(Bot, "You must have "..minSlot.." slot open at least.")
			user:SendPM(Bot, "You are been redirected...")
			user:SendData("$ForceMove "..addredirect)
		elseif (slt > maxSlot) then
			user:SendPM(Bot, "You must have "..maxSlot.." slot open in max.")
			user:SendData("$ForceMove "..addredirect)
			user:SendPM(Bot, "You are been redirected...")
		end
	end
end --to here

hope you don't minded I posted the hole solusion.
//NL

DorianG

Thanks NightLitch you are very glad.
But Also your script give me an error. So i have made a change and i have add a line, so don't give me problem. :D

function DataArrival(user, data) --remove from here
	if (strsub(data,1,7) == "$MyINFO") then
		local _,b, slt = strfind(data,"S:(%x+)")
		slt = slt*1
		if (slt == nil) then
			user:SendPM(Bot, "You are hiding your tag for checking slots.")
			user:SendPM(Bot, "You are Disconnected...")
			user:Ban()
		elseif (slt < minSlot) then
			user:SendPM(Bot, "You must have "..minSlot.." slot open at least.")
			user:SendPM(Bot, "You are been redirected...")
			user:SendData("$ForceMove "..addredirect)
		elseif (slt > maxSlot) then
			user:SendPM(Bot, "You must have "..maxSlot.." slot open in max.")
			user:SendData("$ForceMove "..addredirect)
			user:SendPM(Bot, "You are been redirected...")
		end
	end
end --to here

DorianG

If you have Ptokax 0.330 you could try this script. :D

function DataArrival(user, data) --remove from here
	if (strsub(data,1,7) == "$MyINFO") then
		local _,b, slt = strfind(data,"S:(%x+)")
		local minSlot = frmHub:GetMinSlots()
		local maxSlot = frmHub:GetMaxSlots()
		slt = slt*1
		if (slt == nil) then
			user:SendPM(Bot, "You are hiding your tag for checking slots.")
			user:SendPM(Bot, "You are Disconnected...")
			user:Ban()
		elseif (slt < minSlot) then
			user:SendPM(Bot, "You must have "..minSlot.." slot open at least.")
			user:SendPM(Bot, "You are been redirected...")
			user:SendData("$ForceMove "..addredirect)
		elseif (slt > maxSlot) then
			user:SendPM(Bot, "You must have "..maxSlot.." slot open in max.")
			user:SendData("$ForceMove "..addredirect)
			user:SendPM(Bot, "You are been redirected...")
		end
	end
end --to here


-- This function only checks when the users connects
function NewUserConnected(user, data)
	if strfind(user.sMyInfoString, "S:(%x+)") then
		local _,b,slt = strfind(user.sMyInfoString,"S:(%x+)")
		local minSlot = frmHub:GetMinSlots()
		local maxSlot = frmHub:GetMaxSlots()
		slt = slt*1
		if (slt < minSlot) then
			user:SendPM(Bot, "You must have "..minSlot.." slot open at least.")
			user:SendData("$ForceMove "..addredirect)
			user:SendPM(Bot, "You are been redirected...")
		elseif (slt > maxSlot) then
			user:SendPM(Bot, "You must have "..maxSlot.." slot open in max.")
			user:SendData("$ForceMove "..addredirect)
			user:SendPM(Bot, "You are been redirected...")
		elseif (slt == nil) then
			user:SendPM(Bot, "You have an invalid Client, please download a legal client.")
			user:Ban()
		end
	end
end

NightLitch

why the:  slt = slt*1

what do you have it for ??

one thing I noticed change:

local _,b, slt = strfind(data,"S:(%x+)")

to

local _,b, slt = strfind(data,"S:(%d+)")

that should solve it.

but my most concern is to:

slt = slt*1

/NL
//NL

DorianG

The motive i dont know. but it, to the beginning gave me an error, I then have added slt = slt*1 :D and the Bot it has not given me more problems. ;)
if i can... Because have you changed
local _,b, slt = strfind(data,"S:(%x+)")

to

local _,b, slt = strfind(data,"S:(%d+)") ????

NightLitch

this is how I would do it, and there should not be any errors here. I changed Ban() to Disconnected()

becouse you don't need to ban ppl for hiding the tag just disconnect with a msg and they can come back with a accepted Tag.

here my code:
function DataArrival(user, data) --remove from here
	if (strsub(data,1,7) == "$MyINFO") then
		local _,b, slt = strfind(data,"S:(%d+)")
		local minSlot = frmHub:GetMinSlots()
		local maxSlot = frmHub:GetMaxSlots()
		if (slt == nil or slt == "") then
			user:SendPM(Bot, "You are hiding your tag for checking slots.")
			user:SendPM(Bot, "You are Disconnected...")
			user:Disconnect()
		elseif (slt < minSlot) then
			user:SendPM(Bot, "You must have "..minSlot.." slot open at least.")
			user:SendPM(Bot, "You are been redirected...")
			user:SendData("$ForceMove "..addredirect)
		elseif (slt > maxSlot) then
			user:SendPM(Bot, "You must have "..maxSlot.." slot open in max.")
			user:SendData("$ForceMove "..addredirect)
			user:SendPM(Bot, "You are been redirected...")
		end
	end
end --to here


-- This function only checks when the users connects
function NewUserConnected(user, data)
	local _,b,slt = strfind(user.sMyInfoString,"S:(%d+)")
	local minSlot = frmHub:GetMinSlots()
	local maxSlot = frmHub:GetMaxSlots()
	if (slt == nil or slt == "") then
		user:SendPM(Bot, "You are hiding your tag for checking slots.")
		user:SendPM(Bot, "You are Disconnected...")
		user:Disconnect()
	elseif (slt < minSlot) then
		user:SendPM(Bot, "You must have "..minSlot.." slot open at least.")
		user:SendData("$ForceMove "..addredirect)
		user:SendPM(Bot, "You are been redirected...")
	elseif (slt > maxSlot) then
		user:SendPM(Bot, "You must have "..maxSlot.." slot open in max.")
		user:SendData("$ForceMove "..addredirect)
		user:SendPM(Bot, "You are been redirected...")
	end
end

/NL
//NL

nErBoS

#9
Like litch said, and well said, where you have...

local _,b, slt = strfind(user.sMyInfoString,"S:(%x+)")
put this..
local _,b, slt = strfind(user.sMyInfoString,"S:(%d)")

And where you have this...

slt = slt*1

put this..

slt = tonumber(slt)

Thanks for the correction litch :)

About error is being discusted in the developing scripts to see why does it sends that error, but the script works.

Best regrads, nErBoS
--## nErBoS Spot ##--

DorianG

Yes I like :D, it has stayed indeed interesting the development :)
However I still have not understood how come you have put this:
local _,b, slt = strfind(user.sMyInfoString,"S:(%d)")
instead of
local _,b, slt = strfind(user.sMyInfoString,"S:(%x+)")

I thank you for the consideration :D

nErBoS

#11
Hi,

Well like the good manual says :)  ...

%x
- represents all hexadecimal digits.

%d
- represents all digits.


for more information use this link..

http://www.lua.org/manual/4.0/manual.html#pm

Best regards, nErBoS
--## nErBoS Spot ##--

NightLitch

well you simply just need to catch the nil value:

value == nil then
do code here

Why this occur is becouse a user logs in without having a tag or hiding it, thats when the nil error comes up for you. Hope this helped or if you have come to that solusion yourself.

Best regards /NL
//NL

nErBoS

Once more thanks for the explanion NightLitch

Best regrads, nErBoS
--## nErBoS Spot ##--

DorianG

thank you. Good explanation.
Brief but precise :D

SMF spam blocked by CleanTalk