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,286
Reputation: 57
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
pawn 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;
}
__________________
Filterscripts
Sgt's Driving License - Sgt's Debug - Sgt's RCON Addition - IpCheck - Advertisement
Includes
Sgt's Vehicle Functions
Functions
IsFloat


Searching for a Partner/Admin/Mapper for an aviation server! Send me a PM if you are interested!
Sascha is offline   Reply With Quote