AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   How do I change an entity's flags? (https://forums.alliedmods.net/showthread.php?t=272517)

Dr. Jekyll 10-02-2015 01:23

How do I change an entity's flags?
 
I need to change the flags on a player's sentry gun so that it cannot be upgraded. I've found the function to set and get entity flags, and I've figured out how to get the index of the sentry gun, but I don't understand how to use the SetEntityFlags function. Here's the Sourcemod API page for the function: https://sm.alliedmods.net/new-api/en...SetEntityFlags

Here's the entity page for the sentry: https://developer.valvesoftware.com/wiki/Obj_sentrygun

I want to either remove or disable the "upgradable" flag. What do I enter for the second argument on the "SetEntityFlags(entity, flags)" function to make this happen?

lazarev 10-02-2015 02:19

Re: How do I change an entity's flags?
 
my guess:

PHP Code:

SetEntityFlags(entity,GetEntityFlags(entity) & ~(1<<2)); // 4 - upgradable 


psychonic 10-02-2015 08:26

Re: How do I change an entity's flags?
 
Quote:

Originally Posted by Dr. Jekyll (Post 2348838)
Here's the entity page for the sentry: https://developer.valvesoftware.com/wiki/Obj_sentrygun

I want to either remove or disable the "upgradable" flag. What do I enter for the second argument on the "SetEntityFlags(entity, flags)" function to make this happen?

That's likely a spawn flag, not an "entity flag". You would use similar to the above logic, but with SetEntProp and the "m_spawnflags" variable. However, changes to it may not do anything after the entity has already been spawned. (Just looked and it seems like it will work in this case)

Dr. Jekyll 10-02-2015 13:04

Re: How do I change an entity's flags?
 
Quote:

Originally Posted by psychonic (Post 2348893)
That's likely a spawn flag, not an "entity flag". You would use similar to the above logic, but with SetEntProp and the "m_spawnflags" variable. However, changes to it may not do anything after the entity has already been spawned. (Just looked and it seems like it will work in this case)

Thanks, I'll try this tonight.

Dr. Jekyll 10-02-2015 21:03

Re: How do I change an entity's flags?
 
Quote:

Originally Posted by psychonic (Post 2348893)
That's likely a spawn flag, not an "entity flag". You would use similar to the above logic, but with SetEntProp and the "m_spawnflags" variable. However, changes to it may not do anything after the entity has already been spawned. (Just looked and it seems like it will work in this case)

So here are the arguments I'm using. Is this correct?

SetEntProp(ent, bool, "m_spawnflags_upgradable", false, 4, 0);

I should probably mention that ent is the name of an int I'm using to store the index of the sentry.

lazarev 10-04-2015 01:37

Re: How do I change an entity's flags?
 
Quote:

Originally Posted by Dr. Jekyll (Post 2349118)
So here are the arguments I'm using. Is this correct?

no. read the API info https://sm.alliedmods.net/new-api/entity/SetEntProp

Miu 10-04-2015 08:45

Re: How do I change an entity's flags?
 
SetEntProp(ent, Prop_Data, "m_spawnflags_upgradable", 0)

Dr. Jekyll 11-01-2015 00:23

Re: How do I change an entity's flags?
 
Quote:

Originally Posted by Miu (Post 2349654)
SetEntProp(ent, Prop_Data, "m_spawnflags_upgradable", 0)

I was just looking back through my posts and I realized I forgot to thank you for posting this. Unfortunately it's not working for some reason. The buildings can still be upgraded. Is there any reason I should be using SetEntProp instead of SetEntityFlags?

Chdata 11-01-2015 01:33

Re: How do I change an entity's flags?
 
SetEntProp can affect any netprop.

SetEntityFlags only affects whatever stores the entity's flags, not its spawnflags. Spawnflags are different than entity flags.

Miu 11-01-2015 06:47

Re: How do I change an entity's flags?
 
dunno why I wrote that, you probably want SetEntProp(ent, Prop_Data, "m_spawnflags", 0) instead


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

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