PDA

View Full Version : Stats dialog


vassilis
04/04/2014, 11:29 AM
CMD:stats(playerid,params[])
{
new id;

if(sscanf(params,"u",id)) return SendClientMessage(playerid, COLOR_RED," (Error): /stats [id]");
if(!IsPlayerConnected(id)) return ErrorMessages(playerid,2);
new gname[MAX_PLAYER_NAME];
GetPlayerName(id,gname,sizeof(gname));
new str[20][1900];
format(str[0],1900,"| ------ | %s 's Status | ------- | \n", gname);
strcat(str[1],str[0]);
format(str[2],1900,""COL_WHITE"Score: "COL_LIGHTBLUE"%d \n "COL_WHITE"Money: "COL_LIGHTBLUE"$ %d \n"COL_WHITE"Kills: "COL_LIGHTBLUE"%d \n "COL_WHITE"Deaths: "COL_LIGHTBLUE"%d \n", pinfo[id][Score], pinfo[id][Money], pinfo[id][Kills], pinfo[id][Deaths]);
strcat(str[1],str[2]);
format(str[3],1900,""COL_WHITE"Admin Level: "COL_LIGHTBLUE"%d \n"COL_WHITE"VIP Level: "COL_LIGHTBLUE"%d \n "COL_WHITE"Total Robberies: "COL_LIGHTBLUE"%d \n ", pinfo[id][Admin], pinfo[id][VIP], pinfo[id][TotalRobs]);
strcat(str[1],str[3]);
format(str[4],1900,""COL_WHITE"Robbery Skill: "COL_LIGHTBLUE"%d \n, "COL_WHITE"Hitman Skill: "COL_LIGHTBLUE"%d \n,"COL_WHITE"Terrorist Skill: "COL_LIGHTBLUE"%d \n "COL_WHITE"Total Time Played: "COL_LIGHTBLUE" [%d : %d ] \n", pinfo[id][Robskill], pinfo[id][Hitmanskill], pinfo[id][Terskill],pinfo[id][Hours],pinfo[id][Minutes]);
strcat(str[1],str[4]);
format(str[5],1900,"| ---------------------------------------------------- |");
strcat(str[1],str[5]);
ShowPlayerDialog(playerid,dialog_stats,DIALOG_STYL E_MSGBOX,"Statistics",str[1],"OK","");
return 1;
}
when in press /stats 0 it says unkown cmd

ChandraLouis
04/04/2014, 11:34 AM
CMD:stats(playerid,params[])
{
if(!strlen(params)) player1 = playerid;
else player1 = strval(params);
if(!IsPlayerConnected(id))
{
new str[20][1900];
format(str[0],1900,"| ------ | %s 's Status | ------- | \n", gname);
strcat(str[1],str[0]);
format(str[2],1900,""COL_WHITE"Score: "COL_LIGHTBLUE"%d \n "COL_WHITE"Money: "COL_LIGHTBLUE"$ %d \n"COL_WHITE"Kills: "COL_LIGHTBLUE"%d \n "COL_WHITE"Deaths: "COL_LIGHTBLUE"%d \n", pinfo[id][Score], pinfo[id][Money], pinfo[id][Kills], pinfo[id][Deaths]);
strcat(str[1],str[2]);
format(str[3],1900,""COL_WHITE"Admin Level: "COL_LIGHTBLUE"%d \n"COL_WHITE"VIP Level: "COL_LIGHTBLUE"%d \n "COL_WHITE"Total Robberies: "COL_LIGHTBLUE"%d \n ", pinfo[id][Admin], pinfo[id][VIP], pinfo[id][TotalRobs]);
strcat(str[1],str[3]);
format(str[4],1900,""COL_WHITE"Robbery Skill: "COL_LIGHTBLUE"%d \n, "COL_WHITE"Hitman Skill: "COL_LIGHTBLUE"%d \n,"COL_WHITE"Terrorist Skill: "COL_LIGHTBLUE"%d \n "COL_WHITE"Total Time Played: "COL_LIGHTBLUE" [%d : %d ] \n", pinfo[id][Robskill], pinfo[id][Hitmanskill], pinfo[id][Terskill],pinfo[id][Hours],pinfo[id][Minutes]);
strcat(str[1],str[4]);
format(str[5],1900,"| ---------------------------------------------------- |");
strcat(str[1],str[5]);
ShowPlayerDialog(playerid,dialog_stats,DIALOG_STYL E_MSGBOX,"Statistics",str[1],"OK","");
return 1;
}
else return SCM(playerid, -1, "[ERROR]: Player ID/Name is not valid, Please try /stats [ID]");
}
Try it

