AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Expiration Date in default admin plugin (https://forums.alliedmods.net/showthread.php?t=308407)

ish12321 06-19-2018 07:38

Expiration Date in default admin plugin
 
1 Attachment(s)
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

OciXCrom 06-19-2018 07:58

Re: Expiration Date in default admin plugin
 
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.

ish12321 06-19-2018 08:03

Re: Expiration Date in default admin plugin
 
Or maybe if my code works, it could be added to amxmodx 1.8.3 under the next update

OciXCrom 06-19-2018 08:13

Re: Expiration Date in default admin plugin
 
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.

klippy 06-19-2018 08:16

Re: Expiration Date in default admin plugin
 
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.

^SmileY 06-19-2018 08:27

Re: Expiration Date in default admin plugin
 
Quote:

Originally Posted by KliPPy (Post 2597942)
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. :bee:

ish12321 06-23-2018 15:14

Re: Expiration Date in default admin plugin
 
1 Attachment(s)
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 ?

Kushfield 06-23-2018 16:06

Re: Expiration Date in default admin plugin
 
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); 


ish12321 06-23-2018 16:15

Re: Expiration Date in default admin plugin
 
Quote:

Originally Posted by Kushfield (Post 2598947)
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

yousuf khan 07-29-2020 09:08

Can You Give Me Example Like This:

"killer" "123" "bceijmtu" "a" ; Expiration:

Tell Me What I Add In Expiration?


All times are GMT -4. The time now is 07:18.

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