Hello. I'm tryin to edit the plugin RotateOnUpgrade for remove wall after Hammer hit, but nothing is happen.
I know, many in this plugin is wrong, but I hope U can help me.
Code:using System; using System.Collections.Generic; using UnityEngine; using Rust;namespace Oxide.Plugins { [Info("RotateOnUpgrade", "KeyboardCavemen", "1.3.0")] class RotateOnUpgrade : RustPlugin { //Oxide Hook void OnServerInitialized() { } //Oxide Hook protected override void LoadDefaultConfig() { } //Oxide Hook void OnPlayerInput(BasePlayer player, InputState input) { if (player.IsAdmin() && player.GetActiveItem() != null && player.GetActiveItem().info.shortname.Equals("hammer")) { if (input.WasJustPressed(BUTTON.FIRE_PRIMARY)) { RaycastHit hit; if (Physics.Raycast(player.eyes.position, (player.eyes.rotation * Vector3.forward), out hit, 2f, Layers.Server.Buildings)) { BaseEntity baseEntity = hit.collider.gameObject.ToBaseEntity(); if (baseEntity != null) { BuildingBlock block = baseEntity.GetComponent<BuildingBlock>(); if (block != null && block.blockDefinition.canRotate && !block.HasFlag(BaseEntity.Flags.Reserved1)) { block.SetFlag(BaseEntity.Flags.Reserved1, true); SendReply(player, "Called"); } } } } } } } }
Solved Remove structures via hammer?
Discussion in 'Rust Development' started by azalea`, Jan 23, 2016.
-
Have you placed Puts("debug inner cycle"); debug console outputs to see where the methods does exit before?
-
Something wrong with:
Code:BaseEntity baseEntity = hit.collider.gameObject.ToBaseEntity(); if (baseEntity != null) { puts("Not null"); }
[DOUBLEPOST=1453642767,1453555447][/DOUBLEPOST]HACHI MODE: On -
but SendReply(player, "Called"); never gets called?
-
Oh god...
Rust -
OnPlayerInput is a horrible way to do this. A hook was actually added in the past to allow you to capture hits of the hammer (Oxide Documentation) as Sanlerus also mentioned above.
Code:void OnHammerHit(BasePlayer player, HitInfo info) { // Your code here... }
-
Next question — it required to set Reserved1/Reserved2 to false after rotate/remove the wall? Maybe for RAM saving or etc.Last edited by a moderator: Jan 25, 2016 -
Code:
private void OnHammerHit(BasePlayer player, HitInfo info) { if (player.IsAdmin() && info?.HitEntity != null) { var block = info.HitEntity.GetComponent<BuildingBlock>(); if (block != null && block.blockDefinition.canRotate && !block.HasFlag(BaseEntity.Flags.Reserved1)) { block.SetFlag(BaseEntity.Flags.Reserved1, true); timer.In(30f, () => block?.SetFlag(BaseEntity.Flags.Reserved1, false)); // reset after 30 seconds SendReply(player, "You can rotate this block for 30 seconds"); } } }