13.12.2012, 23:30
(
Последний раз редактировалось LarzI; 14.12.2012 в 07:55.
)
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
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