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

Attach Dynamic Light to Model


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
SamuraiBarbi
Senior Member
Join Date: Aug 2006
Location: United States
Old 05-21-2009 , 18:01   Attach Dynamic Light to Model
Reply With Quote #1

Hello thar! I'm trying to attach a dynamic light to a model so that they light will move around with the model, but it's not attaching to the model when I try setparent. Both entities spawn, but the light just won't attach to the prop I spawned. Can anyone spot what I may be doing incorrectly or give some pointers? Here's my code:

Code:
        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);
        DispatchSpawn(target_propIndex);

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

        SetEntityMoveType(target_propIndex, MOVETYPE_VPHYSICS);
        SetEntProp(target_propIndex, Prop_Data, "m_nSolidType", 6);
        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");
        AcceptEntityInput(target_flareIndex, "SetParent", target_propIndex, target_flareIndex, 0);
        


        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");
        DispatchSpawn(target_flareIndex);
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-22-2009 , 13:02   Re: Attach Dynamic Light to Model
Reply With Quote #2

I also tried to dispatch key value parentname on the light and that didn't seem to do anything 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
strontiumdog
Veteran Member
Join Date: Jan 2007
Location: BC, Canada
Old 05-22-2009 , 14:25   Re: Attach Dynamic Light to Model
Reply With Quote #3

Give the smoke grenade a targetname.

e.g
Code:
new String:targ[64];
Format(targ, sizeof(targ), "nade%i", target_propIndex);
DispatchKeyValue(target_propIndex, "targetname", targ);
Then you need to attach it to that targetname

Code:
AcceptEntityInput(target_flareIndex, "SetParent", targ);
__________________
Plugins | TheVille
Zombie Mod for DoD:S - l4dod.theville.org
strontiumdog is offline
SamuraiBarbi
Senior Member
Join Date: Aug 2006
Location: United States
Old 05-22-2009 , 16:09   Re: Attach Dynamic Light to Model
Reply With Quote #4

Quote:
Originally Posted by strontiumdog View Post
Give the smoke grenade a targetname.

e.g
Code:
new String:targ[64];
Format(targ, sizeof(targ), "nade%i", target_propIndex);
DispatchKeyValue(target_propIndex, "targetname", targ);
Then you need to attach it to that targetname

Code:
AcceptEntityInput(target_flareIndex, "SetParent", targ);
That should have worked but when I add that the light still isn't attaching to the model I've spawned. Here's my code:

Code:
        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", 6);
        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);
        AcceptEntityInput(target_flareIndex, "SetParent", prop);

Last edited by SamuraiBarbi; 05-22-2009 at 16:20.
SamuraiBarbi is offline
Send a message via AIM to SamuraiBarbi Send a message via MSN to SamuraiBarbi Send a message via Yahoo to SamuraiBarbi
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 05-22-2009 , 21:14   Re: Attach Dynamic Light to Model
Reply With Quote #5

Does that even compile?

PHP Code:
SetVariantString(targetname);
AcceptEntityInput(child"SetParent"); 
Fyren is offline
SamuraiBarbi
Senior Member
Join Date: Aug 2006
Location: United States
Old 05-24-2009 , 16:41   Re: Attach Dynamic Light to Model
Reply With Quote #6

OMFG, I love you! That was exactly what I needed to get it to work.

10 million internets to you!
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 04:00.


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