示例#1
0
        void SendDataToServer(string name, Color color)
        {
            var data = new ServerNetworkData
            {
                Color = color,
                Name  = name
            };

            RPC.Send <ServerNetworkData>("SendDataToServer", data);
        }
示例#2
0
        public void SendDataToServer(Player player, ServerNetworkData networkData)
        {
            Logger.LogInfo($"Received a RPC from {player.Nick}!");
            Logger.LogInfo($"Received a name {networkData.Name} and a color {networkData.Color}!");

            if (string.IsNullOrWhiteSpace(networkData.Name))
            {
                Logger.LogError($"{player.Nick} sent data with no name!");
                return;
            }

            InventoryItem item = new InventoryItem
            {
                PlayerColor = networkData.Color,
                PlayerName  = networkData.Name,
                CreatedAt   = DateTime.Now,
                SteamId64   = player.SteamId64
            };

            Database.Insert <InventoryItem>(item).Execute();
        }