Raised This Month: $51 Target: $400
 12% 

[SNIPPET] Find the best hud channel to use


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Sammy-ROCK!
Senior Member
Join Date: Jun 2008
Location: Near Mrs.Lag
Old 12-19-2009 , 17:58   [SNIPPET] Find the best hud channel to use
Reply With Quote #1

Code:
stock FindBestHudChannel()
{
    new EntsUsingChannel[4] = {0, ...};//Track game_text entities and get the channel their set to use.
    new MaxEntities = GetMaxEntities();
    for(new Entity=MaxPlayers+1; Entity<=MaxEntities; Entity++)
    {
        if(!IsValidEntity(Entity) || !IsValidEdict(Entity))
            continue;
        decl String:ClassName[10]; //game_text is 9 bytes so we need 10 to get it fully
        GetEdictClassname(Entity, ClassName, sizeof(ClassName));
        if(StrEqual(ClassName, "game_text", false))
            EntsUsingChannel[GetEntData(Entity, FindDataMapOffs(Entity, "m_textParms.channel")) - 1]++;//-1 so we don't need increase the array size just to keep it justified
    }
    new BestChannel = 1;
    //Starts with channel 1 then check if other channels have less entities using.
    if(EntsUsingChannel[1] < EntsUsingChannel[BestChannel-1])
        BestChannel = 2;
    if(EntsUsingChannel[2] < EntsUsingChannel[BestChannel-1])
        BestChannel = 3;
    if(EntsUsingChannel[3] < EntsUsingChannel[BestChannel-1])
        BestChannel = 4;
    return BestChannel; //Tells the best channel
}
This returns the hud channel that fewer used on the map. To cause the minimum of interference against the map's huds.
Sammy-ROCK! is offline
Reply



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 06:47.


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