Entity.IsValid

From GMod Wiki

Jump to: navigation, search
Function
Syntax Entity:IsValid( )
Description:
Returns true if the entity is really a valid entity. Does it exist?
Returns: Boolean
In Object: Entity
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Entity.IsValid]Entity.IsValid [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Examples

DescriptionIn this example we use Ent:IsValid() to determine whether or not we should continue on in the function.
Used onNewerServer.png
Code
/*---------------------------------------------------------
   Name: gamemode:PhysgunDrop( pl, ent )
   Desc: Dropped an entity
---------------------------------------------------------*/
function GM:PhysgunDrop( pl, ent )
 
    if ( !ent:IsValid() || !pl:IsValid() ) then return end
 
    // ...
 
end
OutputN/A


Additional Notes

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox