hellos , sorry for my english but I'm french.
I would like to create a plugin that kick the player that connects when the server reaches a number of players.
I find this function that returns an int the number of players but I have an error when I test my plugin.
An object reference is required to access non-static member `GameManager.GetPlayerCount()'Code:GameManager.GetPlayerCount()
I have not much knowledge in C# but in another language yes Thanks for your help
Solved Get online player count? (C#)
Discussion in 'Hurtworld Development' started by JohnDoedu31, Dec 12, 2015.
-
Wulf Community Admin
Code:GameManager.Instance.GetPlayerCount()
-
merci pour votre aide, tout cela était-bête
[edit] new question
why ? after Instance
Code:ChatManager.Instance?.AppendChatboxServerAll("<color=" + CMDColor + ">" + CMDTitle + "</color> " + test);
Code:void OnPlayerConnected(PlayerIdentity identity, uLink.NetworkPlayer player) { int nombre = GameManager.Instance.GetPlayerCount(); if(nombre >= 77) { ConsoleManager.Instance?.ExecuteCommand("kick "+identity.SteamId.m_SteamID.ToString()+" Admin slot merci!!!"); } }
may be that the player is not yet in games to be kick ?
Code:kick 76561198173968135 Admin slot merci!!! No player found with that code.
Last edited by a moderator: Dec 13, 2015