Template:Example: Difference between revisions
(Undo revision 20025 by Scr1ptless (talk) - It added 'consoleCommand' example to many different pages.) Tag: Undo |
|||
| Line 1: | Line 1: | ||
===Example=== | ===Example=== | ||
[ServerEvent(Event.PlayerDisconnected)] | |||
public void OnPlayerDisconnect(Player player, DisconnectionType type, string reason) | |||
{ | |||
switch (type) | |||
{ | |||
case DisconnectionType.Left: | |||
player.SendChatMessage($"~b~{player.Name}~w~ has quit the server."); | |||
break; | |||
case DisconnectionType.Timeout: | |||
player.SendChatMessage($"~b~{player.Name}~w~ has timed out."); | |||
break; | |||
case DisconnectionType.Kicked: | |||
player.SendChatMessage($"~b~{player.Name}~w~ was kicked from the server {reason}."); | |||
break; | |||
} | |||
} | |||
Revision as of 20:03, 8 November 2020
Example
[ServerEvent(Event.PlayerDisconnected)] public void OnPlayerDisconnect(Player player, DisconnectionType type, string reason) { switch (type) { case DisconnectionType.Left: player.SendChatMessage($"~b~{player.Name}~w~ has quit the server."); break; case DisconnectionType.Timeout: player.SendChatMessage($"~b~{player.Name}~w~ has timed out."); break; case DisconnectionType.Kicked: player.SendChatMessage($"~b~{player.Name}~w~ was kicked from the server {reason}."); break; } }