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

What is the usage of IsValidEntity & IsValidEdict?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
chu1720
Senior Member
Join Date: Mar 2010
Location: Hong Kong
Old 09-13-2010 , 23:42   What is the usage of IsValidEntity & IsValidEdict?
Reply With Quote #1

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?
chu1720 is offline
Send a message via MSN to chu1720
Death [GER]
Senior Member
Join Date: Mar 2010
Old 09-14-2010 , 00:50   Re: What is the usage of IsValidEntity & IsValidEdict?
Reply With Quote #2

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.
__________________
Death [GER] is offline
AtomicStryker
Veteran Member
Join Date: Apr 2009
Location: Teutonia!!
Old 09-14-2010 , 19:47   Re: What is the usage of IsValidEntity & IsValidEdict?
Reply With Quote #3

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
AtomicStryker is offline
honorcode23
BANNED
Join Date: Mar 2010
Location: Chile
Old 09-18-2010 , 15:04   Re: What is the usage of IsValidEntity & IsValidEdict?
Reply With Quote #4

Quote:
Originally Posted by AtomicStryker View Post
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 . (Using 'IsValidEdict' with SDKHOOks use to crash my server, so i just wonder the difference )
honorcode23 is offline
AtomicStryker
Veteran Member
Join Date: Apr 2009
Location: Teutonia!!
Old 09-18-2010 , 18:16   Re: What is the usage of IsValidEntity & IsValidEdict?
Reply With Quote #5

According to bailopans blog
Quote:
For the purposes of SourceMod, a CBaseEntity, entity, edict, and edict index are all the same thing.
AtomicStryker is offline
honorcode23
BANNED
Join Date: Mar 2010
Location: Chile
Old 09-19-2010 , 03:33   Re: What is the usage of IsValidEntity & IsValidEdict?
Reply With Quote #6

Quote:
Originally Posted by AtomicStryker View Post
According to bailopans blog
w00t. Alright, thanks alot!
honorcode23 is offline
pRED*
Join Date: Dec 2006
Old 09-19-2010 , 04:12   Re: What is the usage of IsValidEntity & IsValidEdict?
Reply With Quote #7

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.
pRED* is offline
AtomicStryker
Veteran Member
Join Date: Apr 2009
Location: Teutonia!!
Old 09-19-2010 , 08:11   Re: What is the usage of IsValidEntity & IsValidEdict?
Reply With Quote #8

Then why can IsValidEntity return Invalid Edict, if it should be the other way around
AtomicStryker is offline
schmidt
BANNED
Join Date: Mar 2010
Location: Milky Way/Earth
Old 01-13-2012 , 18:15   Re: What is the usage of IsValidEntity & IsValidEdict?
Reply With Quote #9

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
schmidt is offline
Send a message via Skype™ to schmidt
Reply



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 11:41.


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