Raised This Month: $ Target: $400
 0% 

check if number is float


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
IAmReallyCool
Member
Join Date: Nov 2013
Old 08-14-2014 , 03:32   Re: check if number is float
Reply With Quote #1

I have got admin cmd to give player invisibility for seconds..

Seconds are defined like this (not float)

new secs

I am aware that admins can type something like this

give_invis STEAM_HERE 1.4

I want to allow only round numbers...
IAmReallyCool is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 08-14-2014 , 04:25   Re: check if number is float
Reply With Quote #2

Well, since the args from the commands are strings, you can use is_str_float(szArg) to detect if the typed value from the command is float.
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 08-14-2014 , 05:33   Re: check if number is float
Reply With Quote #3

Did you read the thread?
Backstabnoob is offline
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 08-14-2014 , 05:56   Re: check if number is float
Reply With Quote #4

Shouldn't str_to_num be enough?
__________________
Jhob94 is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 08-14-2014 , 05:58   Re: check if number is float
Reply With Quote #5

But he wants to check if the string is float, right? So a stock was provided and I guess there is no problem.for him to use it to check if the string is float. Or I'm wrong somewhere?
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 08-14-2014 , 06:02   Re: check if number is float
Reply With Quote #6

Quote:
Originally Posted by Flick3rR View Post
But he wants to check if the string is float, right? So a stock was provided and I guess there is no problem.for him to use it to check if the string is float. Or I'm wrong somewhere?
He doesn't really needs to check it out.
If i am not wrong, he just needs to read args, do str_to_num, check if it's a positive num and keep the function.
__________________
Jhob94 is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 08-14-2014 , 06:04   Re: check if number is float
Reply With Quote #7

It really depends if he actually wants to detect float value or just make everything an integer.
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 08-14-2014 , 06:07   Re: check if number is float
Reply With Quote #8

Quote:
Originally Posted by Flick3rR View Post
It really depends if he actually wants to detect float value or just make everything an integer.
Why would he? As far as it seems, he just thought people would be able to use floats. Since he can do this, i think he won't really want to check if it's a float.
__________________
Jhob94 is offline
IAmReallyCool
Member
Join Date: Nov 2013
Old 08-14-2014 , 08:45   Re: check if number is float
Reply With Quote #9

All i want is to disable possibility to input float number as an argument in admin cmd..

E.g.

if (argument2 is float)
Only int values are allowed..

Last edited by IAmReallyCool; 08-14-2014 at 08:46.
IAmReallyCool is offline
Nextra
Veteran Member
Join Date: Apr 2008
Location: Germany
Old 08-14-2014 , 09:21   Re: check if number is float
Reply With Quote #10

So you want to verify that something is not a float, and what you actually want to achieve is simply check if a string is an integer. That can be easily done by checking !is_str_num(string) as it will not return true if the string contains a dot. Be precise in your OP and you would have had your answer immediately.
__________________
In Flames we trust!

Last edited by Nextra; 08-14-2014 at 09:22.
Nextra is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 13:14.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode