SA-MP Forums Archive
/stats - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: /stats (/showthread.php?tid=238181)



/stats - Markx - 11.03.2011

Hello all.

Where can i get a command (/stats) that will show the players hours on server, deaths, kill, score, Admin level, please?

-I searched on ****** but cant find it :/


Re: /stats - Ironboy - 11.03.2011

try this
pawn Код:
if(strcmp(cmd, "/stats", true) == 0)     {
        new player1, tmp[256];
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))    {
            ShowScore(playerid);
            return 1;   }
        player1 = strval(tmp);

        if(IsPlayerConnected(player1))      {
            GetPlayerName(player1, playername, sizeof(playername));
            format(string, sizeof(string), "<> %s's Stats:  Kills: %d | Deaths: %d | Ratio: %0.2f | Money: $%d ",playername, PlayerInfo[player1][Kills], PlayerInfo[player1][Deaths],Float:PlayerInfo[player1][Deaths]/Float:PlayerInfo[player1][Deaths],GetPlayerMoney(player1));
            SendClientMessage(playerid, green, string);
            return 1;
        } else {
        SendClientMessage(playerid, COLOR_WHITE, "Player Not Connected!");
        return 1;   }
     }



Re: /stats - Montis123 - 11.03.2011

pawn Код:
CMD:stats(playerid,params[])
{
new string[128];
new Float:health;
GetPlayerHealth(playerid,health);
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
format(string,128,"|STATS| Name:[%s] Money:[%d] Score:[%d] Health:[%d]",pName,GetPlayerMoney(playerid),GetPlayerScore(playerid),health);
SendClientMessage(playerid,0x00A300AA,string);
return 1;
}



Re: /stats - Ironboy - 11.03.2011

did you define anything? or


Re: /stats - Markx - 11.03.2011

Thanks, how can i make it save hours? Using y_ini

-i need to make it save to a file..

Im using Zcmd btw


Re: /stats - Markx - 11.03.2011

Quote:
Originally Posted by ******
Посмотреть сообщение
Ironboy: Your code makes huge numbers of assumptions about what there is in the script, Montis123's makes none and is thus a much better example! What is "ShowScore" in your code and how is it defined? Where and how is PlayerInfo defined? (I ask because it's a TERRIBLE name for a global variable!) Why is your green colour a variable (or why does it look like a variable)? "Float:PlayerInfo[player1][Deaths]/Float:PlayerInfo[player1][Deaths]" <- always 1! Finally why are you not using sscanf to get another player given that it allows you to type an ID or a name instead of just an ID?

Markx: To get online time use getdate in OnPlayerConnect and OnPlayerDisconnect. This will return a unix timestamp and you add the difference between join and leave to a saved running total.
Oh wow, i will try to make something
-Thanks for help

WIKI:
Код:
new Year, Month, Day;
getdate(Year, Month, Day);
printf("%02d/%02d/%d", Day, Month, Year);
 
new Days = getdate();
printf("Days since the start of the year: %d", Days)
How to make it days, hours, minutes?


Re: /stats - Markx - 11.03.2011

*bump* Anyone?


Re: /stats - Ironboy - 11.03.2011

i took that cmd from my gm and i thought that will help him


Re: /stats - Markx - 11.03.2011

Quote:
Originally Posted by Ironboy
Посмотреть сообщение
i took that cmd from my gm and i thought that will help him
It is good, but i need it to save when a player disconnects, and load it when he connects


Re: /stats - Zh3r0 - 11.03.2011

Quote:
Originally Posted by Markx
Посмотреть сообщение
It is good, but i need it to save when a player disconnects, and load it when he connects
The easiest way is to look in an Admin script that saves online time.