SSGamers - 12 Anos online por você.

#SSGamers - A Comunidade que mais crescer no brasil!

Participe do fórum, é rápido e fácil

SSGamers - 12 Anos online por você.

#SSGamers - A Comunidade que mais crescer no brasil!

SSGamers - 12 Anos online por você.

Gostaria de reagir a esta mensagem? Crie uma conta em poucos cliques ou inicie sessão para continuar.
Chegou o novo tema 6.5.5 - SSGamers - Servidores online de qualidade - Aproveite e entre para nossa comunidade, inscreva-se já! - Ouça nossa web radio - Veja nossas novidades - Participe dos nossos setores de jogos online - Parcerias aberta fale já com um administrador.

    [Codigo util]format

    Weslley_Script
    Weslley_Script
    SS - Fundador
    SS - Fundador


    Steam Steam : WeslleySSGames
    Zello : WeslleySSGames
    Mensagens : 11378
    Moedas : 1031978
    Data de inscrição : 06/10/2011
    Idade : 28
    Localização : Brasil

    [Codigo util]format Empty [Codigo util]format

    Mensagem por Weslley_Script Sex 24 Mar 2023 - 19:28

    Description:
    Formats a string to include variables and other strings inside it.


    Parameters:
    (output[], len, const format[], {Float,_}:...)
    output[] The string to output the result to
    len The maximum length output can contain
    format[] The format string
    {Float,_}:... Indefinite number of arguments of any tag

    Return Values:
    This function does not return any specific values.

    Format Specifiers
    Specifier Meaning
    %i Integer (whole number)
    %d Integer (whole number).
    %s String
    %f Floating-point number (Float: tag)
    %c ASCII character
    %x Hexadecimal number
    %b Binary number
    %% Literal '%'
    %q Escape a text for SQLite. (Added in 0.3.7 R2)
    The values for the placeholders follow in the exact same order as parameters in the call. For example, "I am %i years old" - the %i will be replaced with an Integer variable, which is the person's age.

    You may optionally put a number between the '%' and the letter of the placeholder code. This number indicates the field width; if the size of the parameter to print at the position of the placeholder is smaller than the field width, the field is expanded with spaces. To cut the number of decimal places beeing shown of a float, you can add '.' between the '%' and the 'f'. (example: %.2f)

    See this post to see how you can specify a variable width or precision by using an asterisk.

    Example Usage:

    Código:
    new result[128];
    new number = 42;
    format(result,sizeof(result), "The number is %i.",number);  //-> The number is 42.
    new string[]= "simple message";
    format(result,sizeof(result), "This is a %s containing the number %i.", string, number);
    // This is a simple message containing the number 42.
    Código:
    new string[64];
    format(string,sizeof(string),"Your score is: %d",GetPlayerScore(playerid));
    SendClientMessage(playerid,0xFFFFFFAA,string);
    Código:
    new hour, minute, second, string[32];
    gettime(hour, minute, second);
     
    format(string, sizeof(string), "The time is %02d:%02d:%02d.", hour, minute, second); // will output something like 09:45:02
    SendClientMessage(playerid, -1, string);

    A quite easy way to insert the literal percent sign (%) is by doing the following.

    Código:
    new string[35];
    format(string,sizeof(string),"43%s of my shirts are black.","%%");
    SendClientMessage(playerid,0xFFFFFAA,string);



    [Codigo util]format D07Xwqb
    [Codigo util]format Yjab9HN

      Data/hora atual: Qui 9 maio 2024 - 10:10