void RefreshKitPanel(BasePlayer player, ulong guiId, int minKit = 0) { PLayerGUI playerGUI; if (!PlayerGUI.TryGetValue(player.userID, out playerGUI)) { PlayerGUI[player.userID] = playerGUI = new PLayerGUI(); } playerGUI.guiid = guiId; playerGUI.page = minKit; DestroyGUI(player, "KitListOverlay"); //Game.Rust.Cui.CuiHelper.AddUi(player, kitlistoverlay); CommunityEntity.ServerInstance.ClientRPCEx(new Network.SendInfo { connection = player.net.connection }, null, "AddUI", new Facepunch.ObjectList(kitlistoverlay)); var kitpanel = GUIKits[guiId]; int current = 0; foreach (var kitname in kitpanel.kits) { if (current >= minKit && current < minKit + 8) { string reason = string.Empty; var cansee = CanSeeKit(player, kitname.ToLower(), true, out reason); if (!cansee && string.IsNullOrEmpty(reason)) { continue; } Kit kit = storedData.Kits[kitname.ToLower()]; var kitData = GetKitData(player.userID, kitname.ToLower()); var ckit = buttonjson.Replace("{color}", "0.5 0.5 0.5 0.2"); ckit = ckit.Replace("{guimsg}", $"'{kitname.ToLower()}'"); ckit = ckit.Replace("{ymin}", (1 - ((current - minKit) + 1) * 0.0775).ToString()); ckit = ckit.Replace("{ymax}", (1 - (current - minKit) * 0.0775).ToString()); ckit = ckit.Replace("{kitfullname}", kit.name); ckit = ckit.Replace("{kitdescription}", kit.description ?? string.Empty); ckit = ckit.Replace("{imageurl}", kit.image ?? "http://i.imgur.com/xxQnE1R.png"); ckit = ckit.Replace("{left}", kit.max <= 0 ? string.Empty : (kit.max - kitData.max).ToString()); ckit = ckit.Replace("{cooldown}", kit.cooldown <= 0 ? string.Empty : CurrentTime() > kitData.cooldown ? "0" : Math.Abs(Math.Ceiling(CurrentTime() - kitData.cooldown)).ToString()); //Game.Rust.Cui.CuiHelper.AddUi(player, ckit); CommunityEntity.ServerInstance.ClientRPCEx(new Network.SendInfo { connection = player.net.connection }, null, "AddUI", new Facepunch.ObjectList(ckit)); } current++; } int pageminus = minKit - 8 < 0 ? 0 : minKit - 8; int pageplus = minKit + 8 > current ? minKit : minKit + 8; var kpage = kitchangepage.Replace("{pageminus}", pageminus.ToString()).Replace("{pageplus}", pageplus.ToString()); //Game.Rust.Cui.CuiHelper.AddUi(player, kpage); CommunityEntity.ServerInstance.ClientRPCEx(new Network.SendInfo { connection = player.net.connection }, null, "AddUI", new Facepunch.ObjectList(kpage)); }
void RefreshKitPanel(BasePlayer player, ulong guiId, int minKit = 0) { PLayerGUI playerGUI; if (!PlayerGUI.TryGetValue(player.userID, out playerGUI)) { PlayerGUI[player.userID] = playerGUI = new PLayerGUI(); } playerGUI.guiid = guiId; playerGUI.page = minKit; DestroyGUI(player, "KitListOverlay"); Game.Rust.Cui.CuiHelper.AddUi(player, kitlistoverlay); var kitpanel = GUIKits[guiId]; var max = minKit + 8; if (max > kitpanel.kits.Count) { max = kitpanel.kits.Count; } for (var i = minKit; i < max; i++) { var kitname = kitpanel.kits[i].ToLower(); string reason; var cansee = CanSeeKit(player, kitname, true, out reason); if (!cansee && string.IsNullOrEmpty(reason)) { continue; } Kit kit = storedData.Kits[kitname]; var kitData = GetKitData(player.userID, kitname); var ckit = buttonjson.Replace("{color}", "0.5 0.5 0.5 0.2"); ckit = ckit.Replace("{guimsg}", $"'{kitname}'"); ckit = ckit.Replace("{ymin}", (1 - ((i - minKit) + 1) * 0.0775).ToString()); ckit = ckit.Replace("{ymax}", (1 - (i - minKit) * 0.0775).ToString()); ckit = ckit.Replace("{kitfullname}", kit.name); ckit = ckit.Replace("{kitdescription}", kit.description ?? string.Empty); ckit = ckit.Replace("{imageurl}", kit.image ?? "http://i.imgur.com/xxQnE1R.png"); ckit = ckit.Replace("{left}", kit.max <= 0 ? string.Empty : (kit.max - kitData.max).ToString()); ckit = ckit.Replace("{cooldown}", kit.cooldown <= 0 ? string.Empty : CurrentTime() > kitData.cooldown ? "0" : Math.Abs(Math.Ceiling(CurrentTime() - kitData.cooldown)).ToString()); Game.Rust.Cui.CuiHelper.AddUi(player, ckit); } var pageminus = minKit - 8 < 0 ? 0 : minKit - 8; var pageplus = minKit + 8 > kitpanel.kits.Count ? minKit : minKit + 8; var kpage = kitchangepage.Replace("{pageminus}", pageminus.ToString()).Replace("{pageplus}", pageplus.ToString()); Game.Rust.Cui.CuiHelper.AddUi(player, kpage); }
void RefreshKitPanel(BasePlayer player, ulong guiId, int minKit = 0) { PLayerGUI playerGUI; if (!PlayerGUI.TryGetValue(player.userID, out playerGUI)) PlayerGUI[player.userID] = playerGUI = new PLayerGUI(); playerGUI.guiid = guiId; playerGUI.page = minKit; DestroyGUI(player, "KitListOverlay"); Game.Rust.Cui.CuiHelper.AddUi(player, kitlistoverlay); var kitpanel = GUIKits[guiId]; var max = minKit + 8; if (max > kitpanel.kits.Count) max = kitpanel.kits.Count; for (var i = minKit; i < max; i++) { var kitname = kitpanel.kits[i].ToLower(); string reason; var cansee = CanSeeKit(player, kitname, true, out reason); if (!cansee && string.IsNullOrEmpty(reason)) continue; Kit kit = storedData.Kits[kitname]; var kitData = GetKitData(player.userID, kitname); var ckit = buttonjson.Replace("{color}", "0.5 0.5 0.5 0.2"); ckit = ckit.Replace("{guimsg}", $"'{kitname}'"); ckit = ckit.Replace("{ymin}", (1 - ((i - minKit) + 1) * 0.0775).ToString()); ckit = ckit.Replace("{ymax}", (1 - (i - minKit) * 0.0775).ToString()); ckit = ckit.Replace("{kitfullname}", kit.name); ckit = ckit.Replace("{kitdescription}", kit.description ?? string.Empty); ckit = ckit.Replace("{imageurl}", kit.image ?? "http://i.imgur.com/xxQnE1R.png"); ckit = ckit.Replace("{left}", kit.max <= 0 ? string.Empty : (kit.max - kitData.max).ToString()); ckit = ckit.Replace("{cooldown}", kit.cooldown <= 0 ? string.Empty : CurrentTime() > kitData.cooldown ? "0" : Math.Abs(Math.Ceiling(CurrentTime() - kitData.cooldown)).ToString()); Game.Rust.Cui.CuiHelper.AddUi(player, ckit); } var pageminus = minKit - 8 < 0 ? 0 : minKit - 8; var pageplus = minKit + 8 > kitpanel.kits.Count ? minKit : minKit + 8; var kpage = kitchangepage.Replace("{pageminus}", pageminus.ToString()).Replace("{pageplus}", pageplus.ToString()); Game.Rust.Cui.CuiHelper.AddUi(player, kpage); }
void RefreshKitPanel(BasePlayer player, ulong guiId, int minKit = 0) { PLayerGUI playerGUI; if (!PlayerGUI.TryGetValue(player.userID, out playerGUI)) PlayerGUI[player.userID] = playerGUI = new PLayerGUI(); playerGUI.guiid = guiId; playerGUI.page = minKit; DestroyGUI(player, "KitListOverlay"); //Game.Rust.Cui.CuiHelper.AddUi(player, kitlistoverlay); CommunityEntity.ServerInstance.ClientRPCEx(new Network.SendInfo { connection = player.net.connection }, null, "AddUI", new Facepunch.ObjectList(kitlistoverlay)); var kitpanel = GUIKits[guiId]; int current = 0; foreach (var kitname in kitpanel.kits) { if (current >= minKit && current < minKit + 8) { string reason = string.Empty; var cansee = CanSeeKit(player, kitname.ToLower(), true, out reason); if (!cansee && string.IsNullOrEmpty(reason)) continue; Kit kit = storedData.Kits[kitname.ToLower()]; var kitData = GetKitData(player.userID, kitname.ToLower()); var ckit = buttonjson.Replace("{color}", "0.5 0.5 0.5 0.2"); ckit = ckit.Replace("{guimsg}", $"'{kitname.ToLower()}'"); ckit = ckit.Replace("{ymin}", (1 - ((current - minKit) + 1) * 0.0775).ToString()); ckit = ckit.Replace("{ymax}", (1 - (current - minKit)*0.0775).ToString()); ckit = ckit.Replace("{kitfullname}", kit.name); ckit = ckit.Replace("{kitdescription}", kit.description ?? string.Empty); ckit = ckit.Replace("{imageurl}", kit.image ?? "http://i.imgur.com/xxQnE1R.png"); ckit = ckit.Replace("{left}", kit.max <= 0 ? string.Empty : (kit.max - kitData.max).ToString()); ckit = ckit.Replace("{cooldown}", kit.cooldown <= 0 ? string.Empty : CurrentTime() > kitData.cooldown ? "0" : Math.Abs(Math.Ceiling(CurrentTime() - kitData.cooldown)).ToString()); //Game.Rust.Cui.CuiHelper.AddUi(player, ckit); CommunityEntity.ServerInstance.ClientRPCEx(new Network.SendInfo { connection = player.net.connection }, null, "AddUI", new Facepunch.ObjectList(ckit)); } current++; } int pageminus = minKit - 8 < 0 ? 0 : minKit - 8; int pageplus = minKit + 8 > current ? minKit : minKit + 8; var kpage = kitchangepage.Replace("{pageminus}", pageminus.ToString()).Replace("{pageplus}", pageplus.ToString()); //Game.Rust.Cui.CuiHelper.AddUi(player, kpage); CommunityEntity.ServerInstance.ClientRPCEx(new Network.SendInfo { connection = player.net.connection }, null, "AddUI", new Facepunch.ObjectList(kpage)); }