I am currently working on a server system for a game called Reign of Kings. I am using hooks and commands given by the Oxide developers to make my server system. Back in the PAWN Language, we could do something like enumeration of player data inside an array, which converts it to a 2d array - something cool. like PlayerData[playerid][data] and data could be anything from an interger called pAdminLevel to a string called pPassword.
I get it that in C#, things are different. So I tried to replicate the method like this:
pData[] PlayerData = new pData[MAX_PLAYERS];
public class pData
{
private int _admin;
public int admin { get { return _admin; } set { _admin = value; } }
public void ClearInfo()
{
_admin = 0;
}
}
so basically whenever I want to call a player's name, I can use PlayerData[playerid].admin.
But I get the error:
5:13 PM [Error] Failed to call hook 'OnPlayerConnected' on plugin 'ServerCommands' (NullReferenceException: Object reference not set to an instance of an object)
After much testing I made it absolutely sure that the problem is infact the way I call PlayerData[x].admin and PlayerData[x].ClearInfo().