AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   What's the best way to detect entity type? (https://forums.alliedmods.net/showthread.php?t=48783)

Simon Logic 12-20-2006 10:01

What's the best way to detect entity type?
 
Also I mean what's the fasterst way?

Most entities are detected by model name. But this is ineffective and not stable cause you can easily change entity model. Well, for beginning assume that i use standard models. Can i use modelindex for that? Or should i cache modelindex while getting a modelname because modelindex can be changed from map to map? May be there is a simple way to detect type via PrivateData (as VEN did with grenade types)?

XxAvalanchexX 12-20-2006 17:09

Re: What's the best way to detect entity type?
 
Using classname.

Simon Logic 12-21-2006 05:06

Re: What's the best way to detect entity type?
 
This is not good because classnames can be the same, but models are different for two (or more) objects.

What's the maximum possible in-game value for modelindex?

XxAvalanchexX 12-21-2006 20:01

Re: What's the best way to detect entity type?
 
Classnames aren't good for identifying what type of entity something is? Classname is what dictates what type of entity something is.

If you are just trying to individualize all of your entities, use their entity indexes, since they are all unique.

Simon Logic 12-22-2006 05:37

Re: What's the best way to detect entity type?
 
Well, i want to detect weapon type. Classnames are the same.

I did some research. modelindex is VERY unreliable & changes from state to state (when attached to player - it's zero; when trhowen - it can be very large). The only way is detection by model :(

The only optimization i see is to enchance equal() function to add one more argument which means what symbol index to start compare, because each model string starts with "moldes/".

The Specialist 12-22-2006 05:40

Re: What's the best way to detect entity type?
 
What exactly are you trying to do ?

Simon Logic 12-22-2006 05:57

Re: What's the best way to detect entity type?
 
There is an array of weapon model strings. Each index corresponds to weapon id. I have an entity id. By classname i detected that it's a weapon ("weaponbox").Then i need to detect a weapon id. Sequental comparison of strings is a shitty method, but 100% workable.

I thought i can do like this:
1) first time detect a weapon id by sequantal comparison of model strings
2) make an association of modelindex -> weapon_id into modelindex2wid array assuming max model index is (for example) 255; so, next time i can get a weapon id immediately: weapon_id = modelindex2wid[entity.modelindex]

But that's not working (see my previous post)!

Is there any other common pev value for weapons of the same type/model, but unique for different types of weapons?

The Specialist 12-22-2006 06:16

Re: What's the best way to detect entity type?
 
getting by a model is a bad way to do it . Its unreliable and can throw off your entire plugin with a model changing plugin on a server , which is a very common thing in servers. Can you explaine what your trying to do ? Theres probly a better way to do it .

Simon Logic 12-22-2006 06:26

Re: What's the best way to detect entity type?
 
I know this. I wrote about it above. That's why i'm asking for help.

I need to detect type of weapon (weapon id) be entity id as fast (less cpu load) as possible.

The Specialist 12-22-2006 06:28

Re: What's the best way to detect entity type?
 
what about
Code:
cs_get_weapon_id()


All times are GMT -4. The time now is 07:10.

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