Not working properly?
#1

Hey guys. I have a system the records the players TOTAL time in game. However some reason it's doubling or something I'm not sure.

I've been in my server for probably around 4 hours? Maybe more maybe less but somewhere around there and I use this function to see how many hours i've played. Server says 20 hours.
Here is my code.
PHP код:
TotalGameTime(playerid, &h=0, &m=0, &s=0)
{
    
PlayerInfo[playerid][PlayedHours] = PlayerInfo[playerid][TotalTime];
    
PlayerInfo[playerid][TotalTime] = ( (gettime() - gPlayerJoin[playerid]) + (PlayerInfo[playerid][PlayedHours]) );
    
floatround(PlayerInfo[playerid][TotalTime] / 3600floatround_floor);
    
floatround(PlayerInfo[playerid][TotalTime] / 60,   floatround_floor) % 60;
    
floatround(PlayerInfo[playerid][TotalTime] % 60,   floatround_floor);
    return 
PlayerInfo[playerid][TotalTime];

I will explain everything that is here.

I think the error is in PlayerInfo[playerid][PlayedHours] = PlayerInfo[playerid][TotalTime]; I use this because I need to somehow get the existing time of the player before I save the new connection time.

The next line is getting the time as the player disconnects and then minus the time of when the player connected. Then plus the already existing time.
Reply


Messages In This Thread
Not working properly? - by Tass007 - 27.09.2016, 01:13
Re: Not working properly? - by HoangNam - 27.09.2016, 03:46
Re: Not working properly? - by Tass007 - 27.09.2016, 04:39
Re: Not working properly? - by iLearner - 27.09.2016, 05:49
Re: Not working properly? - by Dayrion - 27.09.2016, 05:52
Re: Not working properly? - by Tass007 - 27.09.2016, 06:04
Re: Not working properly? - by iLearner - 27.09.2016, 06:38
Re: Not working properly? - by Tass007 - 27.09.2016, 06:53
Re: Not working properly? - by iLearner - 27.09.2016, 07:18
Re: Not working properly? - by justjamie - 27.09.2016, 11:37

Forum Jump:


Users browsing this thread: 1 Guest(s)