Jump to content
RAGE Multiplayer Community

C# Object reference not set to an....


Floriian
 Share

Recommended Posts

Hi,  (again me 😅)

I have some problem with this code. 
What can I do?
(Version: 1.1)

System.NullReferenceException: 'Object reference not set to an instance of an object.'

XpertRoleplay.Data.Data.PlayerData.get returned null.
using System;
using System.Collections.Generic;
using System.Text;
using GTANetworkAPI;

namespace XpertRoleplay.Data
{
    class Data
    {
        public static readonly String DataIndentifier = "PlayerInfo";
        public Player PlayerData { get; set; }
        public String Name { get; set; }
        public int Cash { get; set; }
        public int Level { get; set; }
        public int Age { get; set; }
        public int Health { get; set; }
        
        public Data(Player player)
        {
            this.PlayerData = null;
            this.Name = "";
            this.Cash = 0;
            this.Level = 0;
            this.Age = 0;
            this.Health = 0;
        }
        
        public void SetHealth(int health)
        {
            this.Health = health;
            this.PlayerData.Health = health; //This line
        }

    }
}

serverconsole:

Object reference not set to an instance of an object.

Object reference not set to an instance of an object.

 

Edited by Floriian
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

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