0

The error I am getting is this:

An object reference is required for the non-static field, method, or property 'Flashlight.character'

Here is the code I have

using FireCallouts.SimpleFunctions;
using Rage;

namespace FireCallouts.Equipment
{
    public class Flashlight
    {
        private Ped character;

        public Flashlight(Ped character)
        {
            this.character = character;
        }


        public static void EnableFlashlight()
        {

            if (Game.LocalPlayer.Character && Game.IsKeyDown(Settings.Flashlight))
            {
                PedsSettings ps = PedsSettings.GetDefault();
                Ped ped = character;
                Vector3 flashlightPos = ped.GetOffsetPosition(ped.GetPositionOffset(ped.GetBonePosition(ps.FIREFIGHTER_FLASHLIGHT_ORIGIN_BONE)) + ps.FIREFIGHTER_FLASHLIGHT_ORIGIN_OFFSET.ToVector3());
                Util.DrawSpotlightWithShadow(flashlightPos, ped.GetBoneRotation(PedBoneId.Spine2).ToVector(), ps.FIREFIGHTER_FLASHLIGHT_COLOR.ToColor(), 13.25f, 9.25f, 2.0f, 20f, 20.0f);
            }

        }


    }
}
Panos1221
  • 31
  • 5
  • `Ped ped = character` Where are you expecting `character` to come from? You're in a `static` method, so it can't be in the current instance of `Flashlight`, since there is none. – Heretic Monkey Apr 13 '20 at 14:50
  • 1
    Also, please read [Should 'Hi', 'thanks', taglines, and salutations be removed from posts?](https://meta.stackexchange.com/q/2950/194720) where the answer is "Yes". Stack Overflow is a Q & A site concentrating on getting high-quality questions and answers that will help a lot of people for a long time, not just one person. Thus, text like "Hello all I hope you are okay. I know this question is a newbie one but I cant get it to work." is not useful for answering the question. – Heretic Monkey Apr 13 '20 at 14:53
  • I see thank you very much for your help and I will remove them and avoid them in future questions. I realised the mistake! – Panos1221 Apr 13 '20 at 14:55

0 Answers0