Compatible with .NET Framework 4.8
Player player – the player who sent the message (null for system
messages)string content – the message textPlayer player – the player who connectedPlayer player – the player who respawned or recoveredstring ipAddress – IP address of the clientint id – player ID if knownint clientId – client ID if knownPlayer player – the player who changed weaponint oldWeapon – previous weapon IDint newWeapon – new weapon IDPlayer player – the player who movedVector3 newPosition – new position coordinatesPlayer player – the player who changed bayonet statebool hasBayonet – true if equipped, false if removedusing vcdedconnector;
string hostAddress = "127.0.0.1";
int port = 2000;
VcdedAPI api = new VcdedAPI(hostAddress, port, false);
api.OnChatMessage += (sender, e) =>
{
if (e.Message.Equals("/swap"))
{
e.Player?.Swap();
}
else if (e.Message.Equals("/ping"))
{
e.Player?.SendMessage(MessageType.HostOnDC, "PONG! Aprox: " + e.Player.Ping);
}
else if (e.Message.Equals("/ip"))
{
e.Player?.SendMessage(MessageType.HostOnDC, "Your IP: " + e.Player.Ip);
}
};
api.OnPlayerConnection += (sender, e) =>
{
// waits until player choose side and the gun
e?.BlockThreadUntilSpawned();
e.Player?.SendMessage(MessageType.HostOnDC, "Welcome on the server " + e.Player.Name + "!");
};
api.OnClientConnection += (sender, e) =>
{
// waits until client (player) fully establish connection and receives the full handshake
e?.WaitUntilClientEstablishFullConnection();
api.SendMessage(MessageType.Console, e.Id, "You are joining to our server! Welcome!");
};