SA-MP Forums Archive
Week, Month Stats saving problem - 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: Week, Month Stats saving problem (/showthread.php?tid=443453)



Week, Month Stats saving problem - Black Wolf - 12.06.2013

Hello,

I am currently working on a gamemode.But i am stucked at something i have no idea how to save week stats, month stats.Like a player registers and when he is a week old the current score gets saved in week and then it gets reset and when again one week completes it will get addup with the current same with months.I've maded register/login system and it saves RegisterDate is it possible anyway to check dates and get to know thats he was registered 7 days ago bla bla.So we can store week stats of the player.I am using MySQL R6.A example code will be good.


Re: Week, Month Stats saving problem - Black Wolf - 12.06.2013

BUMP


Re: Week, Month Stats saving problem - Knappen - 12.06.2013

Why would you want to save week stats? What do you mean by week stats at all?

If you want to check how long it has been you could use the getdate and gettime function. It's simple math.

https://sampwiki.blast.hk/wiki/Getdate

https://sampwiki.blast.hk/wiki/Gettime


Re: Week, Month Stats saving problem - Black Wolf - 12.06.2013

How can i compare date?

By week stats i mean that the player score player earned in the week.


Re: Week, Month Stats saving problem - Knappen - 12.06.2013

If you saved the date the player registered, you just simply subtract the date.


Re: Week, Month Stats saving problem - Aly - 12.06.2013

Make a new variable LastWeek.
When the player is login in:
pawn Код:
new day,month,year;
getdate(day,month,year);
if(day - LastWeek[playerid] >= 7)
{
 //..Reset stats
 LastWeek[playerid] = day;
}
Something like that.


Re: Week, Month Stats saving problem - Black Wolf - 12.06.2013

I dont think it will work that way.Also i am storing Registration Date in string in MySQL.So NO subtracting can be done.I guess it can be done with Timestamp ( i read tutorial on it and still not understood it properly).A easy example would be better (using timestamp).


Re: Week, Month Stats saving problem - Knappen - 12.06.2013

Why don't you just fetch the date from MySQL and subtract it like I said?