/stats
#1

Код:
format( str, sizeof( str ), "{E60000}%s{00FF00}'s Stats:\n\n\
							     {E60000}* {00FF00}Kills: {33CCFF}%d\n\
							     {E60000}* {00FF00}Deaths: {33CCFF}%d\n\
							     {E60000}* {00FF00}Ratio: {33CCFF}%0.2f\n\
							     {E60000}* {00FF00}Moneys: {33CCFF}%d{00FF00} $\n\
							     {E60000}* {00FF00}Score: {33CCFF}%d\n", PlayerName( Player ), PlayerInfo[ Player ][ Kills ], PlayerInfo[ Player ][ Deaths ], Float:PlayerInfo[ Player ][ Kills ]/Float:pDeaths, GetPlayerMoney( Player ), GetPlayerScore( Player ) );
	format( str2, sizeof( str2 ), "%s{E60000}* {00FF00}Online Time: {33CCFF}%d {00FF00}Hrs | {33CCFF}%d {00FF00}Min | {33CCFF}%d {00FF00}Sec\n\
								     {E60000}* {00FF00}Coins: {33CCFF}%d\n\
							   	     {E60000}* {00FF00}Race Score: {33CCFF}%d\n\
								     {E60000}* {00FF00}DeathMatch Score: {33CCFF}%d\n\
							   	     {E60000}* {00FF00}Level: {33CCFF}%d\n", str, h, m, s, PlayerInfo[ Player ][ Coins ], PlayerInfo[ Player ][ DeathMatch ], PlayerInfo[ Player ][ RaceScore ], PlayerInfo[ Player ][ Level ] );
	format( str3, sizeof( str3 ), "%s{E60000}* {00FF00}V.I.P: {33CCFF}%s {00FF00}- Level: {33CCFF}%d\n\
									 {E60000}* {00FF00}R.VIP: {33CCFF}%s\n\
							   	     {E60000}* {00FF00}Logged: {33CCFF}%s\n\
		 						     {E60000}* {00FF00}Warnings: {33CCFF}%d\n", str2, P1Vip, PlayerInfo[ Player ][ pVip ], P1Rvip, P1Logged, PlayerInfo[ Player ][ Warnings ] );
    format( str4, sizeof( str4 ), "%s{E60000}* {00FF00}Rank: {E60000}%s {00FF00}(Rank: {33CCFF}%d{00FF00})\n\
								     {E60000}* {00FF00}Respect: {33CCFF}-%d{00FF00}/{33CCFF}+%d\n\
									 {E60000}* {00FF00}SAdmin: {33CCFF}%s\n\
							 		 {E60000}* {00FF00}Drugs: {33CCFF}%d", str3, rank, rankid, PlayerInfo[ Player ][ NegRespect ], PlayerInfo[ Player ][ PosRespect ], P1SAdmin, PlayerInfo[ playerid ][ Drugs ] );
	ShowPlayerDialog( playerid, SStats, DIALOG_STYLE_MSGBOX, "Stats:", str4, "Cancel", "" );
This is the dialog for statistics on a player, everything works fine, but is a problem on "Hours", "Minutes", "Secound", on that is needed to show player online time, but when i type /stats [PlayerID] when the dialog show, it shows me 3557 hours. This problem is just when i put my server on a host... on PC works fine 8-|

Any ideas what she don't work?
Reply
#2

what about providing us with the definition of the h m s variables and the gettime code you used?
Reply
#3

WTF Is wrong with that code?
Reply
#4

other question... why the f*ck are you posting in this topic if you have no clue?..
Your post basicly just repeated the intention of edvin, to get a solution... So try to reply in a helpful way, or just don't reply if you don't know anything about it...
Reply
#5

This is full comand:
pawn Код:
CMD:stats( PARAMS )
{
    new str[ 1024 ], str2[ 1024 ], str3[ 1024 ], str4[ 2048 ], pDeaths, Player, h, m, s, rank[ 50 ], P1Logged[ 4 ], P1Rvip[ 4 ], P1Vip[ 4 ], rankid = PlayerInfo[ playerid ][ Rank ], P1SAdmin[ 4 ];
   
    if ( !strlen( params ) ) Player = playerid;
    else Player = strval( params );
    if ( !IsPlayerConnected( Player ) ) return SendClientMessage( playerid, COLOR_ULTRARED, "ERROR: Player not connected" );

    TotalGameTime( Player, h, m, s );
    if ( PlayerInfo[ Player ][ Deaths ] == 0 ) pDeaths = 1; else pDeaths = PlayerInfo[ Player ][ Deaths ];
    if ( PlayerInfo[ Player ][ LoggedIn ] == 1 ) P1Logged = "Yes"; else P1Logged = "No";
    if ( PlayerInfo[ Player ][ rVip ] == 1 ) P1Rvip = "Yes"; else P1Rvip = "No";
    if ( PlayerInfo[ Player ][ pVip ] >= 1 ) P1Vip = "Yes"; else P1Vip = "No";
    if ( PlayerInfo[ Player ][ SAdmin ] == 1 ) P1SAdmin = "Yes"; else P1SAdmin = "No";
    if ( PlayerInfo[ Player ][ Rank ] == 0 ) { rank = "Looser"; }
    else if ( PlayerInfo[ Player ][ Rank ] == 1 ) { rank = "Easy Killa'"; }
    else if ( PlayerInfo[ Player ][ Rank ] == 2 ) { rank = "Baby Killer"; }
    else if ( PlayerInfo[ Player ][ Rank ] == 3 ) { rank = "e-Gangsta"; }
    else if ( PlayerInfo[ Player ][ Rank ] == 4 ) { rank = "Boss"; }
    else if ( PlayerInfo[ Player ][ Rank ] == 5 ) { rank = "Lil' Psycho"; }
    else if ( PlayerInfo[ Player ][ Rank ] == 6 ) { rank = "Psycho"; }
    else if ( PlayerInfo[ Player ][ Rank ] == 7 ) { rank = "Unstopable"; }
    else if ( PlayerInfo[ Player ][ Rank ] == 8 ) { rank = "Elite Killer"; }
    else if ( PlayerInfo[ Player ][ Rank ] == 9 ) { rank = "Godlike killer!"; }
    else if ( PlayerInfo[ Player ][ Rank ] == 10 ) { rank = "INSANE KILLER"; }
    else if ( PlayerInfo[ Player ][ Rank ] == 11 ) { rank = "The God of Deathmatch"; }

    format( str, sizeof( str ), "{E60000}%s{00FF00}'s Stats:\n\n\
                                 {E60000}* {00FF00}Kills: {33CCFF}%d\n\
                                 {E60000}* {00FF00}Deaths: {33CCFF}%d\n\
                                 {E60000}* {00FF00}Ratio: {33CCFF}%0.2f\n\
                                 {E60000}* {00FF00}Moneys: {33CCFF}%d{00FF00} $\n\
                                 {E60000}* {00FF00}Score: {33CCFF}%d\n"
, PlayerName( Player ), PlayerInfo[ Player ][ Kills ], PlayerInfo[ Player ][ Deaths ], Float:PlayerInfo[ Player ][ Kills ]/Float:pDeaths, GetPlayerMoney( Player ), GetPlayerScore( Player ) );
    format( str2, sizeof( str2 ), "%s{E60000}* {00FF00}Online Time: {33CCFF}%d {00FF00}Hrs | {33CCFF}%d {00FF00}Min | {33CCFF}%d {00FF00}Sec\n\
                                     {E60000}* {00FF00}Coins: {33CCFF}%d\n\
                                     {E60000}* {00FF00}Race Score: {33CCFF}%d\n\
                                     {E60000}* {00FF00}DeathMatch Score: {33CCFF}%d\n\
                                     {E60000}* {00FF00}Level: {33CCFF}%d\n"
, str, h, m, s, PlayerInfo[ Player ][ Coins ], PlayerInfo[ Player ][ RaceScore ], PlayerInfo[ Player ][ DeathMatch ], PlayerInfo[ Player ][ Level ] );
    format( str3, sizeof( str3 ), "%s{E60000}* {00FF00}V.I.P: {33CCFF}%s {00FF00}- Level: {33CCFF}%d\n\
                                     {E60000}* {00FF00}R.VIP: {33CCFF}%s\n\
                                     {E60000}* {00FF00}Logged: {33CCFF}%s\n\
                                     {E60000}* {00FF00}Warnings: {33CCFF}%d/3\n"
, str2, P1Vip, PlayerInfo[ Player ][ pVip ], P1Rvip, P1Logged, PlayerInfo[ Player ][ Warnings ] );
    format( str4, sizeof( str4 ), "%s{E60000}* {00FF00}Rank: {E60000}%s {00FF00}(Rank: {33CCFF}%d{00FF00})\n\
                                     {E60000}* {00FF00}Respect: {33CCFF}-%d{00FF00}/{33CCFF}+%d\n\
                                     {E60000}* {00FF00}SAdmin: {33CCFF}%s\n\
                                     {E60000}* {00FF00}Drugs: {33CCFF}%d"
, str3, rank, rankid, PlayerInfo[ Player ][ NegRespect ], PlayerInfo[ Player ][ PosRespect ], P1SAdmin, PlayerInfo[ playerid ][ Drugs ] );
    ShowPlayerDialog( playerid, SStats, DIALOG_STYLE_MSGBOX, "Stats:", str4, "Cancel", "" );
    return 1;
}
And the function TotalGameTime is this:
pawn Код:
TotalGameTime(playerid, &h=0, &m=0, &s=0)
{
    PlayerInfo[playerid][TotalTime] = ( (gettime() - PlayerInfo[playerid][ConnectTime]) + (PlayerInfo[playerid][hours]*60*60) + (PlayerInfo[playerid][mins]*60) + (PlayerInfo[playerid][secs]) );

    h = floatround(PlayerInfo[playerid][TotalTime] / 3600, floatround_floor);
    m = floatround(PlayerInfo[playerid][TotalTime] / 60,   floatround_floor) % 60;
    s = floatround(PlayerInfo[playerid][TotalTime] % 60,   floatround_floor);

    return PlayerInfo[playerid][TotalTime];
}
I not edited at this function anything, is just basic of the Ladmin ^^
Reply
#6

