Optimizing Code
Is there any better way to do this without using 3 set tasks?
Note each user has 3 personal channels PHP Code:
|
Re: Optimizing Code
why not using unidimenaional array?
new g_channel[33] then you just do: if(g_channel[id] < 3){ //do something g_channel[id]++ set_task(1.5, "reset_channel", id) } public reset_channel(id){ if(g_channel[id]) g_channel[id]--; } Every time player uses command it will add 1 ,and when it will be 3 then he won't be able to use , he will wait for task to decrease the value. |
Re: Optimizing Code
Because if channel two is in use and channel one is free, i want channel one to be used instead of channel three
Channels are actualy coordinates where the message to be displayed :) |
Re: Optimizing Code
PHP Code:
|
Re: Optimizing Code
What you could do is set just 1 task in your public FunctionCalled(id)
Then in your task function, you could check everything in there and set everything to true or false. Anyways, there should indeed be a more proper way but i have no clue how to do that, guess you gotta work with constants & for loops instead. @siriusmd99, you're still using 3 tasks... |
Re: Optimizing Code
Quote:
When you use one channel a task has been set, now if you use it again after 1.0 second with the same task then first channel won't be cleared because first task has been removed due to setting second task. There shall work 3 tasks anyway. |
Re: Optimizing Code
This should do it. It's much less hardcoded so you can change the channel count just by changing one constant.
PHP Code:
|
Re: Optimizing Code
What about this?
PHP Code:
|
Re: Optimizing Code
Quote:
Yes, this is the best way. Using set_task is a bad idea. Klippy , your plugin is not correct. You set a task with the same id ( 0 ) and previous task will be reseted .. Whitez, use get_gametime instead, nice idea. |
Re: Optimizing Code
Quote:
Quote:
|
| All times are GMT -4. The time now is 18:43. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.