Raised This Month: $ Target: $400
 0% 

Optimizing Code


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 06-01-2016 , 10:39   Re: Optimizing Code
Reply With Quote #7

This should do it. It's much less hardcoded so you can change the channel count just by changing one constant.
PHP Code:
#define CHANNEL_COUNT    3
new g_isChannelUsed[33][CHANNEL_COUNT];

public 
MyCallback(id)
{
    for(new 
0CHANNEL_COUNTi++)
    {
        if(!
g_isChannelUsed[id][i])
        {
            
// Send message using channel 'i', or whatever
            
g_isChannelUsed[id][i] = true;
            
            new 
taskData[2];
            
taskData[0] = id;
            
taskData[1] = i;
            
set_task(1.5"Task_ResetChannel"0taskDatasizeof(taskData));
            break;
        }
    }
}

public 
Task_ResetChannel(taskData[])
{
    
g_isChannelUsed[taskData[0]][taskData[1]] = false;


Last edited by klippy; 06-01-2016 at 10:40.
klippy is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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