SA-MP Forums Archive
Played time - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Played time (/showthread.php?tid=578310)



Played time - kalanerik99 - 18.06.2015

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


Re: Played time - Gammix - 18.06.2015

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.


Re: Played time - kalanerik99 - 19.06.2015

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


Re: Played time - rappy93 - 19.06.2015

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);




Re: Played time - kalanerik99 - 19.06.2015

Read everything please I told ya!!!


Re: Played time - rappy93 - 19.06.2015

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?


Re: Played time - kalanerik99 - 19.06.2015

Now


Re: Played time - Stanford - 19.06.2015

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!


Re: Played time - Threshold - 19.06.2015

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...


Re: Played time - kalanerik99 - 19.06.2015

Oooh ok thanks