SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Plugin Development

Reply
 
Thread Tools Display Modes
Old 11/01/2010, 12:45 AM   #1
Y_Less
Beta Tester
 
Y_Less's Avatar
 
Join Date: Jun 2008
Location: 629 - git.io/Y
Posts: 18,151
Reputation: 2540
Default sscanf 2.8.1 - Updated 12/03/13: Now supports npcmodes!

sscanf 2.8.1

Documentation

I have moved all of this documentation to a GitHub wiki:

https://github.com/Y-Less/sscanf/wiki

This keeps it neatly with the code for the (as yet unreleased) version 3.0.

Download

  • Version 2.8.1

Source, Windows .dll, and include:

Mirror from Y_Less

CentOS .so:

Mirror from Mark™
Mirror from h02

Linux .so:

Mirror from h02
Mirror from Mellnik

sscanf2.inc:

Mirror from Pastebin

  • Version 2.8.1 NPC

NPC Plugin

  • Version 3.0 beta

Source:

GitHub
.zip
.tar.gz

Last edited by Y_Less; 13/05/2014 at 09:21 AM.
Y_Less is offline   Reply With Quote
Old 11/01/2010, 12:49 AM   #2
pliva_sb
Big Clucker
 
pliva_sb's Avatar
 
Join Date: Mar 2009
Location: Croatia
Posts: 127
Reputation: 1
Default Re: [REL] sscanf 2.0

Again Nice work Y_less,Well done.
pliva_sb is offline   Reply With Quote
Old 11/01/2010, 01:02 AM   #3
Zeex
Guest
 
Posts: n/a
Default Re: [REL] sscanf 2.0

Wow!

----

I have some questions... What is the defference between boolean and usual integer?
Also what is "l" for? It can perceive values like "yes/no", "true/false", "on/off", etc? Or it is something other?


----

Oh I found what you wrote about boolean above (but I still have no clue about the second thing...)

----

Oh god I really should read better

----

Hm, won't this name (the same as the scripted one has) cause a confusion?
  Reply With Quote
Old 11/01/2010, 03:06 AM   #4
Kalcor
SA-MP Developer
 
Join Date: Apr 2005
Posts: 619
Reputation: 1905
Default Re: [REL] sscanf 2.0

Nice work.

I agree with the above poster though. This function should not be called sscanf because its format syntax doesn't conform to the C standards like printf() and format() do.
Kalcor is offline   Reply With Quote
Old 11/01/2010, 03:31 AM   #5
Kyosaur
High-roller
 
Kyosaur's Avatar
 
Join Date: Mar 2008
Location: USA - California
Posts: 1,057
Reputation: 304
Default Re: [REL] sscanf 2.0

Amazing work! arrays/enums *drool*
__________________
[Tutorial]: Plugin development guide.
[Tutorial]: An indepth look at binary.


Follow me on twitter for updates on all my projects.
Kyosaur is offline   Reply With Quote
Old 11/01/2010, 04:14 AM   #6
Zamaroht
High-roller
 
Zamaroht's Avatar
 
Join Date: Jan 2007
Location: Argentina
Posts: 1,208
Reputation: 46
Default Re: [REL] sscanf 2.0

Amazing work Y_Less.

Regarding that last example that you posted, you wrote a 'j' as the 14th character, and you aren't explaining what it is, so I'll just remove it and give it a try :P:

pawn Code:
#define LEN 10

enum E_DATA
{
  E_NUMBER,
  E_USER,
  E_NUMBER2,
  E_STRING[LEN],
  Float:E_FLOATIEEE
}

new EnumVar[E_DATA],
  Array[11];

