Garry's Mod Wiki

Entity:SetNetworkKeyValue

  boolean Entity:SetNetworkKeyValue( string key, string value )

Description

A helper function to allow setting Network Variables via Entity:SetKeyValue, primarily to allow mappers to set them from Hammer.

Meant to be called from ENTITY:KeyValue, see example.

See also Entity:SetNetworkVarsFromMapInput for a function that does similar thing for map inputs instead.

This function will only work on entities which had Entity:InstallDataTable called on them, which is done automatically for players and all Scripted Entities.

Arguments

1 string key
The key-value name, or simply the "key".
2 string value
The key-value value.

Returns

1 boolean
Whether a network variable was set successfully

Example

Example usage, adding this will allow mappers to set all your key networks as key values. You will also need to provide manually crafted .fgd file that lists all the key values. env_skypaint can be used as an example (garrysmod.fgd and env_skypaint.lua in base gamemode).

function ENT:KeyValue( key, value ) if ( self:SetNetworkKeyValue( key, value ) ) then return end -- Other code... end