Raised This Month: $32 Target: $400
 8% 

Turn off and Kill Light_dynamic Ent


Post New Thread Reply   
 
Thread Tools Display Modes
KMFrog
Senior Member
Join Date: Oct 2007
Old 11-17-2007 , 12:34   Re: Turn off and Kill Light_dynamic Ent
Reply With Quote #11

i dont know about you, but i find ES horrid to try and read through.. so good luck ;]

the interesting part is this:

Code:
es_give event_var(userid) light_dynamic
  es est_setentname server_var(eventscripts_lastgive) server_var(mn_flare_light_name)
  es_fire event_var(userid) server_var(mn_flare_light_name) addoutput "angles -90 0 0"
  es_fire event_var(userid) server_var(mn_flare_light_name) addoutput server_var(mn_flare_light_color)
  es_fire event_var(userid) server_var(mn_flare_light_name) addoutput "_inner_cone -89"
  es_fire event_var(userid) server_var(mn_flare_light_name) addoutput "_cone -89"
  es_fire event_var(userid) server_var(mn_flare_light_name) addoutput "pitch -90"
  es_fire event_var(userid) server_var(mn_flare_light_name) addoutput server_var(mn_flare_light_dist_)
  es_fire event_var(userid) server_var(mn_flare_light_name) addoutput server_var(mn_flare_light_spot_)
  es_fire event_var(userid) server_var(mn_flare_light_name) addoutput server_var(mn_flash_xyz)
  es_fire event_var(userid) server_var(mn_flare_light_name) addoutput server_var(mn_flare_light_brightness)
  es_fire event_var(userid) server_var(mn_flare_light_name) addoutput server_var(mn_flare_light_style_)
  es_fire event_var(userid) server_var(mn_flare_light_name) addoutput "spawnflags 0"
  if(server_var(mn_flare_type) == 2) then es_fire event_var(userid) server_var(mn_flare_light_name) SetParent server_var(mn_flare_flash_name)
  
  // Deletes the flare after mn_flare_time seconds, Must turn off light first
  es_delayed server_var(mn_flare_time) es_fire event_var(userid) server_var(mn_flare_light_name) TurnOff
  es_delayed server_var(mn_f_delayed) es_fire event_var(userid) server_var(mn_flare_light_name) Kill
its pretty much doing the same thing as what im after, except using a flashbang_detonate to get the xyz.. where as my example above is using bullet_impact

Update:
ive been playing with env_lightglow (also featured in that ES to give the flare a "burning" effect) and i can turn the light on and off without a problem - so it seams this problem is specific to light_dynamic
Attached Files
File Type: txt es_mn_flare_212.txt (10.7 KB, 161 views)

Last edited by KMFrog; 11-17-2007 at 15:19. Reason: progress update
KMFrog is offline
SamuraiBarbi
Senior Member
Join Date: Aug 2006
Location: United States
Old 11-22-2007 , 14:17   Re: Turn off and Kill Light_dynamic Ent
Reply With Quote #12

I've seen that script before. The thing is, it's buggy. IE, sometimes the it will kill the light, other times it won't. And when it doesn't kill the light, the light sticks around until the end of the map =/.

There's got to be a way to kill the light in SM and have it work 100% of the time though.
SamuraiBarbi is offline
Send a message via AIM to SamuraiBarbi Send a message via MSN to SamuraiBarbi Send a message via Yahoo to SamuraiBarbi
KMFrog
Senior Member
Join Date: Oct 2007
Old 01-17-2008 , 15:10   Re: Turn off and Kill Light_dynamic Ent
Reply With Quote #13

soooo I'm still trying to work out how to do this.

I now have a working dynamic light that kills itself (using the temp ent api) and there is 1 final problem:

