Raised This Month: $40 Target: $400
 10% 

Expiration Date in default admin plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ish12321
Veteran Member
Join Date: May 2016
Old 06-19-2018 , 08:38   Expiration Date in default admin plugin
Reply With Quote #1

Hello,
So, I've tried adding expiration date to the default admin.sma (only to the users.ini way, not mysql). The code is not yet tested, so it would be great if someone would like to test it out. Also, would be more great if someone could find out any bug or point some better way in it.
Thanks
Attached Files
File Type: sma Get Plugin or Get Source (admin.sma - 61 views - 19.8 KB)
__________________
['O|s|G'] | Death Wins a.k.a Ish Chhabra was here
ish12321 is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 06-19-2018 , 08:58   Re: Expiration Date in default admin plugin
Reply With Quote #2

This kind of thing should be included to the default AMXX package. Being able to add a date in the users.ini file will be much useful. Maybe I'll recreate the entire plugin one day.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
ish12321
Veteran Member
Join Date: May 2016
Old 06-19-2018 , 09:03   Re: Expiration Date in default admin plugin
Reply With Quote #3

Or maybe if my code works, it could be added to amxmodx 1.8.3 under the next update
__________________
['O|s|G'] | Death Wins a.k.a Ish Chhabra was here
ish12321 is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 06-19-2018 , 09:13   Re: Expiration Date in default admin plugin
Reply With Quote #4

I didn't check your code, but it should be easy to make. Just parse an additional parameter from the users.ini file that will be the date, compare it with the current date and stop the plugin from adding the admin if the date is passed.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
KliPPy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 06-19-2018 , 09:16   Re: Expiration Date in default admin plugin
Reply With Quote #5

Actually what 1.8.3 is mostly lacking to be released is features for end users, plugin writes did get a lot of new features. This would be welcome, actually all first party plugins should receive some love.
__________________
KliPPy is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 06-19-2018 , 09:27   Re: Expiration Date in default admin plugin
Reply With Quote #6

Quote:
Originally Posted by KliPPy View Post
Actually what 1.8.3 is mostly lacking to be released is features for end users, plugin writes did get a lot of new features. This would be welcome, actually all first party plugins should receive some love.
And using 1.8.3 natives Mr.
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar,get_pcvar_num(pCvar) ? 1); 
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
ish12321
Veteran Member
Join Date: May 2016
Old 06-23-2018 , 16:14   Re: Expiration Date in default admin plugin
Reply With Quote #7

Hello,
I updated the code as above had few bugs. The plugin works fine if I add properly in users.ini. However, when I use amx_addadmin the expirationdate is not correctly added to users.ini. I doubt error is in
Code:
stock getExpirationDate(duration) {
	new year, month, day;
	date(year, month, day);

	day += duration;

	switch(month) {
			case 1, 3, 5, 7, 8, 10, 12 : {
				if(day > 31) {
					day -= 31;
					month += 1;
				}
			}
			case 2, 4, 6, 9, 11 : {
				if(day > 30) {
					day -= 30;
					month += 1;
				}
			}
	}

	new szExpirationDate[15];
	formatex(szExpirationDate, charsmax(szExpirationDate), "%d%s%s", year, month >= 10 ? "%d" : "0%d", month, day >= 10 ? "%d" : "0%d", day);

	return str_to_num(szExpirationDate);
}
If it is here, could someone point the error ? If not, could someone please check the code and point error ?
Attached Files
File Type: sma Get Plugin or Get Source (admin.sma - 94 views - 20.0 KB)
__________________
['O|s|G'] | Death Wins a.k.a Ish Chhabra was here
ish12321 is offline
Kushfield
Member
Join Date: Jan 2017
Location: Estonia
Old 06-23-2018 , 17:06   Re: Expiration Date in default admin plugin
Reply With Quote #8

What exactly is the output?

You're making that stock way more complicated than it has to be by the way:
PHP Code:
stock getExpirationDate(duration) {
    new 
szExpirationDate[15];
    
format_time(szExpirationDatecharsmax(szExpirationDate), "%Y%m%d"get_systime() + (duration 86400));
    return 
str_to_num(szExpirationDate);

Not sure why you return a str_to_num if you do a num_to_str on it right after.

Also, to automatically add a leading zero to an integer if it's a 1-digit number, you can use the following format:
PHP Code:
formatex(szExpirationDatecharsmax(szExpirationDate), "%d%02d%02d"yearmonthday); 
Kushfield is online now
ish12321
Veteran Member
Join Date: May 2016
Old 06-23-2018 , 17:15   Re: Expiration Date in default admin plugin
Reply With Quote #9

Quote:
Originally Posted by Kushfield View Post
What exactly is the output?

You're making that stock way more complicated than it has to be by the way:
PHP Code:
stock getExpirationDate(duration) {
    new 
szExpirationDate[15];
    
format_time(szExpirationDatecharsmax(szExpirationDate), "%Y%m%d"get_systime() + (duration 86400));
    return 
str_to_num(szExpirationDate);

Not sure why you return a str_to_num if you do a num_to_str on it right after.

Also, to automatically add a leading zero to an integer if it's a 1-digit number, you can use the following format:
PHP Code:
formatex(szExpirationDatecharsmax(szExpirationDate), "%d%02d%02d"yearmonthday); 
Thank you
__________________
['O|s|G'] | Death Wins a.k.a Ish Chhabra was here
ish12321 is offline
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 19:04.


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