Help with dcmd_stats
#1

Hello again,

I have a little problem with my /stats command. I use dcmd for it and I want to change some things.

Код:
dcmd_stats(playerid, params[])
{
	new pName[24], PlayerFile[50], str[128], pDeaths[50], pKills[50];
	
	GetPlayerName(playerid, pName, sizeof(pName));
 	format(PlayerFile, sizeof(PlayerFile), "/users/%s.ini", pName);
 	
	if(!dini_Exists(PlayerFile)) return SendClientMessage(playerid, COLOR_BRIGHTRED, "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");
	  	new Float:Ratio=floatdiv(pKills[24], pDeaths[24]);
		format(str, sizeof(str), "You have died %d times and killed somebody %d times. That makes your ratio %.2f .", pDeaths[24], pKills[24], Ratio);
		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 moderator on the server.");
		}
		if(PlayerInfo[playerid][AdminLevel] == 2)
		{
			SendClientMessage(playerid, COLOR_WHITE, "You are an administrator on the server.");
		}
		if(PlayerInfo[playerid][AdminLevel] == 3)
		{
			SendClientMessage(playerid, COLOR_WHITE, "You are a management member on the server.");
		}
	}
	#pragma unused params
	return 1;
}
So, as you can see when I type /stats it shows me "You have died xy times and you have killed..." So in this way it is very confusing and I wanna change it in this way:


Kills: xy | Deaths; xy | Ratio: xy


For those guys who think I am to lazy to do it: I really donґt know how >.> I get errors and nothings results.

So, try to help
Reply
#2

pawn Код:
dcmd_stats(playerid, params[])
{
    new pName[24], PlayerFile[50], str[128], pDeaths[50], pKills[50];
   
    GetPlayerName(playerid, pName, sizeof(pName));
    format(PlayerFile, sizeof(PlayerFile), "/users/%s.ini", pName);
   
    if(!dini_Exists(PlayerFile)) return SendClientMessage(playerid, COLOR_BRIGHTRED, "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");
        new Float:Ratio=floatdiv(pKills[24], pDeaths[24]);
        format(str, sizeof(str), "Deaths: %d || Kills: %d || Ratio: %.2f", pDeaths[24], pKills[24], Ratio);
        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 moderator on the server.");
        }
        if(PlayerInfo[playerid][AdminLevel] == 2)
        {
            SendClientMessage(playerid, COLOR_WHITE, "You are an administrator on the server.");
        }
        if(PlayerInfo[playerid][AdminLevel] == 3)
        {
            SendClientMessage(playerid, COLOR_WHITE, "You are a management member on the server.");
        }
    }
    #pragma unused params
    return 1;
}
I think that work.
What are the error messages?
Reply
#3

I correct you Ratio must be "%.2f" not "2f"

But it works when I change this

Now I want to add a little line on top when you type /stats.

The line should be like that: || [myname] Statistics ||


Can someone do that or give me a advice?
Reply
#4

pawn Код:
dcmd_stats(playerid, params[])
{
    new pName[24], PlayerFile[50], str[128], pDeaths[50], pKills[50];
   
    GetPlayerName(playerid, pName, sizeof(pName));
    format(PlayerFile, sizeof(PlayerFile), "/users/%s.ini", pName);
   
    if(!dini_Exists(PlayerFile)) return SendClientMessage(playerid, COLOR_BRIGHTRED, "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");
        new Float:Ratio=floatdiv(pKills[24], pDeaths[24]);
        GetPlayerName(playerid, pName, sizeof(pName));
        format(string, sizeof(str), "|| % Statistics ||", pName);
        format(str, sizeof(str), "Deaths: %d || Kills: %d || Ratio: %.2f", pDeaths[24], pKills[24], Ratio);
        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 moderator on the server.");
        }
        if(PlayerInfo[playerid][AdminLevel] == 2)
        {
            SendClientMessage(playerid, COLOR_WHITE, "You are an administrator on the server.");
        }
        if(PlayerInfo[playerid][AdminLevel] == 3)
        {
            SendClientMessage(playerid, COLOR_WHITE, "You are a management member on the server.");
        }
    }
    #pragma unused params
    return 1;
}
That should work
Reply
#5

Oh thanks for your help but I already fix it in the same way as you
Thanks you, you helped!
Reply
#6

Why i get this warning?

C:\Documents and Settings\lenovo\Desktop\HTM\gamemodes\SaAdmin.pwn( 6633) : warning 203: symbol is never used: "dcmd_stats"

Help me please
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)