Instalar com o sampctl
sampctl package install Y-Less/sscanf
Execute na pasta do seu projeto. O sampctl baixa o pacote e as dependências dele.
Usado por 31 pacotes
- PatrickGTR/gta-open★ 85
- DignitySAMP/SP-RP★ 53
- simonseidel/Map-Editor-V3★ 35
- ZanderOperator/open.RP★ 35
- Southclaws/samp-aviation★ 29
- TommyB123/samp-map-parser★ 26
- MatheusAgL/BrasilNewStart-samp★ 19
- ZantetsukenGT/AttDef★ 16
- PerseweratywneImponderabilia/LangPlus★ 13
- emmett-white/samp-admin-system★ 7
- revolutionmp/revolution★ 7
- hreesang/samp-my-cmd★ 5
- AliLogic/discord-command★ 4
- Mergevos/samp-dev-commands★ 3
- kaizerpwn/skriptanje-sa-kaizerom★ 3
- boxg-lv/mtb3-base★ 2
- ariyapanna/samp-map-editor★ 2
- Quante31/samp-server-mod★ 2
- Gomaink/easygz★ 2
- boxg-lv/mtb3-demo★ 2
- Dsfftre/Desolation-SAMP★ 2
- MaximusR9/Babzy-RP-Server★ 1
- LoneProg/Main-Gamemode★ 1
- rusic42O/xNL-Northern-Lights★ 1
- emmett-white/samp-generationz★ 1
- VIRUXE/samp-scavenge-nostalgia★ 1
- cadhead/samp-rp-gamemode★ 1
- Jedrzej94/POC-Brutally-Wounded-SAMP★ 1
- ChronosXYZ/OpenRP★ 1
- nolict/hatch-openmp★ 1
e mais 1
README.md
sscanf 2.15.1
Introduction
This is the sscanf plugin, which provides the sscanf function to extract basic structured data from strings. This is slightly different to regular expressions, but both have their place. A regular expression gives you total control over the exact structure of data down to the character level; however, extracting structured data like numbers using it is tricky. Conversely this gives slightly higher-level "specifiers" which can easily extract data types, at the expense of fine-grained control. To convert a string in to two numbers would look like:
new num1, num2;
sscanf("45 100", "ii", num1, num2);
ii is the specifier string, which here means "integer integer"; stating that the input string should be two whole numbers in a row (which is - "45 100"). num1 and num2 are the destination variables to store the found numbers in (after conversion from strings). You can check if the conversion failed by looking for a non-naught return value:
new num1, num2;
if (sscanf("hello 100", "ii", num1, num2))
{
printf("The input was not two numbers.");
}
This will fail because "hello" is not a whole number (or indeed any type of number at all). For more information on using the function refer to the tutorials or the reference documentation below:
Contents
- 1 Introduction
- 2 Contents
- 3 Downloads
- 4 Use
- 4.1 Scripting
- 4.2 open.mp
- 4.3 SA:MP Windows
- 4.4 SA:MP Linux
- 4.5 NPC Modes
- 5 Tutorials
- 5.1
/sendcashCommand - 5.2 INI Parser
- 5.3 Error Detection
- 5.4 A Basic Shop
- 5.1
- 6 Specifiers
- 6.1 Strings
- 6.2 Packed Strings
- 6.3 Arrays
- 6.4 Enums
- 6.5 Provided Lengths
- 6.6 Quiet
- 6.7 Searches
- 6.8 Enums
- 6.9 Delimiters
- 6.10 Optional specifiers
- 6.11 Users
- 6.12 Custom (kustom) specifiers
- 6.13 Colours
- 6.14 End Of Input
- 7 Options
- 7.1 OLD_DEFAULT_NAME:
- 7.2 MATCH_NAME_PARTIAL:
- 7.3 CELLMIN_ON_MATCHES:
- 7.4 SSCANF_QUIET:
- 7.5 OLD_DEFAULT_KUSTOM:
- 7.6 SSCANF_ALPHA:
- 7.7 SSCANF_COLOUR_FORMS:
- 7.8 SSCANF_ARGB:
- 7.9 MATCH_NAME_FIRST:
- 7.10 MATCH_NAME_SIMILARITY:
- 7.11 ERROR_CODE_IN_RET:
- 7.12 WARNINGS_AS_ERRORS:
- 7.13 ERROR_CATEGORY_ONLY:
- 8
extract - 9 Similarity
- 10 Error Returns
- 10.1 Additional Codes
- 10.2 Error Categories
- 11 Alternates
- 12 All Specifiers
- 13 Full API
- 13.1
sscanf(const data[], const format[], {Float, _}:...); - 13.2
unformat(const data[], const format[], {Float, _}:...); - 13.3
SSCANF_Option(const name[], value); - 13.4
SSCANF_Option(const name[]); - 13.5
SSCANF_SetOption(const name[], value); - 13.6
SSCANF_GetOption(const name[], value); - 13.7
SSCANF_Version(version[], size = sizeof (version)); - 13.8
SSCANF_Version(); - 13.9
SSCANF_VersionString(version[], size = sizeof (version)); - 13.10
SSCANF_VersionBCD(); - 13.11
SSCANF_Levenshtein(const string1[], const string2[]); - 13.12
Float:SSCANF_TextSimilarity(const string1[], const string2[]); - 13.13
SSCANF_GetClosestString(const input[], const candidates[][], threshold = cellmax, count = sizeof (candidates)); - 13.14
SSCANF_GetClosestValue(const input[], const candidates[][], const results[], fail = cellmin, threshold = cellmax, count = sizeof (candidates), check = sizeof (results)); - 13.15
SSCANF_GetSimilarString(const input[], const candidates[][], Float:threshold = 0.111111, count = sizeof (candidates)); - 13.16
SSCANF_GetSimilarValue(const input[], const candidates[][], const results[], fail = cellmin, Float:threshold = 0.111111, count = sizeof (candidates), check = sizeof (results)); - 13.17
SSCANF_VERSION_STRING - 13.18
SSCANF_VERSION_BCD - 13.19
SSCANF_VERSION - 13.20
SSCANF_NO_K_VEHICLE - 13.21
SSCANF_NO_K_WEAPON - 13.22
SSCANF_NO_NICE_FEATURES - 13.23
SSCANF_GetLastError(); - 13.24
SSCANF_ClearLastError(); - 13.25
sscanf_error:SSCANF_GetErrorCategory(error); - 13.26
SSCANF_GetErrorSpecifier(); - 13.27
SSCANF_Debug();`
- 13.1
- 14 Errors/Warnings
- 14.1 MSVRC100.dll not found
- 14.2 sscanf error: System not initialised
- 14.3 sscanf warning: String buffer overflow.
- 14.4 sscanf warning: Optional types invalid in array specifiers, consider using 'A'.
- 14.5 sscanf warning: Optional types invalid in enum specifiers, consider using 'E'.
- 14.6 sscanf error: Multi-dimensional arrays are not supported.
- 14.7 sscanf error: Search strings are not supported in arrays.
- 14.8 sscanf error: Delimiters are not supported in arrays.
- 14.9 sscanf error: Quiet sections are not supported in arrays.
- 14.10 sscanf error: Unknown format specifier '?'.
- 14.11 sscanf warning: Empty default values.
- 14.12 sscanf warning: Unclosed default value.
- 14.13 sscanf warning: No default value found.
- 14.14 sscanf warning: Unenclosed specifier parameter.
- 14.15 sscanf warning: No specified parameter found.
- 14.16 sscanf warning: Missing string length end.
- 14.17 sscanf warning: Missing length end.
- 14.18 sscanf error: Invalid data length.
- 14.19 sscanf error: Invalid character in data length.
- 14.20 sscanf error: String/array must include a length, please add a destination size.
- 14.21 sscanf warning: Can't have nestled quiet sections.
- 14.22 sscanf warning: Not in a quiet section.
- 14.23 sscanf warning: Can't remove quiet in enum.
- 14.24 sscanf error: Arrays are not supported in enums.
- 14.25 sscanf warning: Unclosed string literal.
- 14.26 sscanf warning: sscanf specifiers do not require '%' before them.
- 14.27 sscanf error: Insufficient default values.
- 14.28 sscanf error: Options are not supported in enums.
- 14.29 sscanf error: Options are not supported in arrays.
- 14.30 sscanf error: No option value.
- 14.31 sscanf error: Unknown option name.
- 14.32 sscanf warning: Could not find function SSCANF:?.
- 14.33 sscanf error: SSCANF_Init has incorrect parameters.
- 14.34 sscanf error: SSCANF_Join has incorrect parameters.
- 14.35 sscanf error: SSCANF_Leave has incorrect parameters.
- 14.36 sscanf error: SSCANF_IsConnected has incorrect parameters.
- 14.37 sscanf error: SSCANF_Version has incorrect parameters.
- 14.38 sscanf error: SSCANF_Option has incorrect parameters.
- 14.39 sscanf error: SetPlayerName has incorrect parameters.
- 14.40 sscanf error: Missing required parameters.
- 14.41
fatal error 111: user error: sscanf already defined, or used before inclusion. - 14.42
error 004: function "sscanf" is not implemented - 14.43
error 004: function "sscanf" is not implemented - include <sscanf2> first. - 14.44 sscanf error: Pawn component not loaded.
- 14.45 sscanf warning: Unknown
player->setName()return. - 14.46 sscanf error: This script was built with the component version of the include.
- 14.47 sscanf error: Unable to allocate memory.
- 14.48 sscanf warning: User arrays are not supported in arrays.
- 14.49 sscanf warning: Invalid values in array defaults.
- 14.50 sscanf warning: Excess array defaults found.
- 14.51 sscanf warning: Format specifier does not match parameter count.
- 14.52 sscanf warning: Unclosed quiet section.
- 14.53 sscanf warning: Include / plugin mismatch, please recompile your script for the latest features.
- 14.54 sscanf warning: A minus minus makes no sense.
- 14.55 sscanf warning: A minus option makes no sense.
- 14.56 sscanf warning: A minus delimiter makes no sense.
- 14.57 sscanf warning: A minus quiet section makes no sense.
- 14.58 sscanf warning: User arrays are not supported in enums.
- 14.59 sscanf error: 'U(name)[len]' is incompatible with OLD_DEFAULT_NAME.
- 14.60 sscanf error: 'U(num)[len]' length under 2.
- 14.61 sscanf error: 'u[len]' length under 2.
- 14.62 sscanf error: 'Q(name)[len]' is incompatible with OLD_DEFAULT_NAME.
- 14.63 sscanf error: 'Q(num)[len]' length under 2.
- 14.64 sscanf error: 'q[len]' length under 2.
- 14.65 sscanf error: 'R(name)[len]' is incompatible with OLD_DEFAULT_NAME.
- 14.66 sscanf error: 'R(num)[len]' length under 2.
- 14.67 sscanf error: 'r[len]' length under 2.
- 14.68 sscanf error: (*) is not supported in strings/arrays yet.
- 14.69 sscanf error: Unclosed specifier parameters.
- 14.70 sscanf error: No specified parameters found.
- 14.71 sscanf error: Enums are not supported in enums.
- 14.72 sscanf error: SSCANF_TextSimilarity has incorrect parameters.
- 14.73 sscanf error: SSCANF_GetErrorCategory has incorrect parameters.
- 14.74 sscanf error: End of text is not supported in arrays.
- 14.75 sscanf error: End of text is not supported in enums.
- 14.76 sscanf warning: A minus end of text makes no sense.
- 14.77 sscanf error: No alternate destination.
- 14 Future Plans
- 14.1 Reserved Specifiers
- 14.2 Validity Ranges
- 14.3 Enums And Arrays
- 14.4 Compilation
- 15 Building
- 15.1 Getting The Code
- 15.2 Building On Windows
- 15.3 Building On Linux
- 15.4 Building With Docker
- 16 License
- 16.1 Version: MPL 1.1
- 16.2 Contributor(s):
- 16.3 Special Thanks to:
- 17 Changelog
- 17.1 sscanf 2.8.2 - 18/04/2015
- 17.2 sscanf 2.8.3 - 02/10/2018
- 17.3 sscanf 2.9.0 - 04/11/2019
- 17.4 sscanf 2.10.0 - 27/06/2020
- 17.5 sscanf 2.10.1 - 27/06/2020
- 17.6 sscanf 2.10.2 - 28/06/2020
- 17.7 sscanf 2.10.3 - 28/04/2021
- 17.8 sscanf 2.10.4 - 17/01/2022
- 17.9 sscanf 2.11.1 - 25/01/2022
- 17.9 sscanf 2.11.2 - 04/02/2022
- 17.10 sscanf 2.11.3 - 05/02/2022
- 17.10 sscanf 2.11.4 - 02/03/2022
- 17.11 sscanf 2.11.5 - 31/03/2022
- 17.12 sscanf 2.12.1 - 05/05/2022
- 17.13 sscanf 2.12.2 - 11/05/2022
- 17.14 sscanf 2.13.1 - 25/06/2022
- 17.15 sscanf 2.13.2 - 07/09/2022
- 17.16 sscanf 2.13.3 - 04/12/2022
- 17.17 sscanf 2.13.4 - 20/12/2022
- 17.18 sscanf 2.13.5 - 28/12/2022
- 17.19 sscanf 2.13.6 - 28/12/2022
- 17.20 sscanf 2.13.7 - 02/01/2023
- 17.21 sscanf 2.13.8 - 05/01/2023
- 17.21 sscanf 2.14.1 - 08/09/2023
- 17.22 sscanf 2.15.1 - 10/09/2023
Downloads
GitHub repo:
https://github.com/Y-Less/sscanf/
Use
Scripting
This behaves exactly as the old sscanf did, just MUCH faster and much more flexibly. To use it add:
#include <sscanf2>
To your modes and remove the old sscanf (the new include will detect the old version and throw an error if it is detected).
The basic code looks like:
if (sscanf(params, "ui", giveplayerid, amount))
{
return SendClientMessage(playerid, 0xFF0000AA, "Usage: /givecash <playerid/name> <amount>");
}
However it should be noted that sscanf can be used for any text processing you like. For example an ini processor could look like (don't worry about what the bits mean at this stage):
if (sscanf(szFileLine, "p<=>s[8]s[32]", szIniName, szIniValue))
{
printf("Invalid INI format line");
}
There is also an alternate function name to avoid confusion with the C standard sscanf:
if (unformat(params, "ui", giveplayerid, amount))
{
return SendClientMessage(playerid, 0xFF0000AA, "Usage: /givecash <playerid/name> <amount>");
}
open.mp
The sscanf binary (sscanf.dll on Windows, or sscanf.so on Linux) works as both a legacy (SA:MP) plugin or an open.mp component. The recommended method is to use it as a component - just place the file in the components directory in the server root and open.mp will load it automatically.
If you wish to use it as a legacy plugin for some reason (there is no need if you are on version 2.12.1 or higher) place it in the plugins directory in the open.mp server root and either follow the SA:MP-specific instructions for server.cfg on your platform or add "sscanf" to "pawn.legacy_plugins" in config.json:
{
"pawn":
{
"legacy_plugins":
[
"sscanf"
]
}
}
SA:MP Windows
Add sscanf to the start of the plugins line in server.cfg. For example:
plugins sscanf streamer crashdetect
If there isn't a plugins line already, add one:
plugins sscanf
You must also place sscanf.dll in the plugins subdirectory of the server. If there isn't a plugins directory, create one.
SA:MP Linux
Add sscanf.so to the start of the plugins line in server.cfg. For example:
Esta página é montada com o que o GitHub publica sobre o repositório. O samp.directory não hospeda o código. Avisar de um problema com esta página