Raised This Month: $ Target: $400
 0% 

Optimizing code.


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
danielkza
AMX Mod X Plugin Approver
Join Date: May 2007
Location: São Paulo - Brasil
Old 04-10-2009 , 16:11   Re: Optimizing code.
Reply With Quote #10

From what I understood, it's a very simple snippet, what it does is check if an entity is a 'func_button'. If positive, loop through two string sets, checking if the target name matches. If it does, store the entity index on gButtons[START], if it's the first match, or gButtons[START2] if one was already found. Do the same with the stop buttons.

My attempt:
Code:
new iStartCount = 0, iStopCount = 0

if(equal( szClassname, "func_button"))
{
    new szTarget[32], i;
    pev(iEntity, pev_target, szTarget, charsmax(szTarget));
    
    if(!iStartCount || (iStartCount == 1 && iEntity != gButtons[START]))
    {
        for( i = 0; i < sizeof(szCounterStart); i++)
        {
            if(equal(szTarget, szCounterStart[i]))
                gButtons[!(iStartCount++) ? START : START2] = iEntity;
        }
    }
    else if(!iStopCount || (iStopCount == 1 && iEntity != gButtons[STOP]))
    {
        for( i = 0; i < sizeof(szCounterStop); i++)
        {
            if(equal(szTarget, szCounterStop[i]))
                gButtons[!(iStopCount++) ? STOP : STOP2] = iEntity;
        }
    }
}
__________________

Community / No support through PM
danielkza 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 02:19.


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