EDITED

vassilis
04/04/2014, 11:35 AM
lol so i will use strlen and sscanf...? this is wrong i guess?

ChandraLouis
04/04/2014, 11:37 AM
Edited

vassilis
04/04/2014, 11:41 AM
Edited

How this could be wrong i don't have anything wrong on the sscanf.. :o

ChandraLouis
04/04/2014, 11:48 AM
well, i just took that out from my Server GM

vassilis
04/04/2014, 11:49 AM
Lol could someone help D:

EiresJason
04/04/2014, 11:55 AM
CMD:stats(playerid,params[])
{
new id;

if(sscanf(params,"u",id)) return SendClientMessage(playerid, COLOR_RED," (Error): /stats [id]");
if(!IsPlayerConnected(id)) return ErrorMessages(playerid,2);
new gname[MAX_PLAYER_NAME];
GetPlayerName(id,gname,sizeof(gname));
new dialogstr[1900], string[300]; //increase/decrease the size if you need too.
format(string,sizeof(string),"| ------ | %s 's Status | ------- | \n", gname);
strcat(dialogstr,string);
format(string,sizeof(string)""COL_WHITE"Score: "COL_LIGHTBLUE"%d \n "COL_WHITE"Money: "COL_LIGHTBLUE"$ %d \n"COL_WHITE"Kills: "COL_LIGHTBLUE"%d \n "COL_WHITE"Deaths: "COL_LIGHTBLUE"%d \n", pinfo[id][Score], pinfo[id][Money], pinfo[id][Kills], pinfo[id][Deaths]);
strcat(dialogstr,string);
format(string,sizeof(string),""COL_WHITE"Admin Level: "COL_LIGHTBLUE"%d \n"COL_WHITE"VIP Level: "COL_LIGHTBLUE"%d \n "COL_WHITE"Total Robberies: "COL_LIGHTBLUE"%d \n ", pinfo[id][Admin], pinfo[id][VIP], pinfo[id][TotalRobs]);
strcat(dialogstr,string);
format(string,sizeof(string),""COL_WHITE"Robbery Skill: "COL_LIGHTBLUE"%d \n, "COL_WHITE"Hitman Skill: "COL_LIGHTBLUE"%d \n,"COL_WHITE"Terrorist Skill: "COL_LIGHTBLUE"%d \n "COL_WHITE"Total Time Played: "COL_LIGHTBLUE" [%d : %d ] \n", pinfo[id][Robskill], pinfo[id][Hitmanskill], pinfo[id][Terskill],pinfo[id][Hours],pinfo[id][Minutes]);
strcat(dialogstr,string);
format(string,sizeof(string),"| ---------------------------------------------------- |");
strcat(dialogstr,string);
ShowPlayerDialog(playerid,dialog_stats,DIALOG_STYL E_MSGBOX,"Statistics",dialogstr,"OK","");
return 1;
}

