• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Function ifNumber(string)

There is already this function in TFS global.lua. ;)
Code:
function isNumber(p)
	local m = ""
	for i = 1, string.len(p) do
		m = string.sub(p, i, i)
		if m == "0" or m == "1" or m == "2" or m == "3" or m == "4" or m == "5" or m == "6" or m == "7" or m == "8" or m == "9" then
			-- continue
		else
			return FALSE
		end
	end
	return TRUE
end
 
ROFL @ TFS scripters!
PHP:
function isNumber(str) 
    return tonumber(str) and TRUE or FALSE
end

Or:
PHP:
function isNumber(str, bool)
	if bool == true then
		return type(str) == "number" and TRUE or FALSE
	end
	return tonumber(str) and TRUE or FALSE
end
If you use bool that's true value, then it must be the type number not string :p so it cannot be
str = "23423"
but:
str = 23423 :D :D

Try that one ;)


With your function these would give bugs:
isNumber(function() end)
isNumber(nil)
isNumber({})

It will give you an error message, but not on mine ;)
 
Last edited:
Back
Top