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

How do I change an entity's flags?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Dr. Jekyll
Member
Join Date: Sep 2015
Old 10-02-2015 , 01:23   How do I change an entity's flags?
Reply With Quote #1

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?
Dr. Jekyll is offline
lazarev
Veteran Member
Join Date: Sep 2008
Old 10-02-2015 , 02:19   Re: How do I change an entity's flags?
Reply With Quote #2

my guess:

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

Last edited by lazarev; 10-02-2015 at 02:19.
lazarev is offline
psychonic

BAFFLED
Join Date: May 2008
Old 10-02-2015 , 08:26   Re: How do I change an entity's flags?
Reply With Quote #3

Quote:
Originally Posted by Dr. Jekyll View Post
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)

Last edited by psychonic; 10-02-2015 at 08:32.
psychonic is offline
Dr. Jekyll
Member
Join Date: Sep 2015
Old 10-02-2015 , 13:04   Re: How do I change an entity's flags?
Reply With Quote #4

Quote:
Originally Posted by psychonic View Post
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 is offline
Dr. Jekyll
Member
Join Date: Sep 2015
Old 10-02-2015 , 21:03   Re: How do I change an entity's flags?
Reply With Quote #5

Quote:
Originally Posted by psychonic View Post
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.
Dr. Jekyll is offline
lazarev
Veteran Member
Join Date: Sep 2008
Old 10-04-2015 , 01:37   Re: How do I change an entity's flags?
Reply With Quote #6

Quote:
Originally Posted by Dr. Jekyll View Post
So here are the arguments I'm using. Is this correct?
no. read the API info https://sm.alliedmods.net/new-api/entity/SetEntProp
lazarev is offline
Miu
Veteran Member
Join Date: Nov 2013
Old 10-04-2015 , 08:45   Re: How do I change an entity's flags?
Reply With Quote #7

SetEntProp(ent, Prop_Data, "m_spawnflags_upgradable", 0)
Miu is offline
Dr. Jekyll
Member
Join Date: Sep 2015
Old 11-01-2015 , 00:23   Re: How do I change an entity's flags?
Reply With Quote #8

Quote:
Originally Posted by Miu View Post
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?
Dr. Jekyll is offline
Chdata
Veteran Member
Join Date: Aug 2012
Location: Computer Chair, Illinois
Old 11-01-2015 , 01:33   Re: How do I change an entity's flags?
Reply With Quote #9

SetEntProp can affect any netprop.

SetEntityFlags only affects whatever stores the entity's flags, not its spawnflags. Spawnflags are different than entity flags.
__________________
Chdata is offline
Miu
Veteran Member
Join Date: Nov 2013
Old 11-01-2015 , 06:47   Re: How do I change an entity's flags?
Reply With Quote #10

dunno why I wrote that, you probably want SetEntProp(ent, Prop_Data, "m_spawnflags", 0) instead
Miu 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 21:28.


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