OnSprayCreate
OxideCarbonCraftingCalled when a spray is created.
object OnSprayCreate(SprayCan sprayCan, Vector3 local0, Quaternion local5)Works — the game method in this build is the one the hook was written for.
Parameters
- sprayCan
- SprayCan
- local0
- Vector3
- local5
- Quaternion
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 OnSprayCreate(SprayCan sprayCan, Vector3 local0, Quaternion local5)
{
Puts("OnSprayCreate");
// 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 SprayCan.CreateSpray(BaseEntity.RPCMessage)
Passes: SprayCan sprayCan, Vector3 local0, Quaternion local5
WorksReturnBehavior: ExitWhenValidTypeArgumentBehavior: UseArgumentString (this, l0, l5)Assembly-CSharp.dll
Where it is called (this branch's game code)
// …
}
Quaternion rot = Quaternion.LookRotation((new Plane(vector2, vector).ClosestPointOnPlane(point) - vector).normalized, vector2);
rot *= Quaternion.Euler(0f, 0f, 90f);
if (num != 0 && !msg.player.blueprints.CheckSkinOwnership(num, msg.player))
{
Debug.Log($"SprayCan.ChangeItemSkin player does not have item :{num}:");
return;
}
if (Interface.CallHook("OnSprayCreate", this, vector, rot) != null)
{
return;
}
ulong num2 = ItemDefinition.FindSkin(SprayDecalItem.itemid, num);
BaseEntity baseEntity = GameManager.server.CreateEntity(SprayDecalEntityRef.resourcePath, vector, rot);
baseEntity.skinID = num2;
baseEntity.OnDeployed(null, GetOwnerPlayer(), GetItem());
baseEntity.networkEntityScale = true;
// …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.