Raised This Month: $404 Target: $400
 101% 

Variable format specifier


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
shavit
AlliedModders Donor
Join Date: Dec 2011
Location: Israel
Old 10-10-2018 , 11:31   Variable format specifier
Reply With Quote #1

How could I get a format specifier to be different according to runtime variables?
My use case is showing a different time precision according to the server's tick interval (%.02f or %.03f) without having code duplication for the Format/FormatEx calls
__________________
My Plugins
Not taking private requests, too busy.
shavit is offline
ofir753
Senior Member
Join Date: Aug 2012
Old 10-10-2018 , 13:36   Re: Variable format specifier
Reply With Quote #2

As far as I know format are not recursive, at least not in c.
ofir753 is offline
shavit
AlliedModders Donor
Join Date: Dec 2011
Location: Israel
Old 10-10-2018 , 13:48   Re: Variable format specifier
Reply With Quote #3

Quote:
Originally Posted by ofir753 View Post
As far as I know format are not recursive, at least not in c.
nah in c you can
Code:
%.*f
and specify the number as an argument

how's army? :^)
__________________
My Plugins
Not taking private requests, too busy.

Last edited by shavit; 10-10-2018 at 13:51.
shavit is offline
ofir753
Senior Member
Join Date: Aug 2012
Old 10-10-2018 , 14:31   Re: Variable format specifier
Reply With Quote #4

Quote:
Originally Posted by shavit View Post
nah in c you can
Code:
%.*f
and specify the number as an argument
lol I had no idea about that, anyway I though sourcemod using c to format, they don't .
I looked at the sm format function, I didn't find the feature you mentioned, anyway this is the case when the function take care for "%.2f".
https://github.com/alliedmodders/sou...intf.cpp#L1076

Quote:
Originally Posted by shavit View Post
how's army? :^)
It's fine
ofir753 is offline
Reply


Thread Tools
Display Modes

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 14:56.


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