View Single Post
Old 10/08/2011, 08:53 PM   #2308
Sascha
High-roller
 
Sascha's Avatar
 
Join Date: Jul 2009
Location: Germany
Posts: 1,388
Reputation: 64
Default Re: Useful Functions

hm here is a IsFloat function I just created..
no clue if someone already posted one here, however here it is
as far as I've tested it it works good
Code:
stock IsFloat(buf[])
{
	new l = strlen(buf);
	new dcount = 0;
	for(new i=0; i<l; i++)
	{
	    if(buf[i] == '.')
	    {
	        if(i == 0 || i == l-1) return 0;
	        else
	        {
	            dcount++;
			}
		}
	    if((buf[i] > '9' || buf[i] < '0') && buf[i] != '+' && buf[i] != '-' && buf[i] != '.') return 0;
	    if(buf[i] == '+' || buf[i] == '-')
	    {
			if(i != 0 || l == 1) return 0;
		}
	}
	if(dcount == 0 || dcount > 1) return 0;
	return 1;
}
__________________
FilterscriptsSgt's Driving License - Sgt's Debug - Sgt's RCON Addition - IpCheck - Advertisement
IncludesSgt's Vehicle Functions
FunctionsIsFloat
Searching for a team for a new server (Mapper/Admins/etc.).the website.
IP: 5.1.85.106

Sascha is offline   Reply With Quote