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

[SNIPPET][CS:S] Getting bombsites letters ("A" and "B")


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
exvel
SourceMod Donor
Join Date: Jun 2006
Location: Russia
Old 08-31-2010 , 11:41   [SNIPPET][CS:S] Getting bombsites letters ("A" and "B")
Reply With Quote #1

Run GetBomsitesIndexes() only after the first player connected to the server (OnClientConnected for example).
Thanks to Usurpus for allowing to publish this private code.
PHP Code:
new g_BombsiteA = -1;
new 
g_BombsiteB = -1;

GetBomsitesIndexes()
{
    new 
index = -1;
    
    new 
Float:vecBombsiteCenterA[3];
    new 
Float:vecBombsiteCenterB[3];
    
    
index FindEntityByClassname(index"cs_player_manager");
    if (
index != -1)
    {
        
GetEntPropVector(indexProp_Send"m_bombsiteCenterA"vecBombsiteCenterA);
        
GetEntPropVector(indexProp_Send"m_bombsiteCenterB"vecBombsiteCenterB);
    }
    
    
index = -1;
    while ((
index FindEntityByClassname(index"func_bomb_target")) != -1)
    {
        new 
Float:vecBombsiteMin[3];
        new 
Float:vecBombsiteMax[3];
        
        
GetEntPropVector(indexProp_Send"m_vecMins"vecBombsiteMin);
        
GetEntPropVector(indexProp_Send"m_vecMaxs"vecBombsiteMax);
        
        if (
IsVecBetween(vecBombsiteCenterAvecBombsiteMinvecBombsiteMax))
        {
            
g_BombsiteA index;
        }
        else if (
IsVecBetween(vecBombsiteCenterBvecBombsiteMinvecBombsiteMax))
        {
            
g_BombsiteB index;
        }
    }
}

stock bool:IsVecBetween(const Float:vecVector[3], const Float:vecMin[3], const Float:vecMax[3])
{
    return ( (
vecMin[0] <= vecVector[0] <= vecMax[0]) &&
             (
vecMin[1] <= vecVector[1] <= vecMax[1]) &&
             (
vecMin[2] <= vecVector[2] <= vecMax[2])    );

After running the code you will have an index for bombsite "A" inside of the global variable g_BombsiteA and index for "B" inside of g_BombsiteB.
__________________
For admins: My plugins

For developers: Colors library

Last edited by exvel; 09-02-2010 at 15:39.
exvel is offline
Send a message via ICQ to exvel
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 13:56.


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