OnWeaponFired
OxideCarbonWeaponCalled when a weapon is fired.
void OnWeaponFired(BaseProjectile baseProjectile, BasePlayer player, ItemModProjectile local3, ProtoBuf.ProjectileShoot local2)Works — the game method in this build is the one the hook was written for.
Parameters
- baseProjectile
- BaseProjectile
- player
- BasePlayer
- local3
- ItemModProjectile
- local2
- ProtoBuf.ProjectileShoot
Return value
voidThe return value is ignored — the hook only notifies.
Example
private void OnWeaponFired(BaseProjectile baseProjectile, BasePlayer player, ItemModProjectile local3, ProtoBuf.ProjectileShoot local2)
{
Puts("OnWeaponFired");
}Works in both Oxide and Carbon: Carbon loads Oxide plugins as is.
Injection point
Rust.opj (Oxide)
void BaseProjectile.CLProject(BaseEntity.RPCMessage)
Passes: BaseProjectile baseProjectile, BasePlayer player, ItemModProjectile local3, ProtoBuf.ProjectileShoot local2
WorksReturnBehavior: ContinueArgumentBehavior: UseArgumentString (this, a0.player, l3, l2)Assembly-CSharp.dll
Where it is called (this branch's game code)
// …
}
else if (projectileShoot.projectiles.Count > component.numProjectiles)
{
AntiHack.Log(player, AntiHackType.ProjectileHack, "Count mismatch (" + ShortPrefabName + ")");
player.stats.combat.LogInvalid(player, this, "count_mismatch");
}
else
{
Interface.CallHook("OnWeaponFired", this, msg.player, component, local2);
if (player.InGesture)
{
return;
}
SignalBroadcast(Signal.Attack, string.Empty, msg.connection, GetAttackEffect(), maxAttackEffectDistance);
player.CleanupExpiredProjectiles();
Guid projectileGroupId = Guid.NewGuid();
foreach (ProjectileShoot.Projectile projectile in projectileShoot.projectiles)
// …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.