error 035: argument type mismatch (argument 2) -
NviDa - 01.05.2014
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
}
Re: error 035: argument type mismatch (argument 2) -
TheSimpleGuy - 01.05.2014
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.
Re: error 035: argument type mismatch (argument 2) -
NviDa - 01.05.2014
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
Re: error 035: argument type mismatch (argument 2) -
TheSimpleGuy - 01.05.2014
Thanks for the rep.
OT: I just saw it on other gamemodes and I try to copy it XD
Re: error 035: argument type mismatch (argument 2) -
Konstantinos - 01.05.2014
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
Re: error 035: argument type mismatch (argument 2) -
NviDa - 01.05.2014
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?
Re: error 035: argument type mismatch (argument 2) -
Konstantinos - 01.05.2014
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.
Re: error 035: argument type mismatch (argument 2) -
NviDa - 01.05.2014
Okay thanks man! But I need score to be displayed on stats too.What about for that?
Re: error 035: argument type mismatch (argument 2) -
Konstantinos - 01.05.2014
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));
Re: error 035: argument type mismatch (argument 2) -
Kyance - 01.05.2014
nvm, Konstantinos was faster