/getstats ID in dialog?
#1

Trying to make this for quite a while but failing.

How do I get other player stats but it just stays in the dialog?


Here is my /stats cmd.
pawn Код:
CMD:stats(playerid, params[])
{
    new money = PlayerInfo[playerid][pMoney];
    new score = PlayerInfo[playerid][pScores];
    new admin = PlayerInfo[playerid][pAdminLevel];
    new vip = PlayerInfo[playerid][pVIPlevel];
    new kills = PlayerInfo[playerid][pKills];
    new Deaths = PlayerInfo[playerid][pDeaths];
    new Kicks = PlayerInfo[playerid][pKicks];
    new Warns = PlayerInfo[playerid][pWarns];
    new string[500];
    format(string,sizeof(string), "{0099FF}Money: %d\nLevel: %d", money,score);
    format(string,sizeof(string), "{00AAFF}%s\nAdmin: %d\nVIP: %d", string, admin, vip);
    format(string,sizeof(string), "{00AAFF}%s\nKills: %d\nDeaths: %d", string, kills, Deaths);
    format(string,sizeof(string), "{00AAFF}%s\nKicks: %d\nWarns: %d", Kicks, Warns);
    ShowPlayerDialog(playerid, D_STATS, DIALOG_STYLE_MSGBOX, "Your stats", string, "Close", "");
    return 1;
}
Reply
#2

What's wrong with your currently code?
Reply
#3

I've defined string size to 128. 500 is usless because the strings aren't that long.
pawn Код:
CMD:stats(playerid, params[])
{
    new money = PlayerInfo[playerid][pMoney];
    new score = PlayerInfo[playerid][pScores];
    new admin = PlayerInfo[playerid][pAdminLevel];
    new vip = PlayerInfo[playerid][pVIPlevel];
    new kills = PlayerInfo[playerid][pKills];
    new Deaths = PlayerInfo[playerid][pDeaths];
    new Kicks = PlayerInfo[playerid][pKicks];
    new Warns = PlayerInfo[playerid][pWarns];
    new string[128], string2[128];
    format(string,sizeof(string), "{0099FF}Money: %d\nLevel: %d", money,score);
    format(string2,sizeof(string2), "{00AAFF}%s\nAdmin: %d\nVIP: %d", string, admin, vip);
    strcat(string,string2);
    format(string2,sizeof(string2), "{00AAFF}%s\nKills: %d\nDeaths: %d", string, kills, Deaths);
    strcat(string,string2);
    format(string2,sizeof(string2), "{00AAFF}%s\nKicks: %d\nWarns: %d", Kicks, Warns);
    strcat(string,string2);
    ShowPlayerDialog(playerid, D_STATS, DIALOG_STYLE_MSGBOX, "Your stats", string, "Close", "");
    #pragma unused params
    return 1;
}
Reply
#4

Read this:

How do I get other player stats but it just stays in the dialog?

Код:
new money = PlayerInfo[playerid][pMoney];
Use sscanf to get other player ID.

pawn Код:
CMD:stats(playerid, params[])
{
    new targetID;
    if(sscanf(params, "u", targetID)) return SendClientMessage(playerid, 0xFF0000FF, "[USAGE]: /stats [playerid]");
    if(targetID == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFF0000FF, "[ERROR]: Player is not connected.");
    new money, score, admin, vip, kills, Deaths, Kicks, Warns, string[128], string2[128];
    money = PlayerInfo[targetID][pMoney];
    score = PlayerInfo[targetID][pScores];
    admin = PlayerInfo[targetID][pAdminLevel];
    vip = PlayerInfo[targetID][pVIPlevel];
    kills = PlayerInfo[targetID][pKills];
    Deaths = PlayerInfo[targetID][pDeaths];
    Kicks = PlayerInfo[targetID][pKicks];
    Warns = PlayerInfo[targetID][pWarns];
    format(string, sizeof(string), "{0099FF}Money: %d\nLevel: %d", money, score);
    format(string2, sizeof(string2), "{00AAFF}%s\nAdmin: %d\nVIP: %d", string, admin, vip);
    strcat(string, string2);
    format(string2, sizeof(string2), "{00AAFF}%s\nKills: %d\nDeaths: %d", string, kills, Deaths);
    strcat(string, string2);
    format(string2, sizeof(string2), "{00AAFF}%s\nKicks: %d\nWarns: %d", Kicks, Warns);
    strcat(string, string2);
    ShowPlayerDialog(playerid, D_STATS, DIALOG_STYLE_MSGBOX, "Player stats", string, "Close", "");
    return 1;
}
https://sampforum.blast.hk/showthread.php?tid=120356

Download and copy to your server.
Reply
#5

Quote:
Originally Posted by RedJohn
Посмотреть сообщение
Read this:

How do I get other player stats but it just stays in the dialog?

Код:
new money = PlayerInfo[playerid][pMoney];
Use sscanf to get other player ID.
Yeah, forgot to read the title.. I thought, that he was looking for a command which get's players stats when he type the cmd.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)