Skip to content

OnApartmentRoomPurchase

Usage

  • Return a non-null value to override default behavior

Example Autogenerated

csharp
private object OnApartmentRoomPurchase( ApartmentRoom apartmentRoom, BasePlayer player, ApartmentSize size, ApartmentBuilding instance )
{
    Puts( "OnApartmentRoomPurchase works!" );
    return null;
}

Location

  • ApartmentBuilding::PurchaseRoom(BasePlayer player, ApartmentSize size)
csharp
//---
	ApartmentRoom apartmentRoom = FetchClosestUnoccupiedRoom(size);
	if (apartmentRoom == null)
	{
		Debug.LogError($"Player tried to purchase an apartment of size {size} but no unoccupied rooms were found!");
	}
	else if (Interface.CallHook("OnApartmentRoomPurchase", apartmentRoom, player, size, this) == null)
	{
		int purchaseScrapCost = GetPurchaseScrapCost(size);
		player.inventory.Take(null, ItemManager.Items.Scrap.itemid, purchaseScrapCost);
		GiveRoomToPlayer(player, apartmentRoom);
		if (player.Connection != null)
//---

Released under the MIT License.