Raised This Month: $65 Target: $400
 16% 

Top Flags [06/10/2018]


Post New Thread Reply   
 
Thread Tools Display Modes
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-05-2018 , 21:59   Re: Top Flags [05/10/2018]
Reply With Quote #51

Quote:
Originally Posted by iceeedr View Post
Bugsy, please forgive me, but statistics are not redefined once a day, but once a month (this is if the user wants to use it).
Oh, I'm sorry, I didnt realize you had the variable/cvar to determine if it should reset based on the day. Still, your plugin would require no map changes for this to work. I would implement another method for checking the day and resetting.

In plugin_init(), check the vault for a date record, if it does not exist or is expired, reset sets and write the current date. This would make the check occur on each map change while allowing it to only reset stats on the desired day of the month.
__________________

Last edited by Bugsy; 10-05-2018 at 22:06.
Bugsy is online now
iceeedr
Senior Member
Join Date: Apr 2017
Location: Brazil
Old 10-05-2018 , 22:06   Re: Top Flags [05/10/2018]
Reply With Quote #52

Quote:
Originally Posted by Bugsy View Post
Oh, I'm sorry, I didnt realize you had the variable/cvar to control the day it restarts.
Correct me if I'm wrong ..

PHP Code:
bind_pcvar_num(create_cvar("tf_day_reset""0", .description "On the selected day of each month the rank will be reset.", .has_min true, .min_val 0.0, .has_max true, .max_val 31.0), VarTimeToReset// Here we set the day of the monthly reset and save the value in pcvar "VarTimeToReset"

set_task_ex(86400.0"CheckDate", .flags SetTask_Repeat// Here we configure the task that verifies the day, but it will be changed to a much lower value, I believe that 10 minutes is totally acceptable.

public CheckDate()
{
    new 
Day
    date
(.day Day)
    
    if(
Day == VarTimeToReset)
    {
        
server_cmd("amx_cvar csstats_reset 1")
        
client_print_color(0print_team_red"^x04[TopFlags]^x03: Today is day^x04 %d^x01 and the ranking will be^x04 reseted^x01, at the next map exchange, run to guarantee the^x04 TOP."Day)
        
set_task_ex(3.0"ChangeLevel", .flags SetTask_Once)

    }
// Finally we check the day, if the Day, is equal to pcvar (day chosen for the reset) the statistics will be reset and the map will be reloaded. 
Edit: Okay, parsing the plugin that was not you who wrote is not fun and easy haha, I did not understand this part well, could you give me an example?

Quote:
Originally Posted by Bugsy View Post
In plugin_init(), check the vault for a date record, if it does not exist or is expired, reset sets and write the current date. This would make the check occur on each map change while allowing it to only reset stats on the desired day of the month.
__________________

Last edited by iceeedr; 10-05-2018 at 22:09.
iceeedr is offline
Send a message via Skype™ to iceeedr
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-05-2018 , 22:25   Re: Top Flags [05/10/2018]
Reply With Quote #53

Something like this. It would use the nVault timestamp as the timestamp of the last reset which is accurate down to the second. This would also cover you for example if someone picked 31 as the day, with your current method you'd never get a reset in February or September, for example. When the map is changed or server is restarted and VarTimeToReset days have elapsed, a stats reset would happen. The next would not happen until VarTimeToReset days later.

PHP Code:
#include <amxmodx>
#include <nvault>

const VarTimeToReset 5//# of days between stats reset (not day of the month)

public plugin_init() 
{
    
CheckDate();
}

public 
CheckDate()
{
    new 
iVault iTimeStamp iRecordExists;
    
    
iVault nvault_open"TopFlags" );
    
    
iRecordExists nvault_lookupiVault "StatsReset" "" iTimeStamp );
    
    if ( !
iRecordExists || ( iRecordExists && ( ( get_systime() - iTimeStamp ) >= ( VarTimeToReset 86400 ) ) ) )
    {
        
server_cmd"amx_cvar csstats_reset 1" );
        
nvault_setiVault "StatsReset" "" );
    }
    
    
nvault_closeiVault );

__________________

Last edited by Bugsy; 10-05-2018 at 22:27.
Bugsy is online now
iceeedr
Senior Member
Join Date: Apr 2017
Location: Brazil
Old 10-05-2018 , 22:31   Re: Top Flags [05/10/2018]
Reply With Quote #54

Great Bugsy, really I had not thought of the possibilities of extra-month days.
__________________
iceeedr is offline
Send a message via Skype™ to iceeedr
iceeedr
Senior Member
Join Date: Apr 2017
Location: Brazil
Old 10-06-2018 , 12:35   Re: Top Flags [06/10/2018]
Reply With Quote #55

Code:
1.6 [05/10/2018] Final Release.
* Days count for the reset totally reformulated by Bugsy
* Added new pcvar to enable or disable reset function stats
* Added an #error message if you try to compile sma in versions lower than amxx 1.9
__________________
iceeedr is offline
Send a message via Skype™ to iceeedr
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 10-06-2018 , 15:32   Re: Top Flags [05/10/2018]
Reply With Quote #56

Quote:
Originally Posted by iceeedr View Post
error 008: must be a constant expression; assumed zero[/code]

Edit: The correct is:
Code:
#if AMXX_VERSION_NUM <19
    #error "This plugin requires AMXX 1.9"
#endif
Actually, it's < 190, not 19. Right now 181 is bigger than 19, change it to 190.

PHP Code:
#if AMXX_VERSION_NUM < 190
    #error "This plugin requires AMXX 1.9"
#endif 
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
noonsaibot
Junior Member
Join Date: Mar 2011
Old 10-26-2018 , 09:19   Re: Top Flags [06/10/2018]
Reply With Quote #57

İs there anyway that we can use it on 1.8.2 ?
noonsaibot is offline
iceeedr
Senior Member
Join Date: Apr 2017
Location: Brazil
Old 10-26-2018 , 09:29   Re: Top Flags [06/10/2018]
Reply With Quote #58

Quote:
Originally Posted by noonsaibot View Post
İs there anyway that we can use it on 1.8.2 ?
PM me.
__________________
iceeedr is offline
Send a message via Skype™ to iceeedr
Reply


Thread Tools
Display Modes

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 17:18.


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