Garry's Mod Wiki

Entity:DeleteOnRemove

void Entity:DeleteOnRemove( Entity entityToRemove )

Description

Whenever the entity is removed, entityToRemove will be removed also.

Arguments

1 Entity entityToRemove
The entity to be removed

Example

Creates a second chair in spawned jeeps that is removed when the jeep is removed

hook.Add("PlayerSpawnedVehicle", "VehicleUpgrade", function(ply,vehicle) if vehicle:GetClass() == "prop_vehicle_jeep" then local seat = ents.Create( 'prop_vehicle_prisoner_pod' ) seat:SetModel( "models/nova/jeep_seat.mdl" ) seat:SetPos( vehicle:LocalToWorld(Vector(21,-32,18)) ) seat:SetAngles( vehicle:LocalToWorldAngles(Angle(0,-3.5,0)) ) seat:Spawn() seat:SetKeyValue( "limitview", 0 ) table.Merge( seat, { HandleAnimation = function(_,ply) return ply:SelectWeightedSequence( ACT_HL2MP_SIT ) end } ) gamemode.Call( "PlayerSpawnedVehicle", ply, seat ) vehicle.PassengerSeat = seat vehicle:DeleteOnRemove(seat) //<-- constraint.Weld(seat, vehicle) end end)

Page Links


Special Pages


Wikis

?

Render Time: 21ms

Session 0
DB GetPage 2
Generate Html 2
SaveChanges 8
Render Body 0
Render Sidebar 6