Code not working
#5

You can do it even without a timer. Just get the timestamp when player joins and whenever you need the time you get the current timestamp, subtract the joined timestamp. It will get you the amount of milliseconds the player has played, then you can convert it to hours, minutes and seconds:

pawn Код:
public OnPlayerConnect(playerid)
{
    PlayerInfo[playerid][TimeJoined] = tickcount();
    return 1;
}

CMD:timeplayed(playerid,params[])
{
    new String[32], TimeOnline, Hours, Minutes, Seconds;
    TimeOnline = (tickcount() - PlayerInfo[playerid][TimeJoined])/1000;
    Minutes = TimeOnline/60; Seconds = TimeOnline%60;
    Hours = Minutes/60; Minutes = Minutes%60;
    format(String,sizeof(String),"Time played: %d:%02d:%02d", Hours, Minutes, Seconds);
    SendClientMessage(playerid,RED,String);
    return 1;
}
Reply


Messages In This Thread
Code not working - by Gaurav_Rawat - 20.01.2015, 15:31
Re: Code not working - by Schneider - 20.01.2015, 15:39
Re: Code not working - by xVIP3Rx - 20.01.2015, 15:45
Re: Code not working - by Gaurav_Rawat - 20.01.2015, 16:04
Re: Code not working - by Schneider - 20.01.2015, 16:05
Re: Code not working - by xVIP3Rx - 20.01.2015, 16:09
Re: Code not working - by Gaurav_Rawat - 20.01.2015, 16:20
Re: Code not working - by Schneider - 20.01.2015, 16:24
Re: Code not working - by xVIP3Rx - 20.01.2015, 16:27
Re: Code not working - by Gaurav_Rawat - 20.01.2015, 16:27

Forum Jump:


Users browsing this thread: 1 Guest(s)