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.
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
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 ;)
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.
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
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
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
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+)") ????
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
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
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
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
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
Once more thanks for the explanion NightLitch
Best regrads, nErBoS
thank you. Good explanation.
Brief but precise :D