[SOLVED] Problem with /stats [ID]
#1

Little problem again. I dunno how to fix the problem that I only can see my stats. I want to see the stats from other players.
I also donґt know how to add that I must use /stats [ID] when I type something wrong.

Код:
dcmd_stats(playerid, params[])
{
	new pName[24], PlayerFile[50], str[128], pDeaths[50], pKills[50], pMoney[50];

	GetPlayerName(playerid, pName, sizeof(pName));
 	format(PlayerFile, sizeof(PlayerFile), "/users/%s.ini", pName);

	if(!dini_Exists(PlayerFile)) return SendClientMessage(playerid, COLOR_BRIGHTRED, "ERROR: You aren't registered! Use /register to create an account.");

	if(dini_Exists(PlayerFile))
	{
	 	pDeaths[24] = dini_Int(PlayerFile, "Deaths");
	 	pKills[24] = dini_Int(PlayerFile, "Kills");
	 	pMoney[24] = dini_Int(PlayerFile, "Money");
	 	new Float:Ratio=floatdiv(pKills[24], pDeaths[24]);
	 	format(str, sizeof(str), "				  ||%sґs Statistics ||", pName);
	 	SendClientMessage(playerid, COLOR_WHITE, str);
	 	format(str, sizeof(str), "(Money): Money: %d", pMoney[24]);
		SendClientMessage(playerid, COLOR_WHITE, str);
		format(str, sizeof(str), "(Stats): Kills: %d || Deaths: %d || Ratio: %.2f || Money: %d", pKills[24], pDeaths[24], Ratio, pMoney[24]);
		SendClientMessage(playerid, COLOR_WHITE, str);

		if(PlayerInfo[playerid][AdminLevel] == 0)
		{
			SendClientMessage(playerid, COLOR_WHITE, "You are a player on the server.");
		}
		if(PlayerInfo[playerid][AdminLevel] == 1)
		{
			SendClientMessage(playerid, COLOR_WHITE, "You are a Administrator Level 1 on the server.");
		}
		if(PlayerInfo[playerid][AdminLevel] == 2)
		{
			SendClientMessage(playerid, COLOR_WHITE, "You are an Administrator Level 2 on the server.");
		}
		if(PlayerInfo[playerid][AdminLevel] == 3)
		{
			SendClientMessage(playerid, COLOR_WHITE, "You are a Administrator Level 3 on the server.");
		}
	}
	#pragma unused params
	return 1;
}
Well, it seems easy I know. I only canґt find it. Maybe I am to tired
Reply
#2

Код:
dcmd_stats(playerid, params[])
{
	new pName[24], PlayerFile[50], str[128], pDeaths[50], pKills[50], pMoney[50],targetid;
       
       if(!strlen(params)) targetid = playerid;
	else targetid = strval(params);
 	GetPlayerName(targetid, pName, sizeof(pName));
 	format(PlayerFile, sizeof(PlayerFile), "/users/%s.ini", pName);

	if(!dini_Exists(PlayerFile)) return SendClientMessage(playerid, COLOR_BRIGHTRED, "ERROR: You aren't registered! Use /register to create an account.");

	if(dini_Exists(PlayerFile))
	{
	 	pDeaths[24] = dini_Int(PlayerFile, "Deaths");
	 	pKills[24] = dini_Int(PlayerFile, "Kills");
	 	pMoney[24] = dini_Int(PlayerFile, "Money");
	 	new Float:Ratio=floatdiv(pKills[24], pDeaths[24]);
	 	format(str, sizeof(str), "				 ||%sґs Statistics ||", pName);
	 	SendClientMessage(playerid, COLOR_WHITE, str);
	 	format(str, sizeof(str), "(Money): Money: %d", pMoney[24]);
		SendClientMessage(playerid, COLOR_WHITE, str);
		format(str, sizeof(str), "(Stats): Kills: %d || Deaths: %d || Ratio: %.2f || Money: %d", pKills[24], pDeaths[24], Ratio, pMoney[24]);
		SendClientMessage(playerid, COLOR_WHITE, str);

		if(PlayerInfo[targetid][AdminLevel] == 0)
		{
                if(targetid==playerid) 
                {SendClientMessage(playerid, COLOR_WHITE, "You are a player on the server.");
                }
                else SendClientMessage(playerid,0xffffffaa,"This player is a player on the server");
		}
		if(PlayerInfo[tagetid][AdminLevel] == 1)
		{
			 if(targetid==playerid) 
                {SendClientMessage(playerid, COLOR_WHITE, "You are an Administrator Level 1 on the server.");
                }
                else SenClientMessage(playerid,0xffffffaa,"This player is an Administrator Level 1 on the server");
		}
		if(PlayerInfo[targetid][AdminLevel] == 2)
		{
			 if(targetid==playerid) 
                {SendClientMessage(playerid, COLOR_WHITE, "You are an Administrator Level 2 on the server.");
                }
                else SenClientMessage(playerid,0xffffffaa,"This player is an Administrator Level 2 on the server");
		}
		if(PlayerInfo[targetid][AdminLevel] == 3)
		{
			 if(targetid==playerid) 
                {SendClientMessage(playerid, COLOR_WHITE, "You are an Administrator Level 3 on the server.");
                }
                else SenClientMessage(playerid,0xffffffaa,"This player is an Administrator Level 3 on the server");
		}
	}

	#pragma unused params
	return 1;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)