biker122
04/04/2014, 11:56 AM
CMD:stats(playerid,params[])
{
new id;

if(sscanf(params,"u",id)) return SendClientMessage(playerid, COLOR_RED," (Error): /stats [id]");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid,COLOR_RED,"(Error): Player ID is not valid.
new gname[MAX_PLAYER_NAME];
GetPlayerName(id,gname,sizeof(gname));
new str[20][1900];
format(str[0],1900,"| ------ | %s 's Status | ------- | \n", gname);
strcat(str[1],str[0]);
format(str[2],1900,""COL_WHITE"Score: "COL_LIGHTBLUE"%d \n "COL_WHITE"Money: "COL_LIGHTBLUE"$ %d \n"COL_WHITE"Kills: "COL_LIGHTBLUE"%d \n "COL_WHITE"Deaths: "COL_LIGHTBLUE"%d \n", pinfo[id][Score], pinfo[id][Money], pinfo[id][Kills], pinfo[id][Deaths]);
strcat(str[1],str[2]);
format(str[3],1900,""COL_WHITE"Admin Level: "COL_LIGHTBLUE"%d \n"COL_WHITE"VIP Level: "COL_LIGHTBLUE"%d \n "COL_WHITE"Total Robberies: "COL_LIGHTBLUE"%d \n ", pinfo[id][Admin], pinfo[id][VIP], pinfo[id][TotalRobs]);
strcat(str[1],str[3]);
format(str[4],1900,""COL_WHITE"Robbery Skill: "COL_LIGHTBLUE"%d \n, "COL_WHITE"Hitman Skill: "COL_LIGHTBLUE"%d \n,"COL_WHITE"Terrorist Skill: "COL_LIGHTBLUE"%d \n "COL_WHITE"Total Time Played: "COL_LIGHTBLUE" [%d : %d ] \n", pinfo[id][Robskill], pinfo[id][Hitmanskill], pinfo[id][Terskill],pinfo[id][Hours],pinfo[id][Minutes]);
strcat(str[1],str[4]);
format(str[5],1900,"| ---------------------------------------------------- |");
strcat(str[1],str[5]);
ShowPlayerDialog(playerid,dialog_stats,DIALOG_STYL E_MSGBOX,"Statistics",str[1],"OK","");
return 1;
}

Try this :b

vassilis
04/04/2014, 11:58 AM
CMD:stats(playerid,params[])
{
new id;

if(sscanf(params,"u",id)) return SendClientMessage(playerid, COLOR_RED," (Error): /stats [id]");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid,COLOR_RED,"(Error): Player ID is not valid.
new gname[MAX_PLAYER_NAME];
GetPlayerName(id,gname,sizeof(gname));
new str[20][1900];
format(str[0],1900,"| ------ | %s 's Status | ------- | \n", gname);
strcat(str[1],str[0]);
format(str[2],1900,""COL_WHITE"Score: "COL_LIGHTBLUE"%d \n "COL_WHITE"Money: "COL_LIGHTBLUE"$ %d \n"COL_WHITE"Kills: "COL_LIGHTBLUE"%d \n "COL_WHITE"Deaths: "COL_LIGHTBLUE"%d \n", pinfo[id][Score], pinfo[id][Money], pinfo[id][Kills], pinfo[id][Deaths]);
strcat(str[1],str[2]);
format(str[3],1900,""COL_WHITE"Admin Level: "COL_LIGHTBLUE"%d \n"COL_WHITE"VIP Level: "COL_LIGHTBLUE"%d \n "COL_WHITE"Total Robberies: "COL_LIGHTBLUE"%d \n ", pinfo[id][Admin], pinfo[id][VIP], pinfo[id][TotalRobs]);
strcat(str[1],str[3]);
format(str[4],1900,""COL_WHITE"Robbery Skill: "COL_LIGHTBLUE"%d \n, "COL_WHITE"Hitman Skill: "COL_LIGHTBLUE"%d \n,"COL_WHITE"Terrorist Skill: "COL_LIGHTBLUE"%d \n "COL_WHITE"Total Time Played: "COL_LIGHTBLUE" [%d : %d ] \n", pinfo[id][Robskill], pinfo[id][Hitmanskill], pinfo[id][Terskill],pinfo[id][Hours],pinfo[id][Minutes]);
strcat(str[1],str[4]);
format(str[5],1900,"| ---------------------------------------------------- |");
strcat(str[1],str[5]);
ShowPlayerDialog(playerid,dialog_stats,DIALOG_STYL E_MSGBOX,"Statistics",str[1],"OK","");
return 1;
}

