Raised This Month: $ Target: $400
 0% 

Check if "light" entity is toggled ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
NiHiLaNTh
Way Past Expiration
Join Date: May 2009
Location: Latvia
Old 01-15-2012 , 05:41   Check if "light" entity is toggled ?
Reply With Quote #1

So how to check if entity with classname "light" is enabled? I need to check that and if it's enabled - than turn it off.
__________________

NiHiLaNTh is offline
Send a message via Skype™ to NiHiLaNTh
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-15-2012 , 06:01   Re: Check if "light" entity is toggled ?
Reply With Quote #2

Try to check pev_spawnflags with SF_LIGHT_START_OFF and if so execute Ham_Use on it.
__________________
Arkshine is offline
NiHiLaNTh
Way Past Expiration
Join Date: May 2009
Location: Latvia
Old 01-15-2012 , 11:43   Re: Check if "light" entity is toggled ?
Reply With Quote #3

wow, thanks, it really helped.

One more thing that isn't fixed - when I turn off the light I need to prevent it from being toggled. I tried this:

Code:
set_pev( pEntity, pev_targetname, 0 );
But, I can still toggle the light somehow.

Maybe its because I am trying to block light from being toggled NOT at round start or entity spawn, but on mid-round.

Edit. OK I tested my code again and strange things happened. If I test the code in cs_militia at the garage(where the 2 hostages are located), everything is working perfectly, but if I test it in cs_estate or in cs_militia at sewers, code is working as I mentioned above - light is being turned off, but I am able to enable it )
__________________


Last edited by NiHiLaNTh; 01-15-2012 at 11:50.
NiHiLaNTh is offline
Send a message via Skype™ to NiHiLaNTh
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-15-2012 , 11:48   Re: Check if "light" entity is toggled ?
Reply With Quote #4

The fastest/easier way would be probably to set the m_iStyle (34) offset to a value < 32, so Use will have no effect. (a check is done with this offset if >= 32 in the Use function)
It should be fine if it's the game which provokes that, because a plugin could use directly pfnLightStyle and you would need to block it with FM_LightStyle I guess.
If you set a null targetname and the entity spawns, it will be removed.

PHP Code:
void CLight :: Use( CBaseEntity *pActivatorCBaseEntity *pCallerUSE_TYPE useTypefloat value )
{
    if (
m_iStyle >= 32)
    {
        if ( !
ShouldToggleuseType, !FBitSet(pev->spawnflagsSF_LIGHT_START_OFF) ) )
            return;

        if (
FBitSet(pev->spawnflagsSF_LIGHT_START_OFF))
        {
            if (
m_iszPattern)
                
LIGHT_STYLE(m_iStyle, (char *)STRINGm_iszPattern ));
            else
                
LIGHT_STYLE(m_iStyle"m");
            
ClearBits(pev->spawnflagsSF_LIGHT_START_OFF);
        }
        else
        {
            
LIGHT_STYLE(m_iStyle"a");
            
SetBits(pev->spawnflagsSF_LIGHT_START_OFF);
        }
    }

__________________

Last edited by Arkshine; 01-15-2012 at 11:55.
Arkshine 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:48.


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