Skip to main content

constants

Constants are basically keys/identifiers that are used when sending shared variables or sending hooks from server to client. They work similarly to util.AddNetworkString, this is to save bandwidth for simple net messages that are sent.

For example,

Lyn.Player.SetSharedVar(Entity(1), "HeyThisIsMyKeyThatIsAwesome", true)

If we don't use constants, the key will be sent as a string, taking 27 bytes just for the key, when the bool is only one byte. Using constants makes it only two bytes.

To add constants, create a new file lua/lyn/sh_constants/unique_file_name.lua and add each key you will be using inside it, such as:

C "Lyn.Role.SetCommandParamConstraints"
C "Lyn.Role.PreSetExtends"
C "Lyn.Role.SetExtends"