PtokaX forum

Development Section => Your Developing Problems => Topic started by: nErBoS on 12 February, 2004, 11:58:15

Title: Why ???
Post by: nErBoS on 12 February, 2004, 11:58:15
Hi all,

in this script...

--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

Is working but i am getting this erro on the editor..

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

can anyone explained me why ??

Best regards, nErBoS
Title:
Post by: VidFamne on 12 February, 2004, 12:23:26
Try to use " %d* " instead of " %x+ " in strfind.
%x  -  is all hexadecimal digits

And for the safety;
slt = tonumber(slt)
Title:
Post by: nErBoS on 12 February, 2004, 12:49:07
Thanks for the explanition VidFamne.

Still having error...

Syntax Error: attempt to compare nil with number
Title:
Post by: kepp on 12 February, 2004, 16:25:35
yes, im getting that too and i would really like to know Why?

Is it that user's slot is == 0 and therefore nil?
(But that seems strange) or that it can't find the tag?
Title:
Post by: nErBoS on 13 February, 2004, 02:29:34
This error will appear even if you have 3 slots, but the script does their jobs but i dont understand way he sends this error.

Lets hope some big Scripter can explain :)

Best regards, nErBoS