Skip to content

Latest commit

 

History

History
93 lines (74 loc) · 2.99 KB

File metadata and controls

93 lines (74 loc) · 2.99 KB

d_fmargs.inc

Pawn FuncArgs - Using d_fmargs you can easily use specifiers in string-like type arguments of various SA:MP functions.

Go back to home page...

How to start to use?

  • 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.

API

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.

sscanf

  • This include also provides a Pawn implementation of sscanf functions. 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 sscanf features using:
#define DETUTILS_NO_SSCANF

Argument explanation:

sscanf do(source, address, args = 1);
  • source is a source string to get data from.
  • address is an 2D array to assign data to.
  • args is a count of given arguments in a string.

DETUTILS_FMARGS_FUNCREPLACE

  • 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_FUNCREPLACE is enabled using:
#define DETUTILS_FMARGS_FUNCREPLACE
  • In case you don't want it, you can still use d_fmargs by adding fmargs_ prefix before using the function:
fmargs_SendClientMessage(playerid, -1, "Format %i!", somearg);
  • Meanwhile, the standard SendClientMessage will work just fine without any changes.

Note

  • You'll still be able to use fmargs-prefixed functions even with DETUTILS_FMARGS_FUNCREPLACE enabled.