Pawn FuncArgs - Using d_fmargs you can easily use specifiers in string-like type arguments of various SA:MP functions.
- Usage is really basic.
Example:
public OnPlayerSpawn(playerid)
{
SendClientMessage(playerid, -1, "You are spawned, %s.", ReturnPlayerName(playerid));
return 1;
}TIP: Function ReturnPlayerName is provided by extra library include d_libtags.inc.
Functions whose will work like this after including detutils are:
| SA:MP functions | Description |
|---|---|
| SendClientMessage | Sends a message to certain client. |
| SendClientMessageToAll | Sends a message to all players (clients). |
| GameTextForPlayer | Shows a GameText to certain player. |
| GameTextForAll | Shows a GameText to all players. |
| TextDrawCreate | Creates a global TextDraw. |
| CreatePlayerTextDraw | Creates a player TextDraw. |
| TextDrawSetString | Changes global TextDraw's string. |
| PlayerTextDrawSetString | Changes player TextDraw's string. |
| SendRconCommand | Sends a RCON command to a server. |
| Update3DTextLabelText | Updates the 3D text label text. |
| UpdatePlayer3DTextLabelText | Updates the player 3D text label text. |
- This include also provides a Pawn implementation of
sscanffunctions. Below, you can see an example on how to use these features:
@command(.type = SLASH_COMMAND) sscanftest(playerid, params[])
{
new id, array[2][3];
if(sscanf do(params, array, 2) == SSCANF_FAIL) // If sscanf fails (no spaces in a string)
{
return SendClientMessage(playerid, -1, "Sscanf failed.");
}
SendClientMessage(playerid, -1, "Sscanf succedeed.");
return 1;
}- You can disable these optional
sscanffeatures using:
#define DETUTILS_NO_SSCANFArgument explanation:
sscanf do(source, address, args = 1);sourceis a source string to get data from.addressis an 2D array to assign data to.argsis a count of given arguments in a string.
- This is a compile-time option which tells DETUtils to hook the fmargs functions or not. This is really important to note because it limits the function input only to one line, which means this is impossible to do:
SendClientMessage(
playerid,
-1,
"Message.")
;DETUTILS_FMARGS_FUNCREPLACEis enabled using:
#define DETUTILS_FMARGS_FUNCREPLACE- In case you don't want it, you can still use
d_fmargsby addingfmargs_prefix before using the function:
fmargs_SendClientMessage(playerid, -1, "Format %i!", somearg);- Meanwhile, the standard
SendClientMessagewill work just fine without any changes.
- You'll still be able to use
fmargs-prefixed functions even withDETUTILS_FMARGS_FUNCREPLACEenabled.