Player Stats Help
#1

whats wrong with this code
Код:
CMD:stats(playerid, params[])
{
    new getstatsid;
    if(!sscanf(params, "u", getstatsid))
	{
	    if(IsPlayerConnected(getstatsid))
	    {
	    	if(IsLoggedIn{getstatsid} == 1)
	    	{
	    	
	    	    new str[500], sho[500];
    	    	new const gAdminLevels[][] = { "No", "Moderator", "Administraotr", "Head Administrator", "Server Owner"};
    	    	
    	    	format(str, sizeof(str), "{FFFFFF}%s statistic\n\n", GetName(getstatsid));
    	    	
				strcat(sho, "Personal Statistic:\n");
				strcat(sho, str, sizeof(sho));
				format(str, sizeof(str), "Administrator:		%s\n", gAdminLevels[PlayerInfo[getstatsid][aLevel]]);
				strcat(sho, str, sizeof(sho));
				format(str, sizeof(str), "VIP Level:		%s\n", PlayerInfo[getstatsid][vLevel]);
				strcat(sho, str, sizeof(sho));
				format(str, sizeof(str), "Money:		$%d\n", GetPlayerCash(getstatsid));
				strcat(sho, str, sizeof(sho));
				format(str, sizeof(str), "Kills:		%d\n", PlayerInfo[getstatsid][pKills]);
				strcat(sho, str, sizeof(sho));
				format(str, sizeof(str), "Deaths:		%d\n\n", PlayerInfo[getstatsid][pDeaths]);
				strcat(sho, str, sizeof(sho));
				
				strcat(sho, "Other Statistic:\n");
				format(str, sizeof(str), "Crimes:       %d\n", PlayerInfo[getstatsid][pCrimes]);
				strcat(sho, str, sizeof(sho));
				format(str, sizeof(str), "Time Fined:       %d\n", PlayerInfo[getstatsid][pFined]);
				strcat(sho, str, sizeof(sho));
				format(str, sizeof(str), "Time Arrest:       %d\n", PlayerInfo[getstatsid][pArrests]);
				strcat(sho, str, sizeof(sho));
				format(str, sizeof(str), "Takedowns:       %d\n", PlayerInfo[getstatsid][pTakedowns]);
				strcat(sho, str, sizeof(sho));
				format(str, sizeof(str), "Issues:       %d\n", PlayerInfo[getstatsid][pTickets]);
				strcat(sho, str, sizeof(sho));
				format(str, sizeof(str), "Joins:       %d\n", PlayerInfo[getstatsid][pJoins]);
				strcat(sho, str, sizeof(sho));
				format(str, sizeof(str), "Materials:       %d\n", PlayerInfo[getstatsid][pMaterials]);
				strcat(sho, str, sizeof(sho));

				ShowPlayerDialog(playerid, 592, DIALOG_STYLE_MSGBOX, "GCNR - Statistic", sho, "Close", "");
            }
            else
            {
                SendClientMessage(playerid, RED, "Player not logged in.");
            }
        }
        else
        {
            SendClientMessage(playerid, RED, "Player not found.");
        }
        return true;
	}
	else
	{
		format(str, sizeof(str), "{FFFFFF}%s statistic\n\n", GetName(getstatsid));

		strcat(sho, "Personal Statistic:\n");
		strcat(sho, str, sizeof(sho));
		format(str, sizeof(str), "Administrator:		%s\n", gAdminLevels[PlayerInfo[playerid][aLevel]]);
		strcat(sho, str, sizeof(sho));
		format(str, sizeof(str), "VIP Level:		%s\n", PlayerInfo[playerid][vLevel]);
		strcat(sho, str, sizeof(sho));
		format(str, sizeof(str), "Money:		$%d\n", GetPlayerCash(playerid));
		strcat(sho, str, sizeof(sho));
		format(str, sizeof(str), "Kills:		%d\n", PlayerInfo[playerid][pKills]);
		strcat(sho, str, sizeof(sho));
		format(str, sizeof(str), "Deaths:		%d\n\n", PlayerInfo[playerid][pDeaths]);
		strcat(sho, str, sizeof(sho));

		strcat(sho, "Other Statistic:\n");
		format(str, sizeof(str), "Crimes:       %d\n", PlayerInfo[playerid][pCrimes]);
		strcat(sho, str, sizeof(sho));
		format(str, sizeof(str), "Time Fined:       %d\n", PlayerInfo[playerid][pFined]);
		strcat(sho, str, sizeof(sho));
		format(str, sizeof(str), "Time Arrest:       %d\n", PlayerInfo[playerid][pArrests]);
		strcat(sho, str, sizeof(sho));
		format(str, sizeof(str), "Takedowns:       %d\n", PlayerInfo[playerid][pTakedowns]);
		strcat(sho, str, sizeof(sho));
		format(str, sizeof(str), "Issues:       %d\n", PlayerInfo[playerid][pTickets]);
		strcat(sho, str, sizeof(sho));
		format(str, sizeof(str), "Joins:       %d\n", PlayerInfo[playerid][pJoins]);
		strcat(sho, str, sizeof(sho));
		format(str, sizeof(str), "Materials:       %d\n", PlayerInfo[playerid][pMaterials]);
		strcat(sho, str, sizeof(sho));

		ShowPlayerDialog(playerid, 593, DIALOG_STYLE_MSGBOX, "GCNR - Statistic", sho, "Close", "");
	}
	return true;
}
when i type /stats its force close the sampserver.exe and shutdown the server,... please help
Reply
#2

help
Reply
#3

Instead of using strcat, which is more than likely what is crashing your server, you should use format and sendclientmessage.
Reply
#4

And please don't double post or bump before 24 hrs or you get warning
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)