Try this :b
I don't think errormessages is the problem//

EiresJason
04/04/2014, 11:59 AM
Try mine.

vassilis
04/04/2014, 12:02 PM
Try mine.

Works thanks so the problem was the double variable! +rep from me :)

Konstantinos
04/04/2014, 12:06 PM
CMD:stats(playerid,params[])
{
new id;

if(sscanf(params, "u", id)) return SendClientMessage(playerid, COLOR_RED, " (Error): /stats [id]");
if(!IsPlayerConnected(id)) return ErrorMessages(playerid, 2);
new gname[MAX_PLAYER_NAME];
GetPlayerName(id, gname, sizeof(gname));
new str[600];
format(str, sizeof (str), "| ------ | %s 's Status | ------- | \n"COL_WHITE"Score: "COL_LIGHTBLUE"%d \n "COL_WHITE"Money: "COL_LIGHTBLUE"$ %d \n"COL_WHITE"Kills: "COL_LIGHTBLUE"%d \n "COL_WHITE"Deaths: "COL_LIGHTBLUE"%d \n", gname, pinfo[id][Score], pinfo[id][Money], pinfo[id][Kills], pinfo[id][Deaths]);
format(str, sizeof (str), "%s"COL_WHITE"Admin Level: "COL_LIGHTBLUE"%d \n"COL_WHITE"VIP Level: "COL_LIGHTBLUE"%d \n "COL_WHITE"Total Robberies: "COL_LIGHTBLUE"%d \n", str, pinfo[id][Admin], pinfo[id][VIP], pinfo[id][TotalRobs]);
format(str, sizeof (str), "%s"COL_WHITE"Robbery Skill: "COL_LIGHTBLUE"%d \n, "COL_WHITE"Hitman Skill: "COL_LIGHTBLUE"%d \n,"COL_WHITE"Terrorist Skill: "COL_LIGHTBLUE"%d \n "COL_WHITE"Total Time Played: "COL_LIGHTBLUE" [%d : %d ] \n", str, pinfo[id][Robskill], pinfo[id][Hitmanskill], pinfo[id][Terskill], pinfo[id][Hours], pinfo[id][Minutes]);
strcat(str, "| ---------------------------------------------------- |", sizeof (str));
ShowPlayerDialog(playerid, dialog_stats, DIALOG_STYLE_MSGBOX, "Statistics", str, "OK", "");
return 1;
}

vassilis
04/04/2014, 12:09 PM
CMD:stats(playerid,params[])
{
new id;

if(sscanf(params, "u", id)) return SendClientMessage(playerid, COLOR_RED, " (Error): /stats [id]");
if(!IsPlayerConnected(id)) return ErrorMessages(playerid, 2);
new gname[MAX_PLAYER_NAME];
GetPlayerName(id, gname, sizeof(gname));
new str[600];
format(str, sizeof (str), "| ------ | %s 's Status | ------- | \n"COL_WHITE"Score: "COL_LIGHTBLUE"%d \n "COL_WHITE"Money: "COL_LIGHTBLUE"$ %d \n"COL_WHITE"Kills: "COL_LIGHTBLUE"%d \n "COL_WHITE"Deaths: "COL_LIGHTBLUE"%d \n", gname, pinfo[id][Score], pinfo[id][Money], pinfo[id][Kills], pinfo[id][Deaths]);
format(str, sizeof (str), "%s"COL_WHITE"Admin Level: "COL_LIGHTBLUE"%d \n"COL_WHITE"VIP Level: "COL_LIGHTBLUE"%d \n "COL_WHITE"Total Robberies: "COL_LIGHTBLUE"%d \n", str, pinfo[id][Admin], pinfo[id][VIP], pinfo[id][TotalRobs]);
format(str, sizeof (str), "%s"COL_WHITE"Robbery Skill: "COL_LIGHTBLUE"%d \n, "COL_WHITE"Hitman Skill: "COL_LIGHTBLUE"%d \n,"COL_WHITE"Terrorist Skill: "COL_LIGHTBLUE"%d \n "COL_WHITE"Total Time Played: "COL_LIGHTBLUE" [%d : %d ] \n", str, pinfo[id][Robskill], pinfo[id][Hitmanskill], pinfo[id][Terskill], pinfo[id][Hours], pinfo[id][Minutes]);
strcat(str, "| ---------------------------------------------------- |", sizeof (str));
ShowPlayerDialog(playerid, dialog_stats, DIALOG_STYLE_MSGBOX, "Statistics", str, "OK", "");
return 1;
}


