Beispiel #1
0
 void InitClan(string clanTag)
 {
     if (clanTag != null && !_clansScores.ContainsKey(clanTag))
     {
         ClanScoreboard cScore = new ClanScoreboard(clanTag);
         _clansScores.Add(clanTag, cScore);
     }
 }
Beispiel #2
0
        private void cmdStats(BasePlayer player, string command, string[] args)
        {
            InitPlayer(player.userID);

            try {
                PlayerScoreboard pScore = GetPlayerStats(player.userID);
                SendReply(player, $"Players Stats\nKills: {pScore.Kills}\nDeaths: {pScore.Deaths}\nRevives: {pScore.Revives}\nDowns: {pScore.Downs}");

                ClanScoreboard cScore = GetClanStats(player.userID);
                SendReply(player, $"Clan Stats\nKills: {cScore.Kills}\nDeaths: {cScore.Deaths}\nRevives: {cScore.Revives}\nDowns: {cScore.Downs}");
            } catch (Exception e) {
            }
        }
Beispiel #3
0
        void AddDown(ulong playerId)
        {
            if (playerId == 0)
            {
                return;
            }
            string clan = GetClan(playerId);

            _AddPlayerDown(playerId);
            if (clan != null)
            {
                if (_clansScores.ContainsKey(clan))
                {
                    _clansScores[clan].Downs++;
                }
                else
                {
                    ClanScoreboard newClan = new ClanScoreboard(clan);
                    newClan.Downs++;
                    _clansScores.Add(clan, newClan);
                }
            }
        }
