error 035: argument type mismatch (argument 2)
#1

Hi!
I made this stats command.But I get an error 035: argument type mismatch (argument 2).

What is the problem here?

Pawn code:

pawn Код:
CMD:stats(playerid,params[])
{
    new Cash = PlayerInfo[playerid][pCash];
    new Deaths = PlayerInfo[playerid][pDeaths];
    new Kills = PlayerInfo[playerid][pKills];
    new string[500];
    format(string,sizeof(string),"Cash: %d | Deaths: %d | Kills: %d |",Cash,Deaths,Kills);
    SendClientMessage(playerid,string);
    return 1;
}
Variables:
enum pInfo
{
pPass,
pCash,
pAdmin,
pKills,
pDeaths
}
Reply
#2

Quote:
Originally Posted by NviDa
Посмотреть сообщение
Hi!
I made this stats command.But I get an error 035: argument type mismatch (argument 2).

What is the problem here?

Pawn code:

pawn Код:
CMD:stats(playerid,params[])
{
    new Cash = PlayerInfo[playerid][pCash];
    new Deaths = PlayerInfo[playerid][pDeaths];
    new Kills = PlayerInfo[playerid][pKills];
    new string[500];
    format(string,sizeof(string),"Cash: %d | Deaths: %d | Kills: %d |",Cash,Deaths,Kills);
    SendClientMessage(playerid,string);
    return 1;
}
Variables:
enum pInfo
{
pPass,
pCash,
pAdmin,
pKills,
pDeaths
}
You need a COLOR.

Before:
pawn Код:
SendClientMessage(playerid,string);
After:
pawn Код:
SendClientMessage(playerid,-1,string);
NOTE: -1 is color WHITE.
Reply
#3

Lol! That was it! Its working now. Thanks .
But -1 is color white? What are the other integers for different colors?Can you tell?


Btw
+ REP
Reply
#4

Thanks for the rep.
OT: I just saw it on other gamemodes and I try to copy it XD
Reply
#5

Yes, white is -1 and black is 0. The most colours are difficult to remember them as integers rather than as hex numbers.

For example:
pawn Код:
// RED:
0xFF0000FF -> -16776961

// YELLOW:
0xFFFF00FF -> -65281

// LIME:
0x00FF00FF -> 16711935
Reply
#6

Oh okay.
And what I want to add more stuff to my /stats command.
Suppose
The players Name and his score.What should I do?
Reply
#7

You need to use format function like before. But if by typing /stats you get only your own statistics, what would be the point of getting your own name and ID. That would be good though for every player. Something like this:
pawn Код:
CMD:stats(playerid,params[])
{
    if (isnull(params))
    {
        new string[128];
        format(string, sizeof (string), "Cash: %d | Deaths: %d | Kills: %d", PlayerInfo[playerid][pCash], PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pKills]);
        SendClientMessage(playerid, -1, string);
    }
    else
    {
        new id;
        if (sscanf(params, "r", id)) return SendClientMessage(playerid, -1, "Usage: /stats <ID/Part Of Name (Optional)>");
        if (id == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "Invalid player");
        new string[128], player_name[21];
        GetPlayerName(id, player_name, sizeof (player_name));
        format(string, sizeof (string), "Statistics of %s (ID: %i)", player_name, id);
        SendClientMessage(playerid, -1, string);
        format(string, sizeof (string), "Cash: %d | Deaths: %d | Kills: %d", PlayerInfo[id][pCash], PlayerInfo[id][pDeaths], PlayerInfo[id][pKills]);
        SendClientMessage(playerid, -1, string);
    }
    return 1;
}
If you type /stats, you get your own stats and if you type /stats ID or player's name, you get that player's statistics. You need sscanf for that.
Reply
#8

Okay thanks man! But I need score to be displayed on stats too.What about for that?
Reply
#9

Score is integer so you use "%i" or "%d" placeholder in the format and GetPlayerScore function as argument.
pawn Код:
format(string, sizeof (string), "Cash: %d | Deaths: %d | Kills: %d | Score: %d", PlayerInfo[playerid][pCash], PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pKills], GetPlayerScore(playerid));
Reply
#10

nvm, Konstantinos was faster
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)