[Include] H_Format - Format option in functions
#1

H_Format
H_Format is a simple include that makes your coding simpler and faster.
H_Format changes this functions
  • SendClientMessage(playerid, color, text[])
  • SendClientMessageToAll(color, text[])
  • SetGameModeText(text[])
  • UpdatePlayer3DTextLabelText(playerid, 3dTextLabel, color, text[])
  • Update3DTextLabelText(3dTextLabel, color, text[])
  • TextDrawSetString(textdraw, text[])
  • SetPVarString(playerid,"varname",text[])
into format-functions.
So the formate options are pre-implemented and you dont need to use format(...).
You know it from functions like printf(...)

Functions:
  • SendClientMessagef
    pawn Код:
    SendClientMessagef(playerid, color, format, { Float , _ } : ... );
  • SendClientMessageToAllf
    pawn Код:
    SendClientMessageToAllf(color, format, { Float , _ } : ... );
  • SetGameModeTextf
    pawn Код:
    SetGameModeTextf(format, { Float , _ } : ... );
  • UpdatePlayer3DTextLabelTextf
    pawn Код:
    UpdatePlayer3DTextLabelTextf(playerid, 3dTextLabel, color, format, { Float , _ } : ... );
  • Update3DTextLabelTextf
    pawn Код:
    Update3DTextLabelTextf(3dTextLabel, color, format, { Float , _ } : ... );
  • TextDrawSetStringf
    pawn Код:
    TextDrawSetStringf(textdraw, format, { Float , _ } : ... );
  • SetPVarStringf
    pawn Код:
    SetPVarStringf(playerid,"varname", format, { Float , _ } : ... );
Examples:
Welcome message
pawn Код:
public OnPlayerSpawn(playerid)
{
    new Playername[ MAX_PLAYER_NAME ];
    GetPlayerName(playerid, Playername, MAX_PLAYER_NAME);
    SendClientMessagef(playerid,0xFFFFFFFF,"Hello %s!.", Playername);
}
Change gamemode name
pawn Код:
#define VERSION "v.1.0.1.2"

public OnGameModeInit(){
    SetGameModeTextf("XYZ-Reallife %s",VERSION);
}
Message when player connected
pawn Код:
public OnPlayerSpawn(playerid)
{
    new Playername[ MAX_PLAYER_NAME ];
    GetPlayerName(playerid, Playername, MAX_PLAYER_NAME);
    SendClientMessageToAllf(0xFFFFFFFF,"%s logged in.", Playername);
}
Placeholders:
This placeholders are implemented in the h_format include:
  • %s = String
  • %d = Integer
  • %i = Integer
  • %f = Float
Installation:
  1. Move h_format.inc in your include folder
  2. Write #include <h_format.inc> on top of your script under #include <a_samp>
  3. Now youґre ready!
Download:
Reply


Messages In This Thread
H_Format - Format option in functions - by [LoD]Hauke - 01.10.2012, 21:10
Re: H_Format - Format option in functions - by Sniper Kitty - 02.10.2012, 02:44
Re: H_Format - Format option in functions - by Ballu Miaa - 02.10.2012, 15:58
Re: H_Format - Format option in functions - by Roel - 03.10.2012, 18:46
Re: H_Format - Format option in functions - by Sniper Kitty - 03.10.2012, 18:52
Re: H_Format - Format option in functions - by Roel - 03.10.2012, 19:07

Forum Jump:


Users browsing this thread: 1 Guest(s)