sscanf("hi 1 2.0 34 Zamarohtl29lwordlINFINITY 0xAC", "{S(\"f<5>\")if}E<np<l>{u}ns[" #LEN "]g>(0777, 5, 0xF2, hi\\, there, NAN_E)A<n>(0b1010, 012, 10, 0xA)[11]", EnumVar, Array);

printf("%d, %d, %d, %s, %f", EnumVar[E_NUMBER], EnumVar[E_USER], EnumVar[E_NUMBER2], EnumVar[E_STRING], EnumVar[E_FLOATIEEE]);

for (new i, j = sizeof(Array); i < j; i ++)
{
  printf("%d", Array[i]);
}

My output would be:

pawn Code:
34, 0, 29, wordere, 0x7F800000
2832
12
10
10
10
10
10
10
10
10
10

Suppusing that the user named Zamaroht was id 0, right?
Zamaroht is offline   Reply With Quote
Old 11/01/2010, 06:55 AM   #7
Sergei
High-roller
 
Sergei's Avatar
 
Join Date: Mar 2008
Location: Slovenia
Posts: 2,704
Reputation: 133
Default Re: [REL] sscanf 2.0

Awesome. I saw post about it on Twitter about it and now it's finally here
Sergei is offline   Reply With Quote
Old 11/01/2010, 07:00 AM   #8
Correlli
Godfather
 
Correlli's Avatar
 
Join Date: May 2009
Posts: 7,035
Reputation: 103
Default Re: [REL] sscanf 2.0

Awesome work Y_Less.
Correlli is offline   Reply With Quote
Old 15/11/2010, 07:13 PM   #9
HfV.pT
Big Clucker
 
Join Date: Oct 2010
Posts: 59
Reputation: 0
Default Re: [REL] sscanf 2.0

Good work!
HfV.pT is offline   Reply With Quote
Old 11/01/2010, 08:27 AM   #10
Y_Less
Beta Tester
 
Y_Less's Avatar
 
Join Date: Jun 2008
Location: 629 - git.io/Y
Posts: 18,151
Reputation: 2540
Default Re: [REL] sscanf 2.0

Quote:
Originally Posted by Kye
Nice work.

I agree with the above poster though. This function should not be called sscanf because its format syntax doesn't conform to the C standards like printf() and format() do.
Wow, thanks. And possibly not, but it's fairly easy to change the name, I guess you could just do:

pawn Code:
native unformat(const sting[], const pattern[], {Float,_}:...) = sscanf;

I may include that later and deprecate the old name.

Quote:
Originally Posted by Zamaroht
Suppusing that the user named Zamaroht was id 0, right?
If you ran the code, then I think you've found a small bug, if not then you were so nearly right - "012" is an octal number and it's value is also 10 (hence the leading 0), 0xAC is only 172, not 2832 and although I mentioned that "INFINITY 0xAC" is valid even after you change the string delimiter, I should just mention again that delimters introduced within enums still apply afterwards.

Also, minor side note:

pawn Code:
for (new i, j = sizeof(Array); i < j; i ++)
{
  printf("%d", Array[i]);
}

sizeof is an operator, not a function, so is evaluated at compile time, meaning you code is actually SLOWER than doing:

pawn Code:
for (new i; i < sizeof(Array); i ++)
{
  printf("%d", Array[i]);
}

Soryy if that was just a quick example, but I don't think many people realise that - your code was good had sizeof been a regular function.

Quote:
Originally Posted by Seif_
Great job. How much faster is it from the old sscanf?
It's very hard to tell given that there are so many possible execution paths. I did some tests and I think it came out over 10 times faster, but I would have to check again.

Quote:
Originally Posted by ZeeX
Hm, won't this name (the same as the scripted one has) cause a confusion?
The idea was that it would be a direct replacement, but again you can use the code I posted above to rename it (or just a regular define, but those are less compiler checkable). As for the documentation, I wouldn't be surprised if I needed to update it quite a lot.
Y_Less is offline   Reply With Quote
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macros (?) for enums/arrays MP2 Scripting Help 16 17/01/2012 08:37 PM
Enums - string arrays SuperViper Scripting Help 3 31/10/2011 11:00 AM
Arrays and enums... [MWR]Blood Scripting Help 9 23/09/2011 11:29 AM
Enums and Arrays Th3Angel Help Archive 6 15/02/2011 12:46 AM


All times are GMT. The time now is 07:07 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.