HolyLib Wiki

BroadcastMessage

  gameserver.BroadcastMessage( number type, string name, bf_write buffer )

Description

Sends a custom net message to all clients.
This function allows you send any netmessage you want.
You should know what your doing since this function doesn't validate anything.

Recently Changed

This was recently changed in version (0.8 - DEV).

This function will now check if the given buffer is overflowed and throw a error if it is

Arguments

1number type
You can find all valid types in the protocol.h
2string name
name of broadcast message
3bf_write buffer
buffer

Example

Example usage, we enable sv_cheats clientside while having it disabled serverside.
local bf = bitbuf.CreateWriteBuffer(64) -- Create a 64 bytes buffer. bf:WriteByte(1) -- How many convars were sending bf:WriteString("sv_cheats") -- ConVar name bf:WriteString("1") -- ConVar value -- You can use CBaseClient:SendNetMsg to send it to specific clients. gameserver.BroadcastMessage(5, "NET_SetConVar", bf) -- 5 = net_SetConVar / net message type.