C#C
C#3y ago
KRY_

❔ hook errors and unexpected }

So I’m working on some code for rust as of now and it’s function so far is to spawn a crate at a players position with a offset of 1.5 for the x, I keep getting errors with it though and I can’t seem to fix the issue anyone got a solution? Code:

using Oxide.Core.Libraries.Covalence;
using System;
using System.Collections.Generic;
using UnityEngine;

namespace Oxide.Plugins
{
    [Info("hackable", "KRYPT1KZ", "1.0.1")]
    public class hackable : CovalencePlugin
    {
        private const string hackablePrefab = "assets/prefabs/deployable/hackable_crate.prefab";

        [Command("hackable")]
        private void CommandHackable(IPlayer player, string cmd, string[] args)
        {
            var spawnPosition = new Vector3(player.Position().x + 1.5f, player.Position().y, player.Position().z);
            var entity = GameManager.server.CreateEntity(hackablePrefab, spawnPosition);

            entity.Spawn();

            Puts($"{player.Name} spawned a hackable at {spawnPosition}.");
        }

        private void OnEntityTakeDamage(BaseCombatEntity entity, HitInfo hitinfo)
        {
            if (hitinfo.Initiator != null && hitinfo.Initiator is BasePlayer && entity.ShortPrefabName == "hackable_crate")
            {
                var player = hitinfo.Initiator as BasePlayer;
                Puts($"Player {player.displayName} has opened hackable crate {entity.net.ID}");
            }
        }

        protected override void LoadDefaultConfig()
        {
            // Subscribe to the entity take damage event
            this.HookEvent(Rust.Event.OnEntityTakeDamage, OnEntityTakeDamage);
        }
    }
}
Was this page helpful?