Entity.DeleteOnRemove

From GMod Wiki

Revision as of 16:30, 6 January 2011 by Cube334 (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Function
Syntax Entity:DeleteOnRemove( Entity entityToRemove )
Description:
Whenever the entity is removed, entityToRemove will be removed also.
Returns: nil
In Object: Entity
Realm: NewerServer.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Entity.DeleteOnRemove]Entity.DeleteOnRemove [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Examples

DescriptionFind every brick in the map and make it delete every other brick in the map if it is deleted
Used onNewerServer.png
Code
local props = ents.FindByClass("prop_physics") --Get all the props in the map
local bricks = {} --Table that we will put all the brick models in
 
for _,prop in pairs(props) do
	if prop:GetModel() == "models/props_junk/cinderblock01a.mdl" then --If a brick
		table.Add(bricks,prop) --Add it to the table
	end
end
 
if bricks[2] then --If there is more than one brick
	for _,brick in pairs(bricks) do --For each brick, we want to make it delete every other brick in the map if it gets deleted
		for _, otherbrick in pairs(bricks) do --For every brick, add it to DeleteOnRemove
			if otherbrick ~= brick then --If its not our brick from the first loop
				brick:DeleteOnRemove(otherbrick) --When we delete 'brick' it will delete 'otherbrick'
			end
		end
	end
end
OutputN/A


Additional Notes

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox