[Include] g_utilities - New functions for your server
#1

Basically, this is an include that add many functions, im going to explain all the functions.

pawn Код:
GetName(playerid);
This function get the name of a player without make a var


pawn Код:
GetPlayerID(const nombre[]);
For those people that not use strtok or sccanf, this is going to add the name like parameter (To combine with IsNumeric)


pawn Код:
GetNearestCar(playerid);
This function get the ID of the nearest vehicle


pawn Код:
GetDistanceBetweenTwoPlayers(player1, player2, &Float:x, &Float:y, &Float:z);
This function get the distance between 2 players and save it in floats.


pawn Код:
SendErrorMessage(playerid, message[]);
This function is the same that SendClientMessage but add '[Error]' before the text


pawn Код:
ExplodeAll(type, Float:radio);
This function explode all players in a radius


pawn Код:
RemovePlayerHealth(playerid, Float:resta);
This function discount health of a player, if a player have 100 and you discount 30, they will have 70.


pawn Код:
RemovePlayerArmour(playerid, Float:resta);
This function discount armour of a player, if a player have 100 and you discount 30, they will have 70.


pawn Код:
AddPlayerHealth(playerid, Float:suma);
This function add health for a player, if a player have 60 and you add 20 they will have 80


pawn Код:
AddPlayerArmour(playerid, Float:suma);
This function add armour for a player, if a player have 60 and you add 20 they will have 80


pawn Код:
GetPlayerxPos(playerid);
Get the X position of a player


pawn Код:
GetPlayeryPos(playerid);
Get the Y position of a player


pawn Код:
GetPlayerzPos(playerid);
Get the Z position of a player


pawn Код:
SendClientFormattedMessage(playerid, color, const msg[]);
This function is the plus of format + SendClientMessage
Example:
pawn Код:
SendClientFormattedMessage(playerid, 0xFF0000FF, "Your name is %s", GetName(playerid));


pawn Код:
SendClientFormattedMessageToAll(color, const msg[])
The same but to all the server



Note: If you look at the script, you probably find functions that aren't in the list, this is because some functions aren't complete, im going to release another version with more functions.

Thank you for reading, regards, Goncho28 from the Spanish section.

Reply
#2

For anyone using this, DONT use the GetPlayer[xyz]Pos(playerid) functions. They are nothing compared to a single GetPlayerPos. They would take up more than three times the speed of a regular GetPlayerPos.
Reply
#3

In fact, It's better that nobody use this, useless functions that doesn't make sense.

If you want a real SendClientFormattedText, here's one possibly from ****** or/and Zeex:

Код:
#define BYTES_PER_CELL 				4

stock SendClientMessageFormatted(playerid, color, fstring[], {Float, _}:...)
{
    static const STATIC_ARGS = 3;
    new n = (numargs() - STATIC_ARGS) * BYTES_PER_CELL;
    if(n)
    {
        new message[144],arg_start,arg_end;
        #emit CONST.alt        fstring
        #emit LCTRL          5
        #emit ADD
        #emit STOR.S.pri        arg_start

        #emit LOAD.S.alt        n
        #emit ADD
        #emit STOR.S.pri        arg_end
        do
        {
            #emit LOAD.I
            #emit PUSH.pri
            arg_end -= BYTES_PER_CELL;
            #emit LOAD.S.pri      arg_end
        }
        while(arg_end > arg_start);

        #emit PUSH.S          fstring
        #emit PUSH.C          144
        #emit PUSH.ADR         message

        n += BYTES_PER_CELL * 3;
        #emit PUSH.S          n
        #emit SYSREQ.C         format

        n += BYTES_PER_CELL;
        #emit LCTRL          4
        #emit LOAD.S.alt        n
        #emit ADD
        #emit SCTRL          4

        if(playerid == INVALID_PLAYER_ID)
        {
            #pragma unused playerid
            return SendClientMessageToAll(color, message);
        } else {
            return SendClientMessage(playerid, color, message);
        }
    } else {
        if(playerid == INVALID_PLAYER_ID)
        {
            #pragma unused playerid
            return SendClientMessageToAll(color, fstring);
        } else {
            return SendClientMessage(playerid, color, fstring);
        }
    }
}
Just saying that because that's the only function listed here that actually make sense.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)