AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Trigger Light (https://forums.alliedmods.net/showthread.php?t=128134)

Mr.ToeMayToe 05-29-2010 08:38

Trigger Light
 
I wanted to trigger all the lights in cs_mansion to be off. However, It didn't work.

PHP Code:

#include < amxmodx >
#include < fakemeta >
 
new cvar_triggered
 
public plugin_init ( )
{
    
register_plugin"Trigger Light""0.1""ToeMayToe" )
 
    
register_event"HLTV""event_round_start""a""1=0""2=0" )
 
    
cvar_triggered register_cvar"zp_trigger_light""1" )
}
 
public 
event_round_start( )
{
    
set_task0.1"remove_stuff" )
    
set_task0.1"remove_lights" )
}
 
public 
remove_stuff( )
{
    static 
ent
    
if ( !get_pcvar_numcvar_triggered ) )
    {
        
ent = -1
        
while ( ( ent engfuncEngFunc_FindEntityByStringent"classname""light" ) ) != )
        {
            
dllfuncDLLFunc_Useent); 
            
set_peventpev_targetname
        }
    }
}

public 
remove_lights( )
{
    static 
ent
    ent 
= -1
    
while ( ( ent engfuncEngFunc_FindEntityByStringent"classname""light" ) ) != )
    {
        
dllfuncDLLFunc_Useent);
        
set_peventpev_targetname
    }



Mr.ToeMayToe 05-30-2010 19:21

Re: Trigger Light
 
Please help !

wrecked_ 05-30-2010 21:41

Re: Trigger Light
 
Are you looking to just disable the lights? Or do you want them to just be turned off by default at round start?

This plugin removes all lights (make sure the classname is right, wasn't too sure):
Code:
#include <amxmodx> #include <fakemeta> // not sure, correct me if i'm wrong new const LightClassname[] = "func_light" public plugin_precache() {     register_forward( FM_Spawn, "SpawnForward" ) } public SpawnForward( Ent ) {     if( pev_valid( Ent ) )     {         new cname[32]         pev( Ent, pev_classname, cname, 31 )             if( equal( cname, LightClassname ) )         {             engfunc( EngFunc_RemoveEntity, Ent )         }     } } public plugin_init() {     register_plugin( "Light Remover", "1.0", "Wrecked" ) }

BTW, HLTV isn't called on the map start, so you'll have to wait until a new round restart for that to be called. This might be your issue, and you just weren't waiting for another round and assumed it wasn't working right away.

Mr.ToeMayToe 05-31-2010 00:25

Re: Trigger Light
 
Quote:

Originally Posted by wrecked_ (Post 1195772)
Are you looking to just disable the lights? Or do you want them to just be turned off by default at round start?


This plugin removes all lights (make sure the classname is right, wasn't too sure): Code:
#include <amxmodx></p><p>#include <fakemeta></p><p>&nbsp;</p><p>// not sure, correct me if i'm wrong</p><p>new const LightClassname[] = "func_light"</p><p>&nbsp;</p><p>public plugin_precache()</p><p>{</p><p>&nbsp;&nbsp;&nbsp;&nbsp;register_forwar d( FM_Spawn, "SpawnForward" )</p><p>}</p><p>&nbsp;</p><p>public SpawnForward( Ent )</p><p>{</p><p>&nbsp;&nbsp;&nbsp;&nbsp;if( pev_valid( Ent ) )</p><p>&nbsp;&nbsp;&nbsp;&nbsp;{</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;new cname[32]</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;pev( Ent, pev_classname, cname, 31 )</p><p>&nbsp;</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;if( equal( cname, LightClassname ) )</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;{</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;engfunc( EngFunc_RemoveEntity, Ent )</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;}</p><p>&nbsp;&nbsp;&nbsp;&nbsp;}</p><p>}</p><p>&nbsp;</p><p>public plugin_init()</p><p>{</p><p>&nbsp;&nbsp;&nbsp;&nbsp;register_plugin( "Light Remover", "1.0", "Wrecked" )</p><p>}



BTW, HLTV isn't called on the map start, so you'll have to wait until a new round restart for that to be called. This might be your issue, and you just weren't waiting for another round and assumed it wasn't working right away.

Sorry, it did not work. I try to restart round still it is not working.

wrecked_ 05-31-2010 00:43

Re: Trigger Light
 
Quote:

Originally Posted by Mr.ToeMayToe (Post 1195857)
Sorry, it did not work. I try to restart round still it is not working.

It'll work with any other entity classname. Check it with other classnames. Change the LightClassname[] to light and re-test it. If anyone else knows the classname for a light, feel free to correct me.

Mr.ToeMayToe 05-31-2010 01:30

Re: Trigger Light
 
Quote:

Originally Posted by wrecked_ (Post 1195864)
It'll work with any other entity classname. Check it with other classnames. Change the LightClassname[] to light and re-test it. If anyone else knows the classname for a light, feel free to correct me.

What you mean ?

PHP Code:

#include <amxmodx>
#include <fakemeta>
 
// not sure, correct me if i'm wrong
new const light[] = "func_light" or new const LightClassname[][] = "light" Both doesn't work
 
public plugin_precache()
{
    register_forward( FM_Spawn, "SpawnForward" )
}
 
public SpawnForward( Ent )
{
    if( pev_valid( Ent ) )
    {
        new cname[32]
        pev( Ent, pev_classname, cname, 31 )
 
        if( equal( cname, light ) )
        {
            engfunc( EngFunc_RemoveEntity, Ent )
        }
    }
}
 
public plugin_init()
{
    register_plugin( "Light Remover", "1.0", "Wrecked" )



Exolent[jNr] 05-31-2010 01:58

Re: Trigger Light
 
Quote:

Originally Posted by Mr.ToeMayToe (Post 1195708)
Please help !

Don't bump until 2 weeks have passed since the last post.


All times are GMT -4. The time now is 05:25.

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