Error with strings
#1

Getting Errors with this code..

pawn Код:
COMMAND:stats(playerid,params[])
{
    new pDeaths, player1, player, h, m, s;

    if(sscanf(params, "r", player))
    {
        player1 = playerid;
    }
    else
    {
        player1 = player;
    }

    if(IsPlayerConnected(player1))
    {
        TotalGameTime(player1, h, m, s);
        if(PlayerInfo[player1][Deaths] == 0) { pDeaths = 1; }
        else { pDeaths = PlayerInfo[player1][Deaths]; }
        new longstring[1024];
        strcat(longstring,"\n{FF0000}Stats of the player:{00CC00} %s\n\n{FF0000}Kills:{00CC00}\t\t%d\n{FF0000}Deaths:{00CC00}\t\t%d\n{FF0000}K/D:{00CC00}\t\t%0.2f\n", GetName(player1), PlayerInfo[player1][Kills], PlayerInfo[player1][Deaths],Float:PlayerInfo[player1][Kills]/Float:pDeaths);
        strcat(longstring,"{FF0000}Score:{00CC00}\t\t%d\n{FF0000}Money:{00CC00}\t\t$%d\n{FF0000}Hours:{00CC00}\t\t%d\n{FF0000}Minutes:{00CC00}\t\t%d\n",GetPlayerScore(player1),GetPlayerMoney(player1),h,m);
        strcat(longstring,"{FF0000}Seconds:{00CC00}\t%d\n{FF0000}Register date:{00CC00}\t%s",s,PlayerInfo[player1][RegDate]);
        ShowPlayerDialog(playerid, STATS_DIALOG, DIALOG_STYLE_MSGBOX, "Player Stats", longstring, "OK", "");
    }
    else
    {
        SendClientMessage(playerid, RED, "Player is not connected!");
    }
    return 1;
}

Errors:

Код:
C:\DOCUME~1\SAIKUM~1\Desktop\Pure\FS\MELLAD~1.2R3\MELLAD~1.2R3\FILTER~1\MELLAD~1.PWN(3562) : error 035: argument type mismatch (argument 3)
C:\DOCUME~1\SAIKUM~1\Desktop\Pure\FS\MELLAD~1.2R3\MELLAD~1.2R3\FILTER~1\MELLAD~1.PWN(3563) : warning 202: number of arguments does not match definition
C:\DOCUME~1\SAIKUM~1\Desktop\Pure\FS\MELLAD~1.2R3\MELLAD~1.2R3\FILTER~1\MELLAD~1.PWN(3563) : warning 202: number of arguments does not match definition
C:\DOCUME~1\SAIKUM~1\Desktop\Pure\FS\MELLAD~1.2R3\MELLAD~1.2R3\FILTER~1\MELLAD~1.PWN(3563) : warning 202: number of arguments does not match definition
C:\DOCUME~1\SAIKUM~1\Desktop\Pure\FS\MELLAD~1.2R3\MELLAD~1.2R3\FILTER~1\MELLAD~1.PWN(3564) : warning 202: number of arguments does not match definition
Reply
#2

You can't use strcat like a normal format because the last parameter of strcat is the length.
Try to use multiple formats.
Reply
#3

Quote:
Originally Posted by Macronix
Посмотреть сообщение
You can't use strcat like a normal format because the last parameter of strcat is the length.
Try to use multiple formats.
Can u give me the code with multiple formats please
Reply
#4

Here, try this:
pawn Код:
format(longstring, sizeof(longstring),"\n{FF0000}Stats of the player:{00CC00} %s\n\n{FF0000}Kills:{00CC00}\t\t%d\n{FF0000}Deaths:{00CC00}\t\t%d\n{FF0000}K/D:{00CC00}\t\t%0.2f\n", GetName(player1), PlayerInfo[player1][Kills], PlayerInfo[player1][Deaths],Float:PlayerInfo[player1][Kills]/Float:pDeaths);
format(longstring, sizeof(longstring),"%s{FF0000}Score:{00CC00}\t\t%d\n{FF0000}Money:{00CC00}\t\t$%d\n{FF0000}Hours:{00CC00}\t\t%d\n{FF0000}Minutes:{00CC00}\t\t%d\n{FF0000}Seconds:{00CC00}\t%d\n{FF0000}Register date:{00CC00}\t%s",longstring,GetPlayerScore(player1),GetPlayerMoney(player1),h,m,s,PlayerInfo[player1][RegDate]);
Replace your strcat's with my code
Reply
#5

Thanks bro..its working

really thanks a lot

+Rep
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)