CMD:stats problem.
#1

I'm trying to create a "stats" command
pawn Код:
CMD:stats(playerid, params[]) {
    new id;
    new pname[MAX_PLAYER_NAME], recievername[MAX_PLAYER_NAME];
    GetPlayerName(playerid,pname,sizeof(pname));
    GetPlayerName(id,recievername,sizeof(recievername));
    if(sscanf(params, "u", id)) return SendClientMessage(playerid, COLOR_RED,"[USAGE] - /stats [ID]");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED,"[ERROR] - Player is not connected!");
    new string[128];
    format(string, sizeof(string), "              |   ..:: %s's stats ::..   |", pname);
    SendClientMessage(playerid, COLOR_GREEN, string);
    format(string, sizeof(string), "|   ..:: Score: %d | Money: %d$ | Kills: %d | Deaths: %d ::..   |", GetPlayerScore(recievername), GetPlayerMoney(recievername), PlayerInfo[recievername][pKills], PlayerInfo[recievername][pDeaths]);
    SendClientMessage(playerid, COLOR_GREEN, string);//Error line above this line.
    return 1;
}
but i'm sadly getting this error:
Код:
\test.pwn(2241) : error 035: argument type mismatch (argument 1)
I've tried changing the recievername to id, but it still gave me the error..
Looking from other topics(******), I'm guessing that I'm missing something somewhere..
Reply
#2

Why not targetid instead or reciever ?
Reply
#3

You cannot use a string inside an array variable.

Use id instead reciever.

I also noticed another Bug. In fact you're trying to read the targetname, before checking sscanf.

pawn Код:
GetPlayerName(id,recievername,sizeof(recievername));
Should stay below sscanf.

This is right

pawn Код:
if(sscanf(params, "u", id)) return SendClientMessage(playerid, COLOR_RED,"[USAGE] - /stats [ID]");
GetPlayerName(id,recievername,sizeof(recievername));
Reply
#4

Quote:
Originally Posted by x96664
Посмотреть сообщение
Why not targetid instead or reciever ?
Would renaming it really do something?
Well, still.. re-named, nothing changed..
As i said earlier, i have a feeling that I'm missing something, but i can't notice it.

EDIT:

Quote:
Originally Posted by Skimmer
Посмотреть сообщение
You cannot use a string inside an array variable.

Use id instead reciever.

I also noticed another Bug. In fact you're trying to read the targetname, before checking sscanf.

pawn Код:
GetPlayerName(id,recievername,sizeof(recievername));
Should stay below sscanf.

This is right

pawn Код:
if(sscanf(params, "u", id)) return SendClientMessage(playerid, COLOR_RED,"[USAGE] - /stats [ID]");
GetPlayerName(id,recievername,sizeof(recievername));
Thanks, this worked.
Reply
#5

Quote:
Originally Posted by Kyance
Посмотреть сообщение
Would renaming it really do something?
Well, still.. re-named, nothing changed..
As i said earlier, i have a feeling that I'm missing something, but i can't notice it.

Thanks, this worked.
It's not what I mentioned, check there my stats command:
pawn Код:
CMD:stats(playerid,params[])
{
    new id;
    if(sscanf(params,"u",id)) return SendClientMessage(playerid, BLUE,"USAGE: "cwhite"/stats (id / name)");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, RED, "Player is not connected!");
    ShowStats(playerid, id);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)