/stats multi id
#1

Hello, can someone help me to convert this stats command to /stats id? So if i do /stats i can see my stats, and if i do /stats 0 or /stats Face9000 i can see others stats.

Код:
CMD:stats(playerid, params[])
{
    if(GetPVarInt(playerid, "spawned") == 0) return SCM(playerid, COLOR_LIGHTBLUE, "Please spawn before doing any action.");
    if(GetPVarInt(playerid,"CmdTime")>GetTickCount())return SCM(playerid,0xFF0000FF,"Please wait before using this command again.");
    new Float:gihp, Float:giar;
    GetPlayerHealth(playerid, gihp);
    GetPlayerArmour(playerid, giar);
    new temp[1500];
    new info[1500];

    new Float:Ratio = (float(GetPlayerScore(playerid))/float(UserInfo[playerid][Deaths]));

    strcat(info,"{53C506}Financial Stats:\n\n");
    format(temp, sizeof(temp), "{FFFFFF}Money: {F2C80C}%i\n\n",GetPlayerCash(playerid));
    strcat(info, temp);
    
    format(temp, sizeof(temp), "{FFFFFF}Cookies: {F2C80C}%d\n\n",UserInfo[playerid][Cookies]);
    strcat(info, temp);
    
    strcat(info,"{53C506}Other Stats:\n\n");
    
    format(temp, sizeof(temp), "{FFFFFF}Account ID: {F2C80C}%d\n\n",UserInfo[playerid][ID]);
    strcat(info, temp);
    
    format(temp, sizeof(temp), "{FFFFFF}Registration Date: {F2C80C}%s\n\n",UserInfo[playerid][RegisterDate]);
    strcat(info, temp);
    
    format(temp, sizeof(temp), "{FFFFFF}Level: {F2C80C}%s (%d)\n\n",AdminLevelToName(playerid),UserInfo[playerid][Admin]);
    strcat(info, temp);
    
    format(temp, sizeof(temp), "{FFFFFF}Vip: {F2C80C}%s (%d)\n\n",VipName(playerid),UserInfo[playerid][VIP]);
    strcat(info, temp);
    
    format(temp, sizeof(temp), "{FFFFFF}Score: {F2C80C}%i\n\n",GetPlayerScore(playerid));
    strcat(info, temp);
    
    format(temp, sizeof(temp), "{FFFFFF}Deaths: {F2C80C}%d\n\n",UserInfo[playerid][Deaths]);
    strcat(info, temp);

    format(temp, sizeof(temp), "{FFFFFF}Ratio between Kills/Deaths: {F2C80C}%.3f\n\n",Ratio);
    strcat(info, temp);
    
    strcat(info,"{53C506}Mission Stats:\n\n");

    format(temp, sizeof(temp), "{FFFFFF}Missions Played: {F2C80C}%d\n\n",UserInfo[playerid][MissionsPlayed]);
    strcat(info, temp);
    
    format(temp, sizeof(temp), "{FFFFFF}Last Man Standing Wins: {F2C80C}%d\n\n",UserInfo[playerid][LmsWins]);
    strcat(info, temp);
    
    ShowPlayerDialog(playerid, DIALOG_STATS, DIALOG_STYLE_MSGBOX,"{FFFFFF}Your Current Stats",info,"Close","");
    SetPVarInt(playerid,"CmdTime",GetTickCount()+5000);
    return true;
}
Thanks
Reply
#2

Add a sscanf condition for the other player and replace playerid with giveplayerid. If no sscanf option is given, or the option is an unconnected player set the giveplayerid(or whatever name) to the ID of the player so it shows their stats.
Reply
#3

Care to show me that in the code? Thanks.
Reply
#4

Bump
Reply
#5

pawn Код:
CMD:stats(playerid, params[])
{
    if(GetPVarInt(playerid, "spawned") == 0) return SCM(playerid, COLOR_LIGHTBLUE, "Please spawn before doing any action.");
    if(GetPVarInt(playerid,"CmdTime") > GetTickCount()) return SCM(playerid,0xFF0000FF,"Please wait before using this command again.");
    new giveplayerid;
    if(sscanf(params,"u",giveplayerid)) return SCM(playerid,0xFF0000FF,"/stats [id / part of name]");
    if(giveplayerid == INVALID_PLAYER_ID) return SCM(playerid,0xFF0000FF,"Invalid player");

    new yourid = playerid;
    playerid = giveplayerid;
    new Float:gihp, Float:giar;
    GetPlayerHealth(playerid, gihp);
    GetPlayerArmour(playerid, giar);
    new temp[1500];
    new info[1500];
    // code
    // ...
    // ...
    // ...
    // ...
    ShowPlayerDialog(yourid, DIALOG_STATS, DIALOG_STYLE_MSGBOX,"{FFFFFF}Your Current Stats",info,"Close","");
    SetPVarInt(yourid,"CmdTime",GetTickCount()+5000);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)