22.02.2015, 18:09
You don't even need a timer for this at all. Check out Unix timestamps. Tutorial somewhere in the tutorial section. You save a Unix timestamp when they login. When they disconnect you subtract the value you saved earlier from the current timestamp. This will give you a value in seconds which can easily be converted to hours and minutes when needed. Ergo, you don't need the 'Hour' and 'Min' variables either.
pawn Код:
stock sec_to_time(input_seconds, &hours, &minutes, &seconds)
{
hours = input_seconds / 3600; // int divided by int is int
input_seconds -= (hours * 3600);
minutes = input_seconds / 60;
input_seconds -= (minutes * 60);
seconds = input_seconds;
}
pawn Код:
// e.g.:
new
hours,
minutes,
seconds;
sec_to_time(4512, hours, minutes, seconds);
// hours = 1, minutes = 15, seconds = 12