SA-MP Forums Archive
Stats ! - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Stats ! (/showthread.php?tid=398115)



Stats ! - []Allex[] - 08.12.2012

Hi !

Yesterday I made the Command stats but i don''t how to see another player stats !

I type /stats [id] but doesn''t work because i don''t made !

Can someone do that ?

Thanks !

pawn Код:
CMD:stats(playerid,params[])
{
    new rankid = pRank[playerid];
    new plName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, plName, sizeof(plName));
    new rank[20];
    if(pRank[playerid] == 0) { rank = "Newbie"; }
    else if(pRank[playerid] == 1) { rank = "Baby Killa'"; }
    else if(pRank[playerid] == 2) { rank = "Soldier"; }
    else if(pRank[playerid] == 3) { rank = "Gangsta'"; }
    else if(pRank[playerid] == 4) { rank = "Underboss"; }
    else if(pRank[playerid] == 5) { rank = "Tha' Boss"; }
    new string[9999],sA[1024],sM[1024],sD[1024],sS[1024],sL[1024],sC[1024],file[356],P1Logged[4],P1Register[4],RegDate[256], player1, h, m, s,Own[4];
    if(!strlen(params)) player1 = playerid;
    else player1 = strval(params);
    format(file,sizeof(file),"/ladmin/users/%s.ini",udb_encode(PlayerName2(player1)));
    if(strlen(dini_Get(file,"RegisteredDate")) < 3) RegDate = "n/a"; else RegDate = dini_Get(file,"RegisteredDate");
    if(PlayerInfo[player1][LoggedIn] == 1) P1Logged = "Yes"; else P1Logged = "No";
    if(PlayerInfo[player1][Owner] == 1)
    {
        Own = "Yes";
    }
    else
    {
        if(PlayerInfo[player1][Owner] == 0)
        {
            Own =" No";
        }
    }
    if(fexist(file)) P1Register = "Yes"; else P1Register = "No";
    if(IsPlayerConnected(player1)) {
        new year,month,day; getdate(year, month, day);
        TotalGameTime(player1, h, m, s);
        format(sA,sizeof(sA),"{FFFFFF}========================================\n");
        format(sM,sizeof(sM),"{FFFFFF}Name: "R"%s  {FFFFFF}Date :{FFFFFF}%d{00FF04}*{FFFFFF}%d{00FF04}*{FFFFFF}%d\n{FFFFFF}SA-MP Version : {00FF04} 0.3e\n",PlayerName2(playerid),year,month,day);
        format(sD,sizeof(sD),"{FFBF00}Dm\n{00FF04}Killer Rank : {00F2FF}[{FFFFFF}%d{00F2FF}] {00F2FF}[{FFFFFF}%s{00F2FF}] \n{00FF04}Kills : {00F2FF}[{FFFFFF}%d{00F2FF}] \n{00FF04}Deaths : {00F2FF}[{FFFFFF}%d{00F2FF}]\n{00FF04}Killing Spree : {00F2FF}[{FFFFFF}%d{00F2FF}]\n\n",rankid,rank,PlayerInfo[playerid][Kills],PlayerInfo[playerid][Deaths],bKillingSpree{ playerid });
        format(sS,sizeof(sS),"{FFBF00}Server Info\n {00FF04}Vip Level : {00F2FF}[{FFFFFF}%d{00F2FF}]\n {00FF04}Admin Level : {00F2FF}[{FFFFFF}%d{00F2FF}]\n {00FF04}sAdmin : {00F2FF}[{FFFFFF}%s{00F2FF}]\n\n{FFBF00} Other Info\n{00FF04} Moneys :{00F2FF}[{FFFFFF}%d{00F2FF}] \n {00FF04}Score : {00F2FF}[{FFFFFF}%d{00F2FF}] \n {00FF04}Coins : {00F2FF}[{FFFFFF}%d{00F2FF}]\n",PlayerInfo[playerid][Vip],PlayerInfo[playerid][Level],Own,GetPlayerMoney(playerid),GetPlayerScore(playerid),pInfo[playerid][Coins]);
        format(sL,sizeof(sL)," {00FF04}Time : {00F2FF}[{FFFFFF}%d{00F2FF}]{00FF04}Hours \n\t[{FFFFFF}%d{00F2FF}]{00FF04}mins\n\t[{FFFFFF}%d{00F2FF}]{00FF04}Seconds\n{00FF04}Register Date : {00F2FF}[{FFFFFF}%s{00F2FF}]\n{00FF04}Register : {00F2FF}[{FFFFFF}%s{00F2FF}]\n{00FF04}Login : {00F2FF}[{FFFFFF}%s{00F2FF}]\n{00FF04}Warning : {00F2FF}[{FFFFFF}%d{00F2FF}]\n{00FF04}SkinID : {00F2FF}[{FFFFFF}%d{00F2FF}]\n",h,m,s,RegDate,P1Register,P1Logged,PlayerInfo[player1][Warnings],GetPlayerSkin(player1));
        format(sC,sizeof(sC),"{00FF04}Stunt : {00F2FF}[{FFFFFF}%d{00F2FF}]\n{00FF04}Cookies : {00F2FF}[{FFFFFF}%d{00F2FF}]\n",PlayerInfo[player1][Stunt],pInfo[playerid][Cookie]);
        format(string,sizeof(string),"%s %s %s %s %s %s %s %s ",sA,sM,sA,sD,sS,sL,sC,sA);
        return ShowPlayerDialog(playerid, 9999, 0, "Player Stats", string, "Ok", "");
    }
    return ( 1 );
}



Re: Stats ! - Konstantinos - 08.12.2012

Use sscanf.
pawn Код:
CMD:stats(playerid,params[])
{
    new
        id
    ;
    if( !sscanf( params, "r", id ) )
    {
        // code;
    }
    else
    {
        // code;
    }
    return ( 1 );
}
And NEVER use this again
pawn Код:
new string[9999]
It's the worst thing I've ever seen! 1024 should be fine and just use one string and continue with the rest of message with "\".
pawn Код:
format( string, sizeof( string ), "blablabla \
    blablabla... \
    blablablabla.. \
    last blablabla.."
,
    something1,
    something2,
    something3 );