OnStructureUpgrade
OxideCarbonStructureCalled when a structure upgrades.
object OnStructureUpgrade(BuildingBlock buildingBlock, BasePlayer player, BuildingGrade.Enum type, ulong skin)Works — the game method in this build is the one the hook was written for.
Parameters
- buildingBlock
- BuildingBlock
- player
- BasePlayer
- type
- BuildingGrade.Enum
- skin
- ulong
Return value
objectReturn non-null to cancel the game action.
Example
object — you can affect the game: return a value to change or cancel the action.
private object OnStructureUpgrade(BuildingBlock buildingBlock, BasePlayer player, BuildingGrade.Enum type, ulong skin)
{
Puts("OnStructureUpgrade");
// change nothing — the game continues as usual
return null;
// to affect the game:
// return false; // non-null cancels the game action
}Works in both Oxide and Carbon: Carbon loads Oxide plugins as is.
Injection point
Rust.opj (Oxide)
void BuildingBlock.DoUpgradeToGrade(BaseEntity.RPCMessage)
Passes: BuildingBlock buildingBlock, BasePlayer player, BuildingGrade.Enum type, ulong skin
WorksReturnBehavior: ExitWhenValidTypeArgumentBehavior: UseArgumentString (this, a0.player, l0.gradeBase.type, l0.gradeBase.skin)Assembly-CSharp.dll
Where it is called (this branch's game code)
// …
{
string playerNameStreamSafe = NameHelper.GetPlayerNameStreamSafe(msg.player, basePlayer);
msg.player.ShowToast(GameTip.Styles.Error, ConstructionErrors.BlockedByPlayer, false, playerNameStreamSafe);
}
}
}
else
{
if (Interface.CallHook("OnStructureUpgrade", this, msg.player, constructionGrade.gradeBase.type, constructionGrade.gradeBase.skin) != null)
{
return;
}
if (!CanAffordUpgrade(constructionGrade.gradeBase.type, constructionGrade.gradeBase.skin, msg.player))
{
return;
}
if (SecondsSinceAttacked < 30f)
// …Sources: Rust.opj from OxideMod/Oxide.Rust (MIT) and hook metadata of the Carbon documentation (MIT). Method code is decompiled from this branch's server.