View Single Post
TheDS1337
Veteran Member
Join Date: Jun 2012
Old 01-29-2016 , 15:52   Re: SourceMod FindEntityByClassname / SetEntProp extension equivalents?
Reply With Quote #5

Hey, sorry to bump this since I'm trying to do the same thing

can you tell me why this doesnt work ?
PHP Code:
CBaseEntity *UTIL_FindEntityByClassname(int start, const char *pEntityClassname)
{
    
CBaseEntity *pEntity;

    if (
start == -1)
    {
        
pEntity = (CBaseEntity *)g_pServerTools->FirstEntity();
    }
    else
    {
        
pEntity gamehelpers->ReferenceToEntity(start);

        if (
pEntity)
        {
            
pEntity = (CBaseEntity *)g_pServerTools->NextEntity(pEntity);
        }
    }

    if (
pEntity)
    {
        static 
int offset = -1;

        if (
offset == -1)
        {
            
sm_datatable_info_t info;

            if (
gamehelpers->FindDataMapInfo(gamehelpers->GetDataMap(pEntity), "m_iClassname", &info))
            {
                
offset info.actual_offset;
            }
        }

        const 
char *pClassname;
        
string_t str;

        
int lastLetter;

        while (
pEntity)
        {
            
str = *(string_t *)((uint8_t *)pEntity offset);

            if (
str == NULL_STRING)
            {
                
pEntity = (CBaseEntity *)g_pServerTools->NextEntity(pEntity);
                continue;
            }

            
pClassname STRING(str);

            
lastLetter strlen(pEntityClassname) - 1;

            if (
pEntityClassname[lastLetter] == '*' && !strncasecmp(pEntityClassnamepClassnamelastLetter))
            {
                return 
pEntity;
            }
            else if (!
strcasecmp(pEntityClassnamepClassname))
            {
                return 
pEntity;
            }

            
pEntity = (CBaseEntity *)g_pServerTools->NextEntity(pEntity);
        }
    }

    return 
pEntity;
}; 
Basically I'm trying to find the fov ("ent_fov_controller") and edit it also is there any equivalent to SetVariant* and AcceptEntityInput

PHP Code:
void OnServer_Activate(edict_t *pEdictint edictCountint clientMax)
{
    
engine->LightStyle(0MAP_LIGHT);

/*
    CBaseEntity *pFogEntity = UTIL_FindEntityByClassname(-1, "env_fog_controller");

    if (!pFogEntity)
    {
        g_pServerTools->DispatchSpawn(pFogEntity);
    }

    g_pServerTools->SetKeyValue(pFogEntity, "fogmaxdensity", 0.6);
    
    SetVariantInt(FogStartDist);
    AcceptEntityInput(FogControllerIndex, "SetStartDist");
        
    SetVariantInt(FogEndDist);
    AcceptEntityInput(FogControllerIndex, "SetEndDist");
    
    SetVariantInt(FogZPlane);
    AcceptEntityInput(FogControllerIndex, "SetFarZ");

    SetVariantString(FogColor);
    AcceptEntityInput(FogControllerIndex, "SetColor");

    SetVariantString(FogColor);
    AcceptEntityInput(FogControllerIndex, "SetColorSecondary");
    
    SET START DIST, END DIST, FARZ
*/

The lightning works fine, but others doesnt

Last edited by TheDS1337; 01-29-2016 at 15:53.
TheDS1337 is offline