RAPI

Get the player username from a SteamID.

Method
Example
Method
string GetUsernameFromSteamID(CSteamID steamid)
Example
string username = RAPI.GetUsernameFromSteamID(playersteamid);
RConsole.Log("The player name is " + username);

Toggle the mouse cursor.

Method
Example
Method
void ToggleCursor(bool var)
Example
RAPI.ToggleCursor(true); // This will show the cursor.
RAPI.ToggleCursor(false); // This will hide the cursor.

Register a new item.

Method
Example
Method
void RegisterItem(Item_Base item)
Example
// Here we load the item from the assetbundle
Item_Base yournewitem = asset.LoadAsset<Item_Base>("yournewitem");
// Then we register it using RegisterItem()
RAPI.RegisterItem(yournewitem);

Set an item prefab.

Method
Example
Method
void SetItemObject(Item_Base item, GameObject prefab)
// The default hand is right. RItemHand can be leftHand or rightHand.
void SetItemObject(Item_Base item, GameObject prefab, RItemHand parent)
Example
// Here we load the item from the assetbundle
Item_Base yournewitem = asset.LoadAsset<Item_Base>("yournewitem");
// Then we register it using RegisterItem()
RAPI.RegisterItem(yournewitem);
// Then we set his prefab by loading it from the assetbundle
RAPI.SetItemObject(yournewitem, asset.LoadAsset<GameObject>("yournewitem"));

Gets the local Network_Player script.

Method
Example
Method
Network_Player GetLocalPlayer()
Example
Network_Player player = RAPI.GetLocalPlayer();
// The player variable will contain the local player script.

Give an item to the local player.

Method
Example
Method
void GiveItem(Item_Base item, int amount)
Example
RAPI.GiveItem(ItemManager.GetItemByName("raw_potato"),10);
// This will give 10 raw potatoes to the local player.

Broadcast a chat message.

Method
Example
Method
void BroadcastChatMessage(string message)
Example
RAPI.BroadcastChatMessage("I'm a message");
// Will send "I'm a message" to every players.

Allow the placement of a block on the grid system.

Method
Example
Method
void AddItemToBlockQuadType(Item_Base item, RBlockQuadType quadtype)
Example
RAPI.AddItemToBlockQuadType(YourNewItem, RBlockQuadType.quad_foundation);
// Allow "YourNewItem" to be placed on foundations.

Disallow the placement of a block on the grid system.

Method
Example
Method
void RemoveItemFromBlockQuadType(string itemUniqueName, RBlockQuadType quadtype)
Example
RAPI.RemoveItemFromBlockQuadType("YourItemUniqueName", RBlockQuadType.quad_foundation);
// Disallow the item with the uniquename "YourItemUniqueName" to be placed on foundations.
‚Äč

Listen for network messages on a specific network channel. (0 and 1 are locked for the game and can't be used)

Method
Example
Method
NetworkMessage ListenForNetworkMessagesOnChannel(int channel = 0)
Example
// Choose a unique ID for the channel id to not interfer with other mods.
NetworkMessage netMessage = RAPI.ListenForNetworkMessagesOnChannel(30);
if (netMessage != null)
{
CSteamID id = netMessage.steamid;
Message message = netMessage.message;
// Here we use 5000 because we can't modify an enum, you can use any values
// as long as its not in the Messages enum already. Bigger than 1000 is perfect.
if(message.Type == (Messages)5000){
// Do your stuff with the message now that you know
// its yours and its the wanted type.
YourMessageClass msg = message as YourMessageClass;
}
}

Send a network message to all players.

Method
Example
Method
void SendNetworkMessage(Message message, int channel = 0, EP2PSend ep2psend = EP2PSend.k_EP2PSendReliable, Target target = Target.Other, CSteamID fallbackSteamID = new CSteamID())
Example
// This will send your network message to all players.
RAPI.SendNetworkMessage(new YourMessageClass((Messages)5000));