Format help
#1

pawn Код:
CMD:mc(playerid,params[])
{
    new string[128], targetplayer;
    if(sscanf(params, "i", targetplayer)) return SendClientMessage(playerid, 0xFFFFFFFF, "[USAGE]: /mc [id]");
    else
    {
        format(string, 128, "Player Checks:");
        if (APlayerData[targetplayer][JobStarted] == true)
        {
            format(string, 128, "On a mission: {66FF00}Yes");
        }
        else
            format(string, 128, "On a mission: {FF0000}No");

        if(APlayerData[targetplayer][MafiaLoad] == true)
        {
            format(string, 128, "Maffia load: {66FF00}Yes");
        }
        else
            format(string, 128, "Maffia load: {FF0000}No");
       
        if (APlayerData[targetplayer][Overloaded] == true)
        {
            format(string, 128, "Overloaded: {66FF00}Yes");
        }
        else
            format(string, 128, "Overloaded: {FF0000}No");
       
        SendClientMessage(playerid, 0xFFFFFFFF, string);
    }
    return 1;
}
What it in-game shows is this:
Overloaded: No

How to fix that, I'm new in scripting so, an explanation is helpful
Reply
#2

pawn Код:
CMD:mc( playerid, params[ ] )
{
    new Str_mission[ 32 ], Str_maffia[ 32 ], Str_overloaded[ 32 ], msg[ 128 ], targetplayer;
    if( sscanf( params, "r", targetplayer  )) return SendClientMessage( playerid, 0xFFFFFFFF, "[USAGE]: /mc [id]" );

    if( APlayerData[ targetplayer ][ JobStarted ] == true ) format( Str_mission, sizeof( Str_mission ), "On a mission: {66FF00}Yes" );
    else format( Str_mission, sizeof( Str_mission ), "On a mission: {FF0000}No" );

    if( APlayerData[ targetplayer ][ MafiaLoad ] == true ) format( Str_maffia, sizeof( Str_maffia ), "Maffia load: {66FF00}Yes" );
    else format( Str_maffia, sizeof( Str_maffia ), "Maffia load: {FF0000}No" );

    if( APlayerData[ targetplayer ][ Overloaded ] == true ) format( Str_overloaded, sizeof( Str_overloaded ), "Overloaded: {66FF00}Yes" );
    else format( Str_overloaded, sizeof( Str_overloaded ), "Overloaded: {FF0000}No" );

    strcat( msg, "Player Checks:" );
    strcat( msg, Str_mission );
    strcat( msg, Str_maffia );
    strcat( msg, Str_overloaded );

    SendClientMessage( playerid, 0xFFFFFFFF, msg );
    return 1;
}
Reply
#3

Quote:
Originally Posted by SomebodyAndMe
Посмотреть сообщение
[pawn]
"I'm new in scripting so, an explanation is helpful"
Some explanation?

Edit it shows up in-game like this:


And it shoudl be under each other.
Reply
#4

pawn Код:
CMD:mc( playerid, params[ ] ) // Command
{
    new Str_mission[ 32 ], // a string of 32 Chatacters for the 'On mission' (Yes/No)
        Str_maffia[ 32 ], // a string of 32 Chatacters for the 'On maffia' (Yes/No)
        Str_overloaded[ 32 ], // a string of 32 Chatacters for the 'Overloaded' (Yes/No)
        msg[ 128 ], // A string that we will send the message
        targetplayer; // 'playerid' Variable
       
    if( sscanf( params, "r", targetplayer  )) return SendClientMessage( playerid, 0xFFFFFFFF, "[USAGE]: /mc [id]" );
    // Sscanf parameter for '/mc [ID/Part Of Name]'
    if( APlayerData[ targetplayer ][ JobStarted ] == true ) format( Str_mission, sizeof( Str_mission ), " On a mission: {66FF00}Yes " );
    else format( Str_mission, sizeof( Str_mission ), " On a mission: {FF0000}No " );
    // if the JobStarted is true it store at the 'Str_mission' Variable the text: On a mission: {66FF00}Yes
    // Else it stores the text: On a mission: {FF0000}No
    if( APlayerData[ targetplayer ][ MafiaLoad ] == true ) format( Str_maffia, sizeof( Str_maffia ), " Maffia load: {66FF00}Yes " );
    else format( Str_maffia, sizeof( Str_maffia ), " Maffia load: {FF0000}No " );
    // if the MafiaLoad is true it store at the 'Str_maffia' Variable the text: Maffia load: {66FF00}Yes
    // Else it stores the text: Maffia load: {FF0000}No
    if( APlayerData[ targetplayer ][ Overloaded ] == true ) format( Str_overloaded, sizeof( Str_overloaded ), " Overloaded: {66FF00}Yes " );
    else format( Str_overloaded, sizeof( Str_overloaded ), " Overloaded: {FF0000}No " );
    // if the MafiaLoad is true it store at the 'Overloaded' Variable the text: Overloaded: {66FF00}Yes
    // Else it stores the text: Overloaded: {FF0000}No
   
    // strcat: This function concatenates two strings into the destination reference
    strcat( msg, "Player Checks: " ); // The first message
    strcat( msg, Str_mission ); // then the message we stored at the Str_mission Variable
    strcat( msg, Str_maffia ); // then the message we stored at the Str_maffia Variable
    strcat( msg, Str_overloaded ); // and then the message we stored at the Str_overloaded Variable

    SendClientMessage( playerid, 0xFFFFFFFF, msg );
    // Last, we send the message that it's the 'msg' and we cat the messages before and it concatenates them
   
    return 1;
}
// Result: 'Player Checks: On a mission: {Yes/No} Maffia load: {Yes/No} Overloaded: {Yes/No} '
Reply
#5

How to make it like it is under each other? I've tryed \r and \n both didn't work.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)