Garry's Mod Wiki


  string GM:EntityKeyValue( Entity ent, string key, string value )


Called when a key-value pair is set on an entity on map spawn. Is not called by Entity:SetKeyValue.

See ENTITY:KeyValue for a scripted entities hook, and its scripted weapon alternative: WEAPON:KeyValue.


1 Entity ent
Entity that the keyvalue is being set on
2 string key
Key of the key/value pair
3 string value
Value of the key/value pair


1 string
If set, the value of the key-value pair will be overridden by this string.


Remove infodecal entities similar to the blue graffiti text behind the big building with numbered floors on gm_construct.
The texture keyvalue cannot be retrieved from infodecal entities.

local unwantedDecals = { ["decals/decalgraffiti031a"] = true, -- etc. } hook.Add( "EntityKeyValue", "remove_unwanted_decals", function( ent, key, value ) if ( key == "texture" and IsValid( ent ) and ent:GetClass() == "infodecal" ) then if ( unwantedDecals[value] ) then -- set a targetname to make the decal remain and not appear automatically: ent:SetName( "remove_unwanted_decals" ) end end end ) local function remove_unwanted_decals() -- remove the decals instead of just keeping them invisible: for _, decal in ipairs( ents.FindByClass( "infodecal" ) ) do if ( decal:GetName() == "remove_unwanted_decals" ) then decal:Remove() end end end hook.Add( "InitPostEntity", "remove_unwanted_decals", remove_unwanted_decals ) hook.Add( "PostCleanupMap", "remove_unwanted_decals", remove_unwanted_decals )