AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   What is the usage of IsValidEntity & IsValidEdict? (https://forums.alliedmods.net/showthread.php?t=138101)

chu1720 09-13-2010 23:42

What is the usage of IsValidEntity & IsValidEdict?
 
I see many plugins will use these two functions to check "something" before they actuallly do something. What is the use of these two functions? What is the differences?

Death [GER] 09-14-2010 00:50

Re: What is the usage of IsValidEntity & IsValidEdict?
 
Its use is to check if whatever index you have is valid or not. Means, if it is existing.

for example if you create a entity with an invalid classname and after that check it will return false so you can stop at this point to prevent errors.

AtomicStryker 09-14-2010 19:47

Re: What is the usage of IsValidEntity & IsValidEdict?
 
If you use RemoveEdict and some other functions on an invalid Entity index your server will crash.

The difference between Edict and Entity ... i'd use Edict because Entity sometimes returns "invalid Edict" ahaha

honorcode23 09-18-2010 15:04

Re: What is the usage of IsValidEntity & IsValidEdict?
 
Quote:

Originally Posted by AtomicStryker (Post 1299639)
If you use RemoveEdict and some other functions on an invalid Entity index your server will crash.

The difference between Edict and Entity ... i'd use Edict because Entity sometimes returns "invalid Edict" ahaha

So whats the concrete difference between them? Always wondered, and i think its a good place to ask :P. (Using 'IsValidEdict' with SDKHOOks use to crash my server, so i just wonder the difference :P)

AtomicStryker 09-18-2010 18:16

Re: What is the usage of IsValidEntity & IsValidEdict?
 
According to bailopans blog
Quote:

For the purposes of SourceMod, a CBaseEntity, entity, edict, and edict index are all the same thing.

honorcode23 09-19-2010 03:33

Re: What is the usage of IsValidEntity & IsValidEdict?
 
Quote:

Originally Posted by AtomicStryker (Post 1302980)
According to bailopans blog

w00t. Alright, thanks alot!

pRED* 09-19-2010 04:12

Re: What is the usage of IsValidEntity & IsValidEdict?
 
This has actually changed since that blog post was written.

An entity is only understood by the game code, an edict is the engines representation of an entity (and used to network data about the entity to players).

All edicts should have a matching entity, but some entities can exist without an edict. Logic style entities that don't have a client side entity won't have an edict, as they never get networked and exist purely for server side logic purposes.

AtomicStryker 09-19-2010 08:11

Re: What is the usage of IsValidEntity & IsValidEdict?
 
Then why can IsValidEntity return Invalid Edict, if it should be the other way around

schmidt 01-13-2012 18:15

Re: What is the usage of IsValidEntity & IsValidEdict?
 
Although I read this topic, but could not find a specific answer to the question.
You have to do this:

PHP Code:

if (IsValidEntity(ent) && IsValidEdict(ent)) ... 

or:

PHP Code:

if (IsValidEntity(ent)) ... 

or:

PHP Code:

if (IsValidEdict(ent)) ... 

???

Give an example of proper and improper use of these functions :(


All times are GMT -4. The time now is 19:16.

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