Ye already changed it to that way since its simpler and more efficient but just forgot to mention it. Thanks anyway. :)

EiresJason
04/04/2014, 12:24 PM
CMD:stats(playerid,params[])
{
new id;

if(sscanf(params, "u", id)) return SendClientMessage(playerid, COLOR_RED, " (Error): /stats [id]");
if(!IsPlayerConnected(id)) return ErrorMessages(playerid, 2);
new gname[MAX_PLAYER_NAME];
GetPlayerName(id, gname, sizeof(gname));
new str[600];
format(str, sizeof (str), "| ------ | %s 's Status | ------- | \n"COL_WHITE"Score: "COL_LIGHTBLUE"%d \n "COL_WHITE"Money: "COL_LIGHTBLUE"$ %d \n"COL_WHITE"Kills: "COL_LIGHTBLUE"%d \n "COL_WHITE"Deaths: "COL_LIGHTBLUE"%d \n", gname, pinfo[id][Score], pinfo[id][Money], pinfo[id][Kills], pinfo[id][Deaths]);
format(str, sizeof (str), "%s"COL_WHITE"Admin Level: "COL_LIGHTBLUE"%d \n"COL_WHITE"VIP Level: "COL_LIGHTBLUE"%d \n "COL_WHITE"Total Robberies: "COL_LIGHTBLUE"%d \n", str, pinfo[id][Admin], pinfo[id][VIP], pinfo[id][TotalRobs]);
format(str, sizeof (str), "%s"COL_WHITE"Robbery Skill: "COL_LIGHTBLUE"%d \n, "COL_WHITE"Hitman Skill: "COL_LIGHTBLUE"%d \n,"COL_WHITE"Terrorist Skill: "COL_LIGHTBLUE"%d \n "COL_WHITE"Total Time Played: "COL_LIGHTBLUE" [%d : %d ] \n", str, pinfo[id][Robskill], pinfo[id][Hitmanskill], pinfo[id][Terskill], pinfo[id][Hours], pinfo[id][Minutes]);
strcat(str, "| ---------------------------------------------------- |", sizeof (str));
ShowPlayerDialog(playerid, dialog_stats, DIALOG_STYLE_MSGBOX, "Statistics", str, "OK", "");
return 1;
}


That wouldn't work properly without strcat would it?

Surely the only part shown would be the "Robbery Skill: ......." and the "!-------------------------------------|" part? XD

Konstantinos
04/04/2014, 12:28 PM
strcat just concatenates 2 strings but why to use an extra function when you can do it with format? If you take a look closer, I insert "str" as argument so the previous text joins together with the new one.

EiresJason
04/04/2014, 12:29 PM
strcat just concatenates 2 strings but why to use an extra function when you can do it with format? If you take a look closer, I insert "str" as argument so the previous text joins together with the new one.

Ooh yeah :D

Nicely done xD