The light works fine until the player either:
- Creates another TE (Using SM)
- Fires a weapon (which I'm guessing also creates a dynamic light TE?)

Its looking like a player can only "own" one TE at a time - is this correct?
If so, how would i go about creating a TE dynamic light that does not get removed when the player creates a new one (by gunfire or w/e)

Code:
        TE_Start("Dynamic Light");
        TE_WriteVector("m_vecOrigin", Origin);
        TE_WriteNum("r", 0);
        TE_WriteNum("b", 255);
        TE_WriteNum("g", 0);
        TE_WriteNum("exponent", 50);
        TE_WriteFloat("m_fRadius", 200.0);
        TE_WriteFloat("m_fTime", 22.0);
        TE_WriteFloat("m_fDecay", 0.1);
        TE_SendToAll(0.0);
__________________
Was I helpful or not? Rate Me!
KMFrog is offline
L. Duke
Veteran Member
Join Date: Apr 2005
Location: Walla Walla
Old 01-19-2008 , 23:16   Re: Turn off and Kill Light_dynamic Ent
Reply With Quote #14

As far as I know, there can only be one TE dynamic light at a time so that approach is probably out.

I saw this on *another* forum
Quote:
"Dynamic Light" Shines a spot light down on the player. Only one 'Dynamic Light' can exist at a time.
__________________
"Good grammar is essential, Robin."
- Batman
L. Duke is offline
KMFrog
Senior Member
Join Date: Oct 2007
Old 01-20-2008 , 00:11   Re: Turn off and Kill Light_dynamic Ent
Reply With Quote #15

Shame

I will have to create a non-temp ent then. I can create as many as I need, but the only problem is I cannot turn off the lights & kill them on demand which is functionality I must have....

Example (again):
Code:
#include <sourcemod>
#include <sdktools>

// Hook event to create ent
//------------------------------------------------------------------------------
public OnPluginStart()
{
    HookEvent("bullet_impact",CreateEnt);
}
//------------------------------------------------------------------------------

// Create ent
//------------------------------------------------------------------------------
public CreateEnt(Handle:event,const String:name[],bool:dontBroadcast)
{
    decl String:new_origin[100] = {};
    Format(new_origin,sizeof(new_origin),"%f %f %f", GetEventFloat(event,"x"),GetEventFloat(event,"y"),GetEventFloat(event,"z"));
     
    new ent = CreateEntityByName("light_dynamic");
    if (ent == -1)
    {
        return;
    }

    //DispatchKeyValue(ent, "name", "my_light");
    //DispatchKeyValue(ent, "targetname", "my_light");
    DispatchKeyValue(ent, "_light", "0 0 255");
    DispatchKeyValue(ent, "distance", "256");
    DispatchKeyValue(ent, "spotlight_radius", "100");
    DispatchKeyValue(ent, "origin", new_origin);
    DispatchKeyValue(ent, "brightness", "2");
    DispatchKeyValue(ent, "style", "0");

    DispatchSpawn(ent);
    
    CreateTimer(10.0, kill_ent, ent);

}
//------------------------------------------------------------------------------

// Timer to kill ent
//------------------------------------------------------------------------------
public Action:kill_ent(Handle:timer, any:ent)
{
    LogToGame("killing light");
    PrintToChatAll("killing light");
    
    AcceptEntityInput(ent, "TurnOff");
    AcceptEntityInput(ent, "Kill");
    
    RemoveEdict(ent);
}
//------------------------------------------------------------------------------
This code does appear to remove the ents, as the lights do turn off (and i guess remove themselves) but only if you wait till the original light has been killed by the code, then create a new ent. If you create a new ent before the original has been killed, it will stay visible (presumably) forever.

SM bug?
Engine bug?
Something isn't right
__________________
Was I helpful or not? Rate Me!
KMFrog is offline
Scuzzy
Senior Member
Join Date: Oct 2007
Old 06-24-2008 , 17:35   Re: Turn off and Kill Light_dynamic Ent
Reply With Quote #16

I would very much like to do something like this. I'd like to simulate "flares" in TFC. A player could have 3 at a time, which would fire out and slowly lose their brightness. Were you able to get this to work? Any idea on how I could do what I'd like too?

Scuzzy
Scuzzy is offline
SamuraiBarbi
Senior Member
Join Date: Aug 2006
Location: United States
Old 05-24-2009 , 17:53   Re: Turn off and Kill Light_dynamic Ent
Reply With Quote #17

Holy thread resurrection batman! Seriously though, has anyone the slightest idea how to remove light_dynamic entities that have been created?

This problem has recently resurfaced for me and I'm determined to find a solution this time around.
SamuraiBarbi is offline
Send a message via AIM to SamuraiBarbi Send a message via MSN to SamuraiBarbi Send a message via Yahoo to SamuraiBarbi
SamuraiBarbi
Senior Member
Join Date: Aug 2006
Location: United States
Old 05-25-2009 , 03:11   Re: Turn off and Kill Light_dynamic Ent
Reply With Quote #18

So as I'm just full of questions, here's another couple for good measure

1) TE Dynamic Light. How many of these can be made?

