Played time
#1

Hello
I have been surfing around sa-mp wiki and found one function

PHP код:
NetStats_GetConnectedTime 
How can I use that at my saving played time on server
I use playtime in hours(ex:PTScore:1(Hours)).
How to make that every hour it will add player PTScore +1 (or can I reset the time?)
(or do I have to do like:

PHP код:
new time NetStats_GetConnectedTime 1000;
If(
time == 3600000 || 7200000....) 
No timers PLEASE
Reply
#2

This function converts the player's connected time from milli seconds to human readable format (horus, minutes and seconds).
pawn Код:
stock GetPlayerConnectedTime(playerid, &hours, &minutes, &seconds)
{
        new connected_time = NetStats_GetConnectedTime(playerid);
        seconds = (connected_time / 1000) % 60;
        minutes = (connected_time / (1000 * 60)) % 60;
        hours = (connected_time / (1000 * 60 * 60));
        return true;
}
Snippet from Players Library.
Reply
#3

How to make that it will update when playing?
Read everything in my first post (start post)
Reply
#4

I think this should work.

PHP код:
stock GetPlayerConnectedTime(playerid, &hours, &minutes, &seconds)
{
        new 
connected_time NetStats_GetConnectedTime(playerid);
        
seconds = (connected_time 1000) % 60;
        
minutes = (connected_time / (1000 60)) % 60;
        
hours = (connected_time / (1000 60 60));
        return 
true;
}

CMD:Example(params, []) // Just an example,. the syntax is wrong so just use your own command
{
    new 
hoursminutesseconds;
    new 
string[64];
    
GetPlayerConnectedTime(playeridhoursminutesseconds);
    
format(stringsizeof(string), "You've been online for : %d Hours, %d Minutes and %d Seconds!"hoursminutesseconds);
    
SendClientMessage(playerid, -1string);

Reply
#5

Read everything please I told ya!!!
Reply
#6

I can't really understand because of the way you write, can you please rephrase the initial post so we can understand better what you want to do exactly?
Reply
#7

Now
Reply
#8

So you basically define variables and put values in them using this function that Gammix provided:
pawn Код:
GetPlayerConnectedTime(playerid, &hours, &minutes, &seconds);
If you were online for 1 hours and 23 minutes and 40 seconds you can format a string and tell the player about it!
Reply
#9

Quote:

How to make that every hour it will add player PTScore +1

You need a timer for this... or you can just re-calculate the online time when someone requests it...
Reply
#10

Oooh ok thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)