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

Change KeyValues of an already spawned entity


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
KarlPolice
New Member
Join Date: Mar 2018
Old 07-21-2019 , 05:32   Change KeyValues of an already spawned entity
Reply With Quote #1

How can I change the KeyValues of an already spawned entity. What I know is, I've never seen or tried this is the actual Source SDK Hammer Editor. Not sure if it is possible doing it with a script.


But how can I do it with SourceMod?

Let's take this as an example: https://forums.alliedmods.net/showthread.php?t=288850

PHP Code:
new gunfire CreateEntityByName("env_gunfire"); 

DispatchKeyValue(gunfire"spread""1");
DispatchSpawn(gunfire); 
So now the gunfire entity is spawned.
Let's say I want to change the spread again. How can I do that? So what I know is I wouldn't be able to access the entity anymore by using the gunfire variable. I would need to get the entity first.

But if I get the entity, how can I change the KeyValues then?
__________________
Hotrod Turrets!

Last edited by KarlPolice; 07-21-2019 at 05:32.
KarlPolice is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 07-21-2019 , 05:45   Re: Change KeyValues of an already spawned entity
Reply With Quote #2

Save the entity in a global variable. Also, you should check if that entity has a netptop with "spread" in it ...
__________________
Ilusion9 is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 07-23-2019 , 16:57   Re: Change KeyValues of an already spawned entity
Reply With Quote #3

KeyValues before dispatch of the entity will end up being translated to their associated netprops. This doesnt mean the KeyValue and netprop has the same name or data types.

As suggested by Ilusion9 and to expand.

You want to use sm_dump_netprops from the server console. Find env_gunfire in your dump and find the associated netprob.
__________________
Neuro Toxin is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine
Old 07-31-2019 , 14:25   Re: Change KeyValues of an already spawned entity
Reply With Quote #4

According to valve wiki, AddOutput supports 2 formats.
https://developer.valvesoftware.com/wiki/AddOutput

But, it looks like that doesn't work when entity is already spawned.
PHP Code:
SetVariantString("disableshadows 1");
AcceptEntityInput(client"AddOutput"); 
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch)
[My plugins] [My tools] [GitHub] [Articles]
Dragokas is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 07-31-2019 , 18:28   Re: Change KeyValues of an already spawned entity
Reply With Quote #5

You would need to trigger it to execute
__________________
Neuro Toxin is offline
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 06:15.


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