Quote:
Originally Posted by L. Duke View Post
As far as I know, there can only be one TE dynamic light at a time so that approach is probably out.
Is that true, that there can only be one TE dynamic light at a time?


2) Is there a way to SetParent for a TE Dynamic Light?


3) Is there any reliable way to actually remove a light dynamic entity that you've created? The topic has been raised on both Sourcemods and Eventscripts forums and I haven't been able to determine a reliable solution through either.
SamuraiBarbi is offline
Send a message via AIM to SamuraiBarbi Send a message via MSN to SamuraiBarbi Send a message via Yahoo to SamuraiBarbi
SamuraiBarbi
Senior Member
Join Date: Aug 2006
Location: United States
Old 05-26-2009 , 16:28   Re: Turn off and Kill Light_dynamic Ent
Reply With Quote #19

I'm still trying to figure out how to remove light_dynamic entities that I've created, or at least get them to actually turn off so they seem like they've been removed. Below is code I've been working on which effectively turns the smoke grenade in Counter Strike Source into a flare ( which happens to smoke a lot when it first goes off, ). The problem of course is that the light_dynamic entities I create are lingering even after the code designed to remove them has fired.

Code:
#pragma semicolon 1



#include <sourcemod>
#include <sdktools>
#include <sdktools_trace>
#include <clients>
#include <hacks>


