AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Change KeyValues of an already spawned entity (https://forums.alliedmods.net/showthread.php?t=317603)

KarlPolice 07-21-2019 05:32

Change KeyValues of an already spawned entity
 
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?

Ilusion9 07-21-2019 05:45

Re: Change KeyValues of an already spawned entity
 
Save the entity in a global variable. Also, you should check if that entity has a netptop with "spread" in it ...

Neuro Toxin 07-23-2019 16:57

Re: Change KeyValues of an already spawned entity
 
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.

Dragokas 07-31-2019 14:25

Re: Change KeyValues of an already spawned entity
 
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"); 


Neuro Toxin 07-31-2019 18:28

Re: Change KeyValues of an already spawned entity
 
You would need to trigger it to execute


All times are GMT -4. The time now is 18:21.

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