addip/banid implementation
I've been trying to do my own [efficient, meaning usable] implementation of these commands using a plugin, and i wanted to know if any of you had ideas for it. What first comes to mind is simple creating an array or similar data structure with all the temporarily banned players, and use a task to decrease remaining ban time by one every minute, but i'm not sure this would work well as i've read task should be used little and carefully.
So, the main question is: Does anyone see any problem with this, or could this create problems with the server if i had too many banned players? (too many ~= 15?) If so, any suggestions for an alternative way of doing this would be appreciated. PS: the mininum ban time could be raised so the task is executed less often, or to decrease remaining ban time on every map change. |
Re: addip/banid implementation
Don't.
The way it is is fine. And if you really have to do it use nvault, not an array. |
Re: addip/banid implementation
I know it's fine the way it is, but i need my own :).
Why nvault? since i need to lower every banned player's remaining time by one minute, an array is perfect because i can do it in O(n) time. Else i'd have to use a data structure to store banned keys to lookup in the vault, which would be kinda the same thing, given that i need to know every key that's in the vault. Or do you mean i should use a vault for "permanent" storage? Thanks Black Rose! The only problem i see with using an array is how task's and events are implemented; if they use interrupts, i'd be having a sincronization problem, because when a player is banned, the player's id would be added to the array, but if in the middle of this, the task (which could delete an array member when remaining time reaches zero) gets executed, it would make a mess. Or viceversa, if the task is begin executed and a ban comes through and interrupts.. I need help :(!!! |
Re: addip/banid implementation
ok i'll post some pseudo code so you can better see what i mean:
Code:
As you can see, i can't have one function interrupting the execution of another one, since the array would be left in an inconsistent state. |
| All times are GMT -4. The time now is 00:38. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.