Skip to content

Helpers

Helper Does
AddCommand( "name", cmd => ..., "help", adminOnly, "args" ) Chat command /name. cmd.Player typed it, cmd.Args holds the words after it, cmd.Arg( 0 ) the first one in lower case (“” if missing). It shows in /help and in the chat’s suggestions while typing, with args (for example "join | leave")
After( seconds, () => ... ), Every( seconds, () => ... ) Run code later, once or repeatedly
Reply( player, text ), Broadcast( text ) Chat line for one player, or everyone, starting with [Name]. Rich text: see below
Puts( text ) Line in the server console
Players, FindPlayer( nameOrSteamId ) Connected players
Give( player, "M4", 1 ), GiveKit( player, "kevlar" ) Items by their name in the admin menu; kits of the admin menu (starter, kevlar, builder, raider, mining, research, medical, resources)
SaveInventory( player ), RestoreInventory( player, saved ) Copy an inventory and put it back. The copy can go in your data file
Respawn( player ) Respawn a dead player now, without a sleeping bag
IsAdmin( player ) The host of a lobby, or an admin of the dedicated server (admin claim in users.json, or made admin from Admin > Players). Commands with adminOnly use it. The server owner can also reserve a whole plugin for admins (rl_plugins_admin_only, section 1)
SetButton( player, "id", "label", "/command", key ), RemoveButton( player, "id" ) A button in the player’s inventory screen that runs a chat command. key 1 to 4 also binds it to Server plugin key N (0: no key). Same id again: the button is updated (its label can show a state, “Fly: ON”)
ShowMenu( player, menu ), CloseMenu( player ) A window with buttons, see below
SetFly( player, on ) Fly like an admin (it stops at death). player.IsFlying tells the state
SetFrozen( player, on ) Freeze a player: they cannot walk or jump, they can still look, shoot and talk (jail, AFK check, an admin’s freeze). player.IsFrozen tells the state. Released when the plugins restart
SetChatTag( player, "[VIP]", "#ffcc00", "star", "Supporter" ) A tag before the player’s name in the public chat, for everyone (a group, a clan), with an optional icon before it: the name of a Material icon ("star", "verified", "gavel"), in the tag’s color, or an image address (see Images). Admins already have a shield; an icon replaces it. The last value is the icon’s tooltip, the tag by default; give one to a tag that is just an icon: SetChatTag( player, "", "#ffcc00", "star", "VIP" ). "" for both removes it. Removed when the plugins restart: set it again in OnLoaded and OnPlayerConnected
SetHudText( player, "id", text, corner, image ), RemoveHudText( player, "id" ) Rich text on the player’s HUD, in a corner: topleft, top, topright (default) or right, with an optional image above it (see Images). Same id again: replaced. Update it from a timer (Every) to show a score or a distance
SetMarker( player, "id", position, label ), RemoveMarker( player, "id" ) A marker on a point of the world: its label and ground distance float over the point (at the screen’s edge when it is out of view), with a flag on the map (G). Same id again: moved
Meters( a, b ), Compass( from, to ), MapCell( position ) Ground distance in meters; direction on the game’s map (“north-east”); map square (“F7”)
RegisterPermission( "kits.vip" ) Declare a permission of your plugin (listed by rl_perm list)
HasPermission( steamId, "kits.vip" ) May this player use it? Admins may use everything
InGroup( steamId, "vip" ), GroupsOf( steamId ), AllGroups Groups of a player, all groups
CreateGroup( "vip", parent ), AddToGroup( steamId, "vip" ), RemoveFromGroup( ... ) Manage groups (saved at once)
GrantPermission( groupOrSteamId, perm ), RevokePermission( ... ) Manage permissions
PlayerCount, MaxPlayers Players connected and slots of the server
LoadConfig<T>() Settings from plugins/config/<Name>.json, written with T’s defaults the first time
SaveConfig( config ) Write the settings back (an admin changed them in game)
LoadData<T>(), SaveData( data ) Your data in plugins/data/<Name>.json, kept across restarts: scores, positions, each player’s settings (Airdrop keeps what every player chose to see). T is a class of your file with properties { get; set; }; lists and dictionaries work
Scene, Name The server’s scene, and the plugin’s name

Building pieces and placed objects (boxes, doors, fires, beds, custom objects) are GameObjects; these helpers read and change them without knowing the game’s classes:

Helper Does
Aimed( player, meters ) What the player looks at, within meters (4 by default): a placed object, a building piece, a player or an animal; null if nothing
OwnerOf( placed ) SteamID of who placed an object, or of who started a building for one of its pieces; "" otherwise
PlacedItem( placed ) The item a placed object or piece is made of (.DisplayTitle, .Title), a custom item’s too; null otherwise
IsItem( placed, "id" ) Is this placed object or piece your custom item id?
PlacedBy( steamId ) Every object a player placed and every piece of their buildings
Demolish( placed ) Destroy an object (its contents fall in a bag) or a piece (and what rested on it). Nothing is given back: Give( player, PlacedItem( placed ).DisplayTitle ) first to refund it
// /owner: an admin looks at a wall and learns whose it is
void OnOwner( ChatCommand cmd )
{
var target = Aimed( cmd.Player, 10f );
var owner = target != null ? OwnerOf( target ) : "";
Reply( cmd.Player, owner == "" ? "Nobody's." : $"{PlacedItem( target )?.DisplayTitle} of {owner}" );
}