Time on Server
#1

Hello All

I have a code:
Код:
public OnPlayerConnect(playerid)
{
  PlayerInfo[playerid][PTScore] = GetTickCount();
  return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
  PlayerInfo[playerid][PTScore] = GetTickCount() - PlayerInfo[playerid][PTScore];
}
How to make that it will update PTScore when playing the server
PTSCORE is playtime score (IN HOURS) (I need it in hours)
NO TIMERS !!!!!
Reply
#2

Use gettime instead. Returns the value in seconds and is more reliable.

pawn Код:
stock sec_to_time(timestamp, &hours, &minutes, &seconds)
{
    hours = timestamp / 3600; // int divided by int is int
    timestamp -= (hours * 3600);
   
    minutes = timestamp / 60;
    timestamp -= (minutes * 60);
   
    seconds = timestamp;
}
Reply
#3

#Vince can you show me a look of it !
(gettime....)
Reply
#4

Код:
public OnPlayerConnect(playerid)
{
	PlayerInfo[playerid][PTScore] = 0;
	PlayerInfo[playerid][TimePlayedLastLogin] = gettime();
  return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
	new current_time = gettime();
	current_time -= PlayerInfo[playerid][TimePlayedLastLogin];
	PlayerInfo[playerid][PTScore] += current_time/3600; // 3600 seconds = 60 minutes = 1 hour 
}
Untested!
Reply
#5

I will be saving PTScore And I want that it will refresh when player is playing on the server
Reply
#6

Not sure what you meant but this what I got.

pawn Код:
PlayerInfo[playerid][PTScore] = current_time/3600; // Sets the hours not increases the variable.
Reply
#7

OK Thanks And I will put it where I have to refresh stats ?
Reply
#8

I really don't understand you, you want to save the stats or what?

Elaborate please.
Reply
#9

Yea and that it will refresh them
Reply
#10

Use the magical button which leads you to the depths of the shadow realm, the "Search" button and find some saving systems.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)