CMD:stats(playerid,params[]) { SendClientMessage(playerid, whitestamp, "{FFFF00}Usage: /stats <PlayerID>"); new id, h, m, d; new pName[24], pName2[24]; GetPlayerName(playerid, pName, sizeof(pName)), GetPlayerName(id, pName2, sizeof(pName)); sscanf(params, "u", id); if (isnull(params)) { new seconds = gettime() - pInfo[playerid][ConnectedTime] + pInfo[playerid][TotalSecs]; format(Jstring, sizeof(Jstring), "{ffd700}%s (ID:%d)\n\n", pName, playerid); format(Jstring, sizeof(Jstring), "Score: %d\n", GetPlayerScore(playerid)); format(Jstring, sizeof(Jstring), "Money: $%d\n", GetPlayerMoney(playerid)); format(Jstring, sizeof(Jstring), "Kills: %d\n", pInfo[playerid][Kills]); format(Jstring, sizeof(Jstring), "Deaths: %d\n", pInfo[playerid][Deaths]); format(Jstring, sizeof(Jstring), "Ratio: %0.2f\n", Float:pInfo[playerid][Kills]/Float:pInfo[playerid][Deaths]); format(Jstring, sizeof(Jstring), "Total Time Logged in: %s\n", ConvertTime(seconds,m,h,d)); return ShowPlayerDialog(playerid,DIALOG_STATS,DIALOG_STYLE_MSGBOX,"Player Stats",Jstring,"Close",""); } else if(IsPlayerConnected(id)) { new seconds = gettime() - pInfo[id][ConnectedTime] + pInfo[id][TotalSecs]; format(Jstring, sizeof(Jstring), "{ffd700}%s (ID:%d) {A9C4E4}\n\nScore: %d\nMoney: $%d\nKills: %d\nDeaths: %d\nRatio: %0.2f\nTime Logged In: %s", pName2, id, GetPlayerScore(id), GetPlayerMoney(id), pInfo[id][Kills], pInfo[id][Deaths], Float:pInfo[id][Kills]/Float:pInfo[id][Deaths], ConvertTime(seconds,m,h,d)); return ShowPlayerDialog(playerid,DIALOG_STATS,DIALOG_STYLE_MSGBOX,"Player Stats",Jstring,"Close",""); } else return ShowPlayerDialog(playerid, DIALOG_STATS2, DIALOG_STYLE_MSGBOX,"Player Stats", "Player is not connected", "Close", ""); }
format(Jstring, sizeof(Jstring), "{ffd700}%s (ID:%d)\n\n \
Score: %d\n \
Money: $%d\n",
pName, playerid,
GetPlayerScore(playerid),
GetPlayerMoney(playerid));
Your using 7 formats when you should only be using 1 (Possibly 2 if the string is too long and you need strcat) each successive format clears the action of the last so you'll only ever end up with the last formatted string of course.
Example (You will need to complete this) pawn Код:
|
dcmd_stats(playerid,params[]) { new str[512], pDeaths, player1, h, m, s; new status[2][10] = {"Disabled", "Enabled"}; if(!strlen(params)) player1 = playerid; else player1 = strval(params); if(!IsPlayerConnected(player1)) return SendClientMessage(playerid, white, "{FF0000}>> Player not Connected"); TotalGameTime(player1, h, m, s); if(AccInfo[player1][Deaths] == 0) pDeaths = 1; else pDeaths = AccInfo[player1][Deaths]; format(str, sizeof(str), "{DAA520}%s (ID: %d){B0C4DE}\n\n", PlayerName2(player1), player1); format(str, sizeof(str), "%sSkinID: %d\n", str, GetPlayerSkin(player1)); format(str, sizeof(str), "%sScore: %d\n", str, GetPlayerScore(player1)); format(str, sizeof(str), "%sKills: %d\n", str, AccInfo[player1][Kills]); format(str, sizeof(str), "%sMoney: $%d\n", str, GetPlayerMoney(player1)); format(str, sizeof(str), "%sRatio: %.2f\n", str, Float:AccInfo[player1][Kills]/Float:pDeaths); format(str, sizeof(str), "%sReputations: +%d\n\n", str, AccInfo[player1][Reps]); format(str, sizeof(str), "%sInterior: %d\n", str, GetPlayerInterior(player1)); format(str, sizeof(str), "%sTime Login: %d hours %d minutes %d seconds\n", str, h, m, s); ShowPlayerDialog(playerid, 8435, DIALOG_STYLE_MSGBOX, "Player Statistics", str, "Close", ""); return 1; } #endif
format(Jstring, sizeof(Jstring), "{ffd700}%s (ID:%d)\n\n \ Score: %d\n \ Money: $%d\n", pName, playerid, GetPlayerScore(playerid), GetPlayerMoney(playerid));
format(Jstring, sizeof(Jstring), "{ffd700}%s (ID:%d)\n\n \
Score: %d\n \
Money: $%d\n",
format(Jstring, sizeof(Jstring), "{ffd700}%s (ID:%d)\n\nScore: %d\nMoney: $%d\n",
#define IsValidID(%0) \
if(%0 >= 0 && %0 <= 100) return 1; \
else return 0;
You wrote legit code it will compile but it doesn't do what your expecting. I could write it but then you wouldn't learn anything at least give it a shot and if you have problems post your code and I'll tell you what you did wrong.
One quick thing... pawn Код:
pawn Код:
|
new seconds = gettime() - pInfo[playerid][ConnectedTime] + pInfo[playerid][TotalSecs]; new str1[512]; strcat(str1, "{ffd700}%s (ID:%d)\n\n", pName, playerid); <<-----error 035: argument type mismatch (argument 3) strcat(str1, "%sScore: %d\n", GetPlayerScore(playerid)); strcat(str1, "%sMoney: $%d\n", GetPlayerMoney(playerid)); strcat(str1, "%sKills: %d\n", pInfo[playerid][Kills]); strcat(str1, "%sDeaths: %d\n", pInfo[playerid][Deaths]); strcat(str1, "%sRatio: %0.2f\n", Float:pInfo[playerid][Kills]/Float:pInfo[playerid][Deaths]); <<------warning 213: tag mismatch strcat(str1, "%sTotal Time Logged in: %s\n", ConvertTime(seconds,m,h,d)); <<------error 035: argument type mismatch (argument 3) return ShowPlayerDialog(playerid,DIALOG_STATS,DIALOG_STYLE_MSGBOX,"Player Stats",Jstring,"Close",""); }
You wouldn't use strcat like that you would format the two halfs and then combine but you probably don't need that here just a single format() should work if you follow my example.
|
input line too long (after substitutions)
{ new seconds = gettime() - pInfo[playerid][ConnectedTime] + pInfo[playerid][TotalSecs]; format(JLstring, sizeof(JLstring), "{ffd700}%s (ID:%d){A9C4E4}\n\nGeneral:\nTime Login: %s \nPing: %d \n\nScores:\nDM Score: %d \nK/D Ratio: %0.2f \nMoney: $%d \n\nGame: \nVirtual World: %d \nWanted Level: %d \nSkin: %d", pName, playerid, ConvertTime(seconds,m,h,d), GetPlayerPing(playerid), pInfo[playerid][Kills], Float:pInfo[playerid][Kills]/Float:pInfo[playerid][Deaths], GetPlayerMoney(playerid), GetPlayerVirtualWorld(playerid), GetPlayerWantedLevel(playerid),GetPlayerSkin(playerid)); return ShowPlayerDialog(playerid,DIALOG_STATS,DIALOG_STYLE_MSGBOX,"Player Stats",JLstring,"Close",""); } else
new str[512]; // Change the size if the not all the text shows.
format(JLstring, sizeof(JLstring), "Your stats text 1", bla, bla1);
strcat(str, JLstring);
format(JLstring, sizeof(JLstring), "Your stats text 2", bla3, bla4);
strcat(str, JLstring);
ShowPlayerDialog(playerid, 1234, DIALOG_STYLE_MSGBOX, "Statistics", str, "Close", "");
pawn Код:
|