OnPayForPlacement
OxidePlayerobject OnPayForPlacement(BasePlayer player, Planner planner, Construction component)
object OnPayForPlacement(BasePlayer player, WallpaperPlanner wallpaperPlanner, Construction component)Works — the game method in this build is the one the hook was written for.
Parameters
- player
- BasePlayer
- planner
- Planner
- component
- Construction
Return value
objectReturn a value of the method's result type and the game returns it immediately; null continues as usual.
Example
object — you can affect the game: return a value to change or cancel the action.
private object OnPayForPlacement(BasePlayer player, Planner planner, Construction component)
{
Puts("OnPayForPlacement");
// change nothing — the game continues as usual
return null;
// to affect the game:
// return null; // null — the game continues as usual
}Works in both Oxide and Carbon: Carbon loads Oxide plugins as is.
Injection point 1
Rust.opj (Oxide)
void Planner.PayForPlacement(BasePlayer, Construction)
Passes: BasePlayer player, Planner planner, Construction component
WorksReturnBehavior: ExitWhenValidTypeArgumentBehavior: UseArgumentString (a0, this, a1)Assembly-CSharp.dll
Where it is called (this branch's game code)
public virtual void PayForPlacement(BasePlayer player, Construction component)
{
if (Interface.CallHook("OnPayForPlacement", player, this, component) != null)
{
return;
}
if (player.IsInCreativeMode && Creative.freeBuild)
{
return;
}
if (player.IsInTutorial)
// …Injection point 2
Rust.opj (Oxide)
void WallpaperPlanner.PayForPlacement(BasePlayer, Construction)
Passes: BasePlayer player, WallpaperPlanner wallpaperPlanner, Construction component
WorksReturnBehavior: ExitWhenValidTypeArgumentBehavior: UseArgumentString (a0, this, a1)Assembly-CSharp.dll
Where it is called (this branch's game code)
public override void PayForPlacement(BasePlayer player, Construction component)
{
if (Interface.CallHook("OnPayForPlacement", player, this, component) != null)
{
return;
}
if (!player.IsInCreativeMode || !Creative.freeBuild)
{
player.inventory.Take(null, placementPrice.itemid, (int)placementPrice.amount);
player.Command("note.inv", placementPrice.itemid, (int)placementPrice.amount * -1);
}
// …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.