SA-MP Forums Archive
Time played - 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: Time played (/showthread.php?tid=508340)



Time played - Ananisiki - 21.04.2014

I wonder how i can add days played in stats?

Every 24 minutes will be one day in game, how i do


Re: Time played - AroseKhanNiazi - 21.04.2014

ananisiki soon i am doing it so i will give it too u too


Re: Time played - Ananisiki - 21.04.2014

Need it now friend... :/


Re: Time played - OsteeN - 21.04.2014

Set a timer that will trigger every 24 minutes, which would add it to an database/ini file.


Re: Time played - Ananisiki - 21.04.2014

Ye but how like a stock / public with stuff in it and pinfo[timeplayed] and stuff like that


Re: Time played - AroseKhanNiazi - 21.04.2014

add an playerinfo enum like
Код:
daysplayed
then set an time on player connect and kill the timer on playerdisconnect
and you can do when the timer reaches the time u set
Код:
PlayerInfo[playerid][daysplayed] ++;



Re: Time played - Ananisiki - 21.04.2014

Dont really understand


Re: Time played - AroseKhanNiazi - 22.04.2014

do you use any clock/time system ??


Re: Time played - therainycat - 22.04.2014

Quote:
Originally Posted by Ananisiki
Посмотреть сообщение
I wonder how i can add days played in stats?

Every 24 minutes will be one day in game, how i do
1. Create variable to store a "dayz played count" for each player (add it to your global arrays):
PHP код:
new days_played[MAX_PLAYERS]; 
2. Create public function, that will be called each hour (your's 24 minutes):
PHP код:
public IAmCalledEachHour() {
  for (new 
i=0i<MAX_PLAYERSi++)
    if (
IsPlayerConnected(i))
      
days_played[i]++;

It adds 1 hour for each player, that is online.

3. Set the timer, that will call this function each 24 minutes, for example in OnGameModeInit:
PHP код:
public OnGameModeInit(){
  ...
  
SetTimer("IAmCalledEachHour"24 60 1000true);
  ...

Done.


Re: Time played - Ananisiki - 23.04.2014

ty +rep