BUMP UP!
Reply
#7

Well here's an example that might help you:

pawn Код:
enum pInfo { //
    Seconds,
    Minutes,
    Hours,
}
PlayerInfo Variable:
pawn Код:
new PlayerInfo[MAX_PLAYERS][pInfo];
OnPlayerConnect or OnPlayerSpawn:
pawn Код:
SetTimerEx("GameTime",1000,1,"i",playerid); // Player Total Online Time every one second, seconds = + 1
pawn Код:
forward GameTime(playerid);
public GameTime(playerid) {
    PlayerInfo[playerid][Seconds]++; // When GameTime is being called, seconds are updated +1
    if(PlayerInfo[playerid][Seconds] == 60) { // If the total seconds = 60
        PlayerInfo[playerid][Minutes]++; // + 1 minute
        PlayerInfo[playerid][Seconds] = 0; // reset seconds to 0
    }
    if(PlayerInfo[playerid][Minutes] == 60) { // If the total minutes = 60
        PlayerInfo[playerid][Hours]++; // + 1 hour
        PlayerInfo[playerid][Minutes] = 0; // reset minutes to 0
        PlayerInfo[playerid][Seconds] = 0; // reset minutes to 0
    }
    return 1;
}
If you wanted to put it into a /stats command (ZCMD & sscanf):

pawn Код:
CMD:stats(playerid, params[]) {
    new id;
    if(sscanf(params,"d",id)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /stats [id]");
    if (!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, "ERROR: Player is not connected.");
    format(szString, sizeof(szString), "* Total Online Time: %i hours, %i minutes, and %i seconds", PlayerInfo[id][Hours], PlayerInfo[id][Minutes], PlayerInfo[id][Seconds]);
    SendClientMessage(playerid, COLOR_YELLOW, szString);
    return 1;
}
Reply
#8

@dr.pepper i don't need to save the hours. It's all saved because i use LAdmin4v2 ... i putted the LAdmin in my gamemode and make /stats in dialog. And the hours appear 3557 ...
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)