|
|
#1 | ||||||||||||||||||
|
High-roller
![]() ![]() ![]() ![]() ![]() Join Date: Mar 2008
Location: Sweden
Posts: 1,670
Reputation: 969
|
Hey,
After seeing a great new feature in sscanf that allows you to create custom specifiers, I figured it was only right to do the same to format and printf! For example, the following code could be made a lot shorter: pawn Code:
This will do the same thing: Code:
new msg[128]; format(msg, _, "You were given %w by %P", weapon, playerid); // msg is for example: You were given an M4 by Slice
You can create your own specifiers! You can do this very easily; example of one that puts an upper-case string at %S: Add this anywhere outside of a function: pawn Code:
You can now do this: pawn Code:
If you want an integer, float, or anything else instead of a string you just change it: pawn Code:
Additional notes Worth mentioning is this is a superset of format, meaning it has exactly all the features of format and those behave like always (the only exception is it's a bit friendlier to packed strings, though %s still doesn't support it). It actually uses the original native "format" function to do the heavy lifting. Download Download: http://pastebin.com/xMAMtB6M Last edited by Slice; 26/01/2012 at 01:56 PM. |
||||||||||||||||||
|
|
|
|
|
#2 |
|
High-roller
![]() ![]() ![]() ![]() ![]() Join Date: Jun 2010
Location: Sofia, Bulgaria
Posts: 1,226
Reputation: 437
|
Kewl, I actually need this.
|
|
|
|
|
|
#3 |
|
Big Clucker
![]() ![]() Join Date: Dec 2009
Posts: 188
Reputation: 50
|
very nice, i gonna use it for sure
![]() edit: Why you use "GetMaxPlayers" instead of "MAX_PLAYERS" ?? |
|
|
|
|
|
#4 |
|
High-roller
![]() ![]() ![]() ![]() ![]() Join Date: Jan 2012
Location: New Delhi, India
Posts: 1,146
Reputation: 345
|
Great.Really Great.Don't know what to say anymore.....
|
|
|
|
|
|
#5 |
|
High-roller
![]() ![]() ![]() ![]() ![]() Join Date: Mar 2008
Location: Sweden
Posts: 1,670
Reputation: 969
|
|
|
|
|
|
|
#6 |
|
High-roller
![]() ![]() ![]() ![]() ![]() Join Date: Mar 2011
Location: Al Ain, UAE. Homeland: Bangladesh.
Posts: 1,299
Reputation: 673
|
There you go, another awesome release. I'm obviously gonna use it.
|
|
|
|
|
|
#7 |
|
Gangsta
![]() ![]() ![]() ![]() Join Date: Mar 2011
Location: Croatia
Posts: 721
Reputation: 146
|
Nice one, Slice!
![]() rep+ |
|
|
|
|
|
#8 |
|
Guest
Posts: n/a
|
Yet another useful release. Nice work Slice(The next Y_Less).
|
|
|
|
#9 |
|
Banned
![]() Join Date: May 2011
Location: Internet
Posts: 2,127
Reputation: 205
|
awesome,thanks
|
|
|
|
|
|
#10 |
|
Gangsta
![]() ![]() ![]() ![]() Join Date: May 2011
Location: Zadar, Croatia
Posts: 990
Reputation: 130
|
fucking awesome man
![]() rep+ edit: shit I can't give rep
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| xMovie Entertainment (3 vids): "Like a boss" "The rapist" "Jizz in my pants" | xMovie | Screenshots and Videos | 11 | 27/03/2012 12:10 PM |
| "Warning 209: function "CreateDynamicVehicle" should return a value." | rati555 | Scripting Help | 2 | 06/11/2011 06:18 PM |
| "Warning 209: function "cmd_enter" should return a value." Urgent help needed! | pEar | Scripting Help | 3 | 10/09/2011 05:55 PM |
| Little "format" and "dini" help | blackwave | Help Archive | 3 | 28/12/2010 11:28 AM |
| "Run time error 19: "File or function is not found" | TouR | Help Archive | 2 | 18/06/2010 10:04 AM |