Raised This Month: $51 Target: $400
 12% 

x number of times per day


Post New Thread Reply   
 
Thread Tools Display Modes
EpicMonkey
buttmonkey
Join Date: Feb 2012
Old 02-25-2012 , 06:21   Re: x number of times per day
Reply With Quote #11

thats not what am trying to do ...
EpicMonkey is offline
Devil259
Veteran Member
Join Date: Dec 2009
Location: France (59)
Old 02-25-2012 , 06:23   Re: x number of times per day
Reply With Quote #12

http://forums.alliedmods.net/showthread.php?p=11751
__________________
You can do anything you set your mind to, man.

Devil259 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-25-2012 , 21:54   Re: x number of times per day
Reply With Quote #13

You need to store both day and number of slaps for each player. Then, when they enter the server check to see if the day stored is today. If it is today, load the number of slaps in the global array that counts slaps. If it is not today then enter 0 for the slap count.

Simple as that.
__________________
fysiks is online now
EpicMonkey
buttmonkey
Join Date: Feb 2012
Old 03-23-2012 , 16:42   Re: x number of times per day
Reply With Quote #14

Quote:
Originally Posted by fysiks View Post
You need to store both day and number of slaps for each player. Then, when they enter the server check to see if the day stored is today. If it is today, load the number of slaps in the global array that counts slaps. If it is not today then enter 0 for the slap count.

Simple as that.
hmm so , When player connects , Check if the day is different, if it is then store todays date and remove the previous one and give the player x number of slaps , right?
EpicMonkey is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 03-23-2012 , 16:59   Re: x number of times per day
Reply With Quote #15

Code:
#include <amxmodx> #include <nvault> new gVault; public plugin_init() {     gVault = nvault_open("daily_slaps");         // get current timestamp     new now = get_systime();         // subtract all time of hours, minutes, and seconds such that the day just started     new hour, minute, second;     time(hour, minute, second);     new day_start = now - ((hour * 3600) + (minute * 60) + second);         // remove all vault entries before today     nvault_prune(gVault, 0, day_start);         // set task to prune again for next day start, in case plugin is running across midnight     new next_day = day_start + 86400;     set_task(float(next_day - now), "TaskPruneVault"); } public TaskPruneVault() {     // prune vault since day is changing right now     nvault_prune(gVault, 0, get_systime() + 1);         // set task to execute again next day     set_task(86400.0, "TaskPruneVault"); } public plugin_end() {     nvault_close(gVault); } GetSlaps(id) {     new steamID[35];     get_user_authid(id, steamID, charsmax(steamID));         return nvault_get(gVault, steamID); } SetSlaps(id, slaps) {     new steamID[35];     get_user_authid(id, steamID, charsmax(steamID));         new value[12];     num_to_str(slaps, value, charsmax(value));         nvault_set(gVault, steamID, value); }

Then your slap function would look like this:

Code:
public CmdSlap(id, level, cid) {     // check access, args, grab target, etc.         new slaps = GetSlaps(id);     if(slaps >= /* max slaps per day */) {         // you cannot slap anymore!         return PLUGIN_HANDLED;     }         // update slaps     SetSlaps(id, slaps + 1);         // rest of command code... }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
EpicMonkey
buttmonkey
Join Date: Feb 2012
Old 03-23-2012 , 18:29   Re: x number of times per day
Reply With Quote #16

very interesting , i like what you did with the pruning function , had a problem with the date thing , and the way of saving with nvault is just amazing ... , thanks a bunch for showing me how to do it

Last edited by EpicMonkey; 03-23-2012 at 18:29.
EpicMonkey is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 00:27.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode