Optimization of code based on dates
#1

Hi! I've recently made a /ban command with the parameters "time" and "period". Times is an integer, and period is either "minutes", "hours", "days", "months", "years".
If you do the ban command with the time 4 and the period months, the ban-function will get the time and date, then advance it by 4 months (leap years are calculated, and days in each month is also correctly working), then save that date to a ban-file (using y_ini) with the player's name as a tag.

Now, onto my question and purpose of this thread:

Is there any way to optimize/improve my "conversion"-code?

I feel like I do unnecessary lots of calculations and that my code is super inefficient, but I'm not a hundred percent sure.
Please take a look if you think you can help: http://pastebin.com/ayW73Fka

Edit: There are some places in my script where tabs are written as spaces - by accident - so the code seems unindented, while in reality it is actually correctly indented. Just wanted you to know, hah.

Edit 2: Here's the command and the ban-check on connect too - just in case they also can be improved.

Command: http://pastebin.com/4eFwAa70

OnPlayerConnect: http://pastebin.com/BJNRUuEk
Reply


Messages In This Thread
Optimization of code based on dates - by LarzI - 13.12.2012, 23:30
Re: Optimization of code based on dates - by Jefff - 13.12.2012, 23:56
Re: Optimization of code based on dates - by LarzI - 13.12.2012, 23:58
Re: Optimization of code based on dates - by maramizo - 13.12.2012, 23:58
Re: Optimization of code based on dates - by LarzI - 14.12.2012, 00:05
Re: Optimization of code based on dates - by maramizo - 14.12.2012, 00:18
Re: Optimization of code based on dates - by LarzI - 14.12.2012, 00:24
Re: Optimization of code based on dates - by maramizo - 14.12.2012, 00:35
Re: Optimization of code based on dates - by LarzI - 14.12.2012, 01:31
Re: Optimization of code based on dates - by maramizo - 14.12.2012, 02:07

Forum Jump:


Users browsing this thread: 2 Guest(s)