new Handle:h_lightDynamicList;


    public OnPluginStart()
    {
        HookEvent("smokegrenade_detonate", Event_SmokeGrenadeDetonate, EventHookMode_Post);
        
        HookEvent("round_start", Hook_RoundStart);
        
        HookEvent("round_end", Hook_RoundEnd);
    }

    public Action:Event_SmokeGrenadeDetonate(Handle:event, const String:name[], bool:dontBroadcast)
    {
        new target_playerID = GetEventInt(event,"userid");
        new target_playerClient = GetClientOfUserId(target_playerID);
        
        new Float:target_entityCoordX = GetEventFloat(event, "x");
        
        new Float:target_entityCoordY = GetEventFloat(event, "y");
        
        new Float:target_entityCoordZ = GetEventFloat(event, "z");
        
        CreateFlare(target_playerClient, target_entityCoordX, target_entityCoordY, target_entityCoordZ);
    }
    
    public Action:Hook_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
    {    
        h_lightDynamicList = CreateArray();    
    }
    
    public Action:Hook_RoundEnd(Handle:event, const String:name[], bool:dontBroadcast)
    {
        ResetLightDynamic();
    }
    
    
    public CreateFlare(any:target_playerClient, Float:target_entityCoordX, Float:target_entityCoordY, Float:target_entityCoordZ)
    {
        new String:target_entityCoord[50];
        Format(target_entityCoord, sizeof(target_entityCoord), "%f %f %f", target_entityCoordX, target_entityCoordY, target_entityCoordZ);

        /**
         * Make the prop
         */

        new target_propIndex = CreateEntityByName("prop_physics_override");

        SetEntityModel(target_propIndex, "models/weapons/w_eq_smokegrenade.mdl");
        DispatchKeyValue(target_propIndex, "origin", target_entityCoord);

        new String:prop[64];
        Format(prop, sizeof(prop), "prop%i", target_propIndex);
        DispatchKeyValue(target_propIndex, "targetname", prop);

        DispatchSpawn(target_propIndex);

        SetEntProp(target_propIndex, Prop_Data, "m_CollisionGroup", 2);

        SetEntityMoveType(target_propIndex, MOVETYPE_VPHYSICS);
        SetEntProp(target_propIndex, Prop_Data, "m_nSolidType", 2);
        SetEntProp(target_propIndex, Prop_Data, "m_takedamage", 0);

        /**
         * Make the flare
         */

        new Float:brightness = 6.0;

        new String:brightness_s[20];
        FloatToString(brightness, brightness_s, sizeof(brightness_s));

        new target_flareIndex = CreateEntityByName("light_dynamic");
        DispatchKeyValue(target_flareIndex, "_light", "245 0 0");
        DispatchKeyValue(target_flareIndex, "origin", target_entityCoord);
        DispatchKeyValue(target_flareIndex, "brightness", brightness_s);
        DispatchKeyValue(target_flareIndex, "distance", "256");
        DispatchKeyValue(target_flareIndex, "style", "6");

        new String:flare[64];
        Format(flare, sizeof(flare), "flare%i", target_flareIndex);
        DispatchKeyValue(target_flareIndex, "targetname", flare);
        DispatchKeyValue(target_flareIndex, "paretname", prop);
        DispatchSpawn(target_flareIndex);
        SetVariantString(prop);
        AcceptEntityInput(target_flareIndex, "SetParent");

        PushArrayCell(h_lightDynamicList, target_flareIndex);

        /**
         * Make the glow
         */

        new target_glowIndex = CreateEntityByName("env_lightglow");
        DispatchKeyValue(target_glowIndex, "rendercolor", "250 0 0");
        DispatchKeyValue(target_glowIndex, "VerticalGlowSize", "16");
        DispatchKeyValue(target_glowIndex, "HorizontalGlowSize", "16");
        DispatchKeyValue(target_glowIndex, "MinDist", "9000");
        DispatchKeyValue(target_glowIndex, "MaxDist", "0");
        DispatchKeyValue(target_glowIndex, "GlowProxySize", "2.0");
        DispatchKeyValue(target_glowIndex, "HDRColorScale", "1.0");
        DispatchKeyValue(target_glowIndex, "origin", target_entityCoord);

        new String:glow[64];
        Format(glow, sizeof(glow), "glow%i", target_glowIndex);
        DispatchKeyValue(target_glowIndex, "targetname", glow);
        DispatchKeyValue(target_glowIndex, "paretname", prop);
        DispatchSpawn(target_glowIndex);
        SetVariantString(prop);
        AcceptEntityInput(target_glowIndex, "SetParent");
        
    }
    
    public ResetLightDynamic()
    {
        new target_lightDynamicSpawned = GetArraySize(h_lightDynamicList);
        
        for (new i = 0; i < target_lightDynamicSpawned; i++)
        {
            new target_entityIndex = GetArrayCell(h_lightDynamicList, i);
            
            UpdateLightDynamic(target_entityIndex);            
        }
        
        CloseHandle(h_lightDynamicList);
    }
    
    public UpdateLightDynamic(any:target_entityIndex)
    {
        new target_entityValidStatus = IsValidEntity(target_entityIndex);
        
        if (target_entityValidStatus == 1)
        {
            AcceptEntityInput(target_entityIndex, "TurnOff");
            AcceptEntityInput(target_entityIndex, "Kill");
        
            RemoveEdict(target_entityIndex);
            
            PrintToChatAll("removing light dynamic index %i", target_entityIndex);
        }    
    }
SamuraiBarbi is offline
Send a message via AIM to SamuraiBarbi Send a message via MSN to SamuraiBarbi Send a message via Yahoo to SamuraiBarbi
Reply


Thread Tools
Display Modes

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 20:58.


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