Beispiel #4
0
        private void cmdCui(BasePlayer player, string command, string[] args)
        {
            CuiElementContainer     container    = new CuiElementContainer();
            List <ClanScoreboard>   cScoreSorted = _clansScores.Values.OrderByDescending(x => x.kdr()).Take(10).ToList();
            List <PlayerScoreboard> pScoreSorted = _playerScores.Values.OrderByDescending(x => x.kdr()).Take(10).ToList();

            if (cScoreSorted.Count > 0)
            {
                mainElementClan = container.Add(new CuiPanel {
                    Image =
                    {
                        Color = "0 0 0 0.5"
                    },
                    RectTransform =
                    {
                        AnchorMin = "0.800 0.650",
                        AnchorMax = "0.995 0.960" //left digit is viewheight from left, right digit is Y axis, viewheight from bottom
                    },
                    CursorEnabled = false,
                }, "Hud", mainPanelClanName);

                container.Add(new CuiLabel {
                    Text =
                    {
                        Text     = "#",
                        FontSize =  15,
                        Align    = TextAnchor.MiddleLeft
                    },
                    RectTransform =
                    {
                        AnchorMin = $"0.05 0.80",
                        AnchorMax = $"0.12 0.95"
                    }
                }, mainElementClan);

                container.Add(new CuiLabel {
                    Text =
                    {
                        Text     = "Clan",
                        FontSize =     15,
                        Align    = TextAnchor.MiddleLeft
                    },
                    RectTransform =
                    {
                        AnchorMin = $"0.15 0.80",
                        AnchorMax = $"0.46 0.95"
                    }
                }, mainElementClan);

                container.Add(new CuiLabel {
                    Text =
                    {
                        Text     = "Kills",
                        FontSize =      15,
                        Align    = TextAnchor.MiddleCenter
                    },
                    RectTransform =
                    {
                        AnchorMin = $"0.49 0.80",
                        AnchorMax = $"0.64 0.95"
                    }
                }, mainElementClan);

                container.Add(new CuiLabel {
                    Text =
                    {
                        Text     = "Deaths",
                        FontSize =       15,
                        Align    = TextAnchor.MiddleCenter
                    },
                    RectTransform =
                    {
                        AnchorMin = $"0.67 0.80",
                        AnchorMax = $"0.85 0.95"
                    }
                }, mainElementClan);

                container.Add(new CuiLabel {
                    Text =
                    {
                        Text     = "KDR",
                        FontSize =    15,
                        Align    = TextAnchor.MiddleCenter
                    },
                    RectTransform =
                    {
                        AnchorMin = $"0.85 0.80",
                        AnchorMax = $"1.00 0.95"
                    }
                }, mainElementClan);


                for (var i = 0; i < cScoreSorted.Count; i++)
                {
                    ClanScoreboard team = cScoreSorted[i];

                    container.Add(new CuiLabel {
                        Text =
                        {
                            Text     = (i + 1).ToString(),
                            FontSize =                 14,
                            Align    = TextAnchor.MiddleLeft
                        },
                        RectTransform =
                        {
                            AnchorMin = $"0.05 {0.825 - 0.075*(i+1)}",
                            AnchorMax = $"0.12 {0.825 - (0.075*i+0)}"
                        }
                    }, mainElementClan);

                    container.Add(new CuiLabel {
                        Text =
                        {
                            Text     = team.clanTag,
                            FontSize =           14,
                            Align    = TextAnchor.MiddleLeft
                        },
                        RectTransform =
                        {
                            AnchorMin = $"0.15 {0.825 - 0.075*(i+1)}",
                            AnchorMax = $"0.30 {0.825 - (0.075*i+0)}"
                        }
                    }, mainElementClan);

                    container.Add(new CuiLabel {
                        Text =
                        {
                            Text     = team.Kills.ToString(),
                            FontSize =                    14,
                            Align    = TextAnchor.MiddleCenter
                        },
                        RectTransform =
                        {
                            AnchorMin = $"0.49 {0.825 - 0.075*(i+1)}",
                            AnchorMax = $"0.64 {0.825 - (0.075*i+0)}"
                        }
                    }, mainElementClan);

                    container.Add(new CuiLabel {
                        Text =
                        {
                            Text     = team.Deaths.ToString(),
                            FontSize =                     14,
                            Align    = TextAnchor.MiddleCenter
                        },
                        RectTransform =
                        {
                            AnchorMin = $"0.67 {0.825 - 0.075*(i+1)}",
                            AnchorMax = $"0.80 {0.825 - (0.075*i+0)}"
                        }
                    }, mainElementClan);

                    container.Add(new CuiLabel {
                        Text =
                        {
                            Text     = team.kdr().ToString(),
                            FontSize =                    14,
                            Align    = TextAnchor.MiddleCenter
                        },
                        RectTransform =
                        {
                            AnchorMin = $"0.85 {0.825 - 0.075*(i+1)}",
                            AnchorMax = $"1.00 {0.825 - (0.075*i+0)}"
                        }
                    }, mainElementClan);
                }
            }
            ////////////////////////////////////////////////////////////////////////////
            ///
            if (pScoreSorted.Count > 0)
            {
                mainElementPlayers = container.Add(new CuiPanel {
                    Image =
                    {
                        Color = "0 0 0 0.5"
                    },
                    RectTransform =
                    {
                        AnchorMin = "0.800 0.335",
                        AnchorMax = "0.995 0.645" //left digit is viewheight from left, right digit is Y axis, viewheight from bottom
                    },
                    CursorEnabled = false,
                }, "Hud", mainPanelPlayersName);

                container.Add(new CuiLabel {
                    Text =
                    {
                        Text     = "#",
                        FontSize =  15,
                        Align    = TextAnchor.MiddleLeft
                    },
                    RectTransform =
                    {
                        AnchorMin = $"0.05 0.80",
                        AnchorMax = $"0.12 0.95"
                    }
                }, mainElementPlayers);

                container.Add(new CuiLabel {
                    Text =
                    {
                        Text     = "Players",
                        FontSize =        15,
                        Align    = TextAnchor.MiddleLeft
                    },
                    RectTransform =
                    {
                        AnchorMin = $"0.15 0.80",
                        AnchorMax = $"0.46 0.95"
                    }
                }, mainElementPlayers);

                container.Add(new CuiLabel {
                    Text =
                    {
                        Text     = "Kills",
                        FontSize =      15,
                        Align    = TextAnchor.MiddleCenter
                    },
                    RectTransform =
                    {
                        AnchorMin = $"0.49 0.80",
                        AnchorMax = $"0.64 0.95"
                    }
                }, mainElementPlayers);

                container.Add(new CuiLabel {
                    Text =
                    {
                        Text     = "Deaths",
                        FontSize =       15,
                        Align    = TextAnchor.MiddleCenter
                    },
                    RectTransform =
                    {
                        AnchorMin = $"0.67 0.80",
                        AnchorMax = $"0.85 0.95"
                    }
                }, mainElementPlayers);

                container.Add(new CuiLabel {
                    Text =
                    {
                        Text     = "KDR",
                        FontSize =    15,
                        Align    = TextAnchor.MiddleCenter
                    },
                    RectTransform =
                    {
                        AnchorMin = $"0.85 0.80",
                        AnchorMax = $"1.00 0.95"
                    }
                }, mainElementPlayers);


                for (var i = 0; i < pScoreSorted.Count; i++)
                {
                    PlayerScoreboard plyr    = pScoreSorted[i];
                    IPlayer          fplayer = covalence.Players.FindPlayerById(plyr.playerId.ToString());

                    container.Add(new CuiLabel {
                        Text =
                        {
                            Text     = (i + 1).ToString(),
                            FontSize =                 14,
                            Align    = TextAnchor.MiddleLeft
                        },
                        RectTransform =
                        {
                            AnchorMin = $"0.05 {0.825 - 0.075*(i+1)}",
                            AnchorMax = $"0.12 {0.825 - (0.075*i+0)}"
                        }
                    }, mainElementPlayers);
                    container.Add(new CuiLabel {
                        Text =
                        {
                            Text     = fplayer != null ? fplayer?.Name : plyr.playerId.ToString(),
                            FontSize =                                                         14,
                            Align    = TextAnchor.MiddleLeft
                        },
                        RectTransform =
                        {
                            AnchorMin = $"0.15 {0.825 - 0.075*(i+1)}",
                            AnchorMax = $"0.40 {0.825 - (0.075*i+0)}"
                        }
                    }, mainElementPlayers);

                    container.Add(new CuiLabel {
                        Text =
                        {
                            Text     = plyr.Kills.ToString(),
                            FontSize =                    14,
                            Align    = TextAnchor.MiddleCenter
                        },
                        RectTransform =
                        {
                            AnchorMin = $"0.49 {0.825 - 0.075*(i+1)}",
                            AnchorMax = $"0.64 {0.825 - (0.075*i+0)}"
                        }
                    }, mainElementPlayers);

                    container.Add(new CuiLabel {
                        Text =
                        {
                            Text     = plyr.Deaths.ToString(),
                            FontSize =                     14,
                            Align    = TextAnchor.MiddleCenter
                        },
                        RectTransform =
                        {
                            AnchorMin = $"0.67 {0.825 - 0.075*(i+1)}",
                            AnchorMax = $"0.80 {0.825 - (0.075*i+0)}"
                        }
                    }, mainElementPlayers);

                    container.Add(new CuiLabel {
                        Text =
                        {
                            Text     = plyr.kdr().ToString(),
                            FontSize =                    14,
                            Align    = TextAnchor.MiddleCenter
                        },
                        RectTransform =
                        {
                            AnchorMin = $"0.85 {0.825 - 0.075*(i+1)}",
                            AnchorMax = $"1.00 {0.825 - (0.075*i+0)}"
                        }
                    }, mainElementPlayers);
                }
            }

            if ((cScoreSorted.Count + pScoreSorted.Count) > 0 && !openPanels.ContainsKey(player.userID))
            {
                openPanels.Add(player.userID, "open");
                CuiHelper.AddUi(player, container);
                timer.Once(10, () => DestroyUI(player));
            }
        }