Jump to content

Open Community  ·  34 members

My Summer Car

Where am I stupid in code?


Kainnax

Recommended Posts

Can anyone help me please? I'm trying to make a simple hl_like_flashlight mod, but it doesn't work at all. ChatGPT didn't help, although it tried really hard.  DLL compiles smoothly, mod loader sees the mod, but that is all where I've got so far. Halp.

using MSCLoader;
using UnityEngine;

namespace Flashlight
{
    public class Flashlight : Mod
    {
        public override string ID => "Flashlight";
        public override string Name => "Flashlight";
        public override string Author => "Pisosss";
        public override string Version => "1.2.666";
        public override string Description => "";

        private KeyCode LampKey = KeyCode.X;
        private bool LampOff;
        private Light flashlight;

        public override void OnLoad()
        {
            LampOff = true;

            GameObject player = GameObject.Find("PLAYER");
            flashlight = player.AddComponent<Light>();
            flashlight.type = LightType.Spot;
            flashlight.color = Color.white;
            flashlight.spotAngle = 70;
            flashlight.intensity = 4;
            flashlight.range = 20;
            flashlight.enabled = false;
        }

        public override void Update()
        {
            if (Input.GetKey(LampKey))
            {
                LampOff = !LampOff;
                flashlight.enabled = !LampOff;
            }
        }
    }
}

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...