Skip to content

Commit

Permalink
Merge pull request #81 from schwarper/0.2.9
Browse files Browse the repository at this point in the history
0.2.9
  • Loading branch information
schwarper committed Aug 2, 2024
2 parents 9a9b8f2 + 198f2fe commit ebe9396
Show file tree
Hide file tree
Showing 69 changed files with 145 additions and 3,303 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,29 @@ Discord nickname: schwarper

Discord link : [Discord server](https://discord.gg/4zQfUzjk36)

# Approved modules
[Crash by NaathySz](https://github.com/NaathySz/Store-Crash)

[Quiz by NaathySz](https://github.com/NaathySz/Store-Quiz)

[SlotMachine by NaathySz](https://github.com/NaathySz/Store-SlotMachine)

[HiLo by NaathySz](https://github.com/NaathySz/Store-HiLo)

[NameBonus by NaathySz](https://github.com/NaathySz/Store-NameBonus)

[CoinFlip by NaathySz](https://github.com/NaathySz/Store-CoinFlip)

[ReferralCodes by NaathySz](https://github.com/NaathySz/Store-ReferralCodes)

[Daily by NaathySz](https://github.com/NaathySz/Store-Daily)

[Salary by NaathySz](https://github.com/NaathySz/Store-Salary)

[Voucher by NaathySz](https://github.com/NaathySz/Store-Voucher)

[TopList by NaathySz](https://github.com/NaathySz/Store-TopList)

# Installation

1. Download the plugin:
Expand Down
4 changes: 3 additions & 1 deletion Store/lang/ch.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,17 @@
"menu_store<sound>": "声音",
"menu_store<equipment>": "设备",

"menu_store<all_title>": "共同模型",
"menu_store<t_title>": "T阵营模型",
"menu_store<ct_title>": "CT阵营模型",
"menu_store<purchase>": "{0} - [{1}]",
"menu_store<equip>": "装备",
"menu_store<unequip>": "脱下",
"menu_store<sell>": "出售 [{0}]",
"menu_store<confirm_title>": "购买?{0} - {1} 积分",
"menu_store<confirm_title>": "购买?",
"menu_store<yes>": "",
"menu_store<no>": "",
"menu_store<confirm_item>": "{0} - {1} 积分",

"css_credits": "{white}金币余额: {green}{0} {white}.",
"css_givecredits<player>": "{blue}{0}{white}给了{green}{2}金币{white}到{green}{1}{white}账户里.",
Expand Down
4 changes: 3 additions & 1 deletion Store/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,17 @@
"menu_store<sound>": "Sounds",
"menu_store<equipment>": "Equipments",

"menu_store<all_title>": "Models in common",
"menu_store<t_title>": "T Models",
"menu_store<ct_title>": "CT Models",
"menu_store<purchase>": "{0} - [{1}]",
"menu_store<equip>": "EQUIP",
"menu_store<unequip>": "UNEQUIP",
"menu_store<sell>": "SELL [{0}]",
"menu_store<confirm_title>": "Buying {0} - {1} credits?",
"menu_store<confirm_title>": "Buying?",
"menu_store<yes>": "Yes",
"menu_store<no>": "No",
"menu_store<confirm_item>": "{0} - {1} credits",

"css_credits": "{white}You have {green}{0} {white}credits.",
"css_givecredits<player>": "{blue}{0} {white}gave {green}{2} credits {white}to {green}{1}{white}.",
Expand Down
4 changes: 3 additions & 1 deletion Store/lang/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,17 @@
"menu_store<sound>": "Sons",
"menu_store<equipment>": "Equipamentos",

"menu_store<all_title>": "Modelos em comum",
"menu_store<t_title>": "Modelos T",
"menu_store<ct_title>": "Modelos CT",
"menu_store<purchase>": "{0} - [{1}]",
"menu_store<equip>": "EQUIPAR",
"menu_store<unequip>": "DESEQUIPAR",
"menu_store<sell>": "VENDER [{0}]",
"menu_store<confirm_title>": "Comprando? {0} - {1} créditos",
"menu_store<confirm_title>": "Comprando?",
"menu_store<yes>": "Sim",
"menu_store<no>": "Não",
"menu_store<confirm_item>": "{0} - {1} créditos",

"css_credits": "{white}Você possui {green}{0} {white}créditos.",
"css_givecredits<player>": "{blue}{0} {white}deu {green}{2} créditos {white}para {green}{1}{white}.",
Expand Down
4 changes: 3 additions & 1 deletion Store/lang/ro.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,17 @@
"menu_store<sound>": "Sunete",
"menu_store<equipment>": "Echipamente",

"menu_store<all_title>": "Modele în comun",
"menu_store<t_title>": "Modele T",
"menu_store<ct_title>": "Modele CT",
"menu_store<purchase>": "{0} - [{1}]",
"menu_store<equip>": "ECHIPEAZĂ",
"menu_store<unequip>": "DEZ-ECHIPEAZĂ",
"menu_store<sell>": "VINDE [{0}]",
"menu_store<confirm_title>": "Cumperi? {0} - {1} credite",
"menu_store<confirm_title>": "Cumperi?",
"menu_store<yes>": "Da",
"menu_store<no>": "Nu",
"menu_store<confirm_item>": "{0} - {1} credite",

"css_credits": "{white}Ai {green}{0} {white}credite.",
"css_givecredits<player>": "{blue}{0} {white}a dat {green}{2} credite {white}către {green}{1}{white}.",
Expand Down
4 changes: 3 additions & 1 deletion Store/lang/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,17 @@
"menu_store<sound>": "Звуки",
"menu_store<equipment>": "Оборудование",

"menu_store<all_title>": "Общие модели",
"menu_store<t_title>": "Модели t",
"menu_store<ct_title>": "Модели ct",
"menu_store<purchase>": "{0} - [{1}]",
"menu_store<equip>": "ЭКИПИРОВАТЬ",
"menu_store<unequip>": "СНЯТЬ",
"menu_store<sell>": "ПРОДАТЬ [{0}]",
"menu_store<confirm_title>": "Покупка? {0} - {1} креди",
"menu_store<confirm_title>": "Покупка?",
"menu_store<yes>": "Да",
"menu_store<no>": "Нет",
"menu_store<confirm_item>": "{0} - {1} креди",

"css_credits": "{white}У вас {green}{0} {white}кредитов.",
"css_givecredits<player>": "{blue}{0} {white}передал {green}{2} кредитов {white}{green}{1}{white}.",
Expand Down
4 changes: 3 additions & 1 deletion Store/lang/sl.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,17 @@
"menu_store<sound>": "Zvoki",
"menu_store<equipment>": "Oprema",

"menu_store<all_title>": "Skupni Modeli",
"menu_store<t_title>": "T Modeli",
"menu_store<ct_title>": "CT Modeli",
"menu_store<purchase>": "{0} - [{1}]",
"menu_store<equip>": "AKTIVIRAJ",
"menu_store<unequip>": "DEAKTIVIRAJ",
"menu_store<sell>": "PRODAJ [{0}]",
"menu_store<confirm_title>": "Nakup? {0} - {1} krediti",
"menu_store<confirm_title>": "Nakup?",
"menu_store<yes>": "Da",
"menu_store<no>": "Ne",
"menu_store<confirm_item>": "{0} - {1} krediti",

"css_credits": "{white}Trenutno imaš {green}{0} {white}kreditov.",
"css_givecredits<player>": "{blue}{0} {white}je dal {lightblue}{2} kredite {white}igralcu {green}{1}{white}.",
Expand Down
4 changes: 3 additions & 1 deletion Store/lang/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,17 @@
"menu_store<sound>": "Sesler",
"menu_store<equipment>": "Ekipmanlar",

"menu_store<all_title>": "Ortak Modeller",
"menu_store<t_title>": "T Modelleri",
"menu_store<ct_title>": "CT Modelleri",
"menu_store<purchase>": "{0} - [{1}]",
"menu_store<equip>": "KUŞAN",
"menu_store<unequip>": "BIRAK",
"menu_store<sell>": "SAT [{0}]",
"menu_store<confirm_title>": "Satın alıyorsun? {0} - {1} kredi",
"menu_store<confirm_title>": "Satın alıyor musun?",
"menu_store<yes>": "Evet",
"menu_store<no>": "Hayır",
"menu_store<confirm_item>": "{0} - {1} kredi",

"css_credits": "{green}{0} {white}kredin bulunmaktadır.",
"css_givecredits<player>": "{blue}{0}{white}, {green}{1} {white}adlı oyuncuya {green}{2} kredi {white}verdi.",
Expand Down
4 changes: 3 additions & 1 deletion Store/lang/ua.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,17 @@
"menu_store<sound>": "Звуки",
"menu_store<equipment>": "Обладнання",

"menu_store<all_title>": "Загальні моделі",
"menu_store<t_title>": "Моделі t",
"menu_store<ct_title>": "Моделі ct",
"menu_store<purchase>": "{0} - [{1}]",
"menu_store<equip>": "ЕКІПІРОВАТИ",
"menu_store<unequip>": "ЗНЯТИ",
"menu_store<sell>": "ПРОДАТИ [{0}]",
"menu_store<confirm_title>": "Купуєш? {0} - {1} креді",
"menu_store<confirm_title>": "Купуєш?",
"menu_store<yes>": "Так",
"menu_store<no>": "Ні",
"menu_store<confirm_item>": "{0} - {1} креді",

"css_credits": "{white}У вас {green}{0} {white}кредитів.",
"css_givecredits<player>": "{blue}{0} {white}передав {green}{2} кредитів {white}{green}{1}{white}.",
Expand Down
2 changes: 1 addition & 1 deletion Store/src/cs2-store.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Store;
public class Store : BasePlugin, IPluginConfig<StoreConfig>
{
public override string ModuleName => "Store";
public override string ModuleVersion => "0.2.8";
public override string ModuleVersion => "0.2.9";
public override string ModuleAuthor => "schwarper";

public StoreConfig Config { get; set; } = new StoreConfig();
Expand Down
29 changes: 22 additions & 7 deletions Store/src/item/item.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,23 @@ public static bool Equip(CCSPlayerController player, Dictionary<string, string>
return false;
}

Store_Equipment? currentitem = Instance.GlobalStorePlayerEquipments.FirstOrDefault(p => p.SteamID == player.SteamID && p.Type == item["type"] && item.TryGetValue("slot", out string? slot) && !string.IsNullOrEmpty(slot) && p.Slot == int.Parse(item["slot"]));

if (currentitem != null)
var currentitems = Instance.GlobalStorePlayerEquipments.FindAll(p =>
p.SteamID == player.SteamID &&
p.Type == item["type"] &&
(type.Type == "playerskin" && item["slot"] == "1" || p.Slot == 1) ||
p.Slot == int.Parse(item["slot"])
).ToList();

if (currentitems.Count > 0)
{
Dictionary<string, string>? citem = GetItem(currentitem.Type, currentitem.UniqueId);

if (citem != null)
foreach (var currentitem in currentitems)
{
Unequip(player, citem);
Dictionary<string, string>? citem = GetItem(currentitem.Type, currentitem.UniqueId);

if (citem != null)
{
Unequip(player, citem);
}
}
}

Expand Down Expand Up @@ -181,6 +189,13 @@ public static bool PlayerHas(CCSPlayerController player, string type, string Uni
return false;
}

Store_Item_Types? itemtype = Instance.GlobalStoreItemTypes.FirstOrDefault(i => i.Type == item["type"]);

if (itemtype?.Equipable == false)
{
return false;
}

if (!ignoreVip && IsPlayerVip(player))
{
return true;
Expand Down
16 changes: 5 additions & 11 deletions Store/src/item/items/playerskin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@ public static bool OnEquip(CCSPlayerController player, Dictionary<string, string
return false;
}

if (player.TeamNum == int.Parse(item["slot"]))
{
player.ChangeModelDelay(item["uniqueid"], item["disable_leg"] is "true" or "1", int.Parse(item["slot"]));
}
player.ChangeModelDelay(item["uniqueid"], item["disable_leg"] is "true" or "1", int.Parse(item["slot"]));

return true;
}
Expand All @@ -71,14 +68,11 @@ public static bool OnUnequip(CCSPlayerController player, Dictionary<string, stri
return false;
}

if (player.TeamNum == int.Parse(item["slot"]))
{
(string modelname, bool disableleg)? defaultModel = GetDefaultModel(player);
(string modelname, bool disableleg)? defaultModel = GetDefaultModel(player);

if (defaultModel.HasValue)
{
player.ChangeModelDelay(defaultModel.Value.modelname, defaultModel.Value.disableleg, player.TeamNum);
}
if (defaultModel.HasValue)
{
player.ChangeModelDelay(defaultModel.Value.modelname, defaultModel.Value.disableleg, player.TeamNum);
}

return true;
Expand Down
26 changes: 15 additions & 11 deletions Store/src/item/items/tag.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Core.Capabilities;
using CounterStrikeSharp.API.Modules.Utils;
Expand All @@ -11,23 +12,26 @@ public static class Item_Tag
{
private static ITagApi? tagApi;
private static readonly List<string> typeList = ["scoretag", "chattag", "chatcolor", "namecolor"];
private static PluginCapability<ITagApi> Capability { get; } = new("tags:api");

public static void OnAllPluginsLoaded()
{
tagApi = Capability.Get();

if (tagApi == null)
try
{
return;
}
PluginCapability<ITagApi> Capability = new("tags:api");

tagApi = Capability.Get();

Item.RegisterType("scoretag", OnMapStart, OnServerPrecacheResources, OnEquip, OnUnequip, true, null);
Item.RegisterType("chattag", OnMapStart, OnServerPrecacheResources, OnEquip, OnUnequip, true, null);
Item.RegisterType("chatcolor", OnMapStart, OnServerPrecacheResources, OnEquip, OnUnequip, true, null);
Item.RegisterType("namecolor", OnMapStart, OnServerPrecacheResources, OnEquip, OnUnequip, true, null);
Item.RegisterType("scoretag", OnMapStart, OnServerPrecacheResources, OnEquip, OnUnequip, true, null);
Item.RegisterType("chattag", OnMapStart, OnServerPrecacheResources, OnEquip, OnUnequip, true, null);
Item.RegisterType("chatcolor", OnMapStart, OnServerPrecacheResources, OnEquip, OnUnequip, true, null);
Item.RegisterType("namecolor", OnMapStart, OnServerPrecacheResources, OnEquip, OnUnequip, true, null);

Instance.RegisterEventHandler<EventPlayerConnectFull>(OnPlayerConnectFull);
Instance.RegisterEventHandler<EventPlayerConnectFull>(OnPlayerConnectFull);
}
catch (Exception)
{
tagApi = null;
}
}
public static void OnMapStart()
{
Expand Down
13 changes: 8 additions & 5 deletions Store/src/menu/menu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public static void DisplayStore(CCSPlayerController player, bool inventory)

foreach (KeyValuePair<string, Dictionary<string, Dictionary<string, string>>> category in Instance.Config.Items)
{
if ((inventory || Item.IsPlayerVip(player)) && !category.Value.Values.Any(item => Item.PlayerHas(player, item["type"], item["uniqueid"], false)))
if (inventory && !category.Value.Values.Any(item => Item.PlayerHas(player, item["type"], item["uniqueid"], false)))
{
continue;
}
Expand Down Expand Up @@ -115,17 +115,17 @@ public static void DisplayItems(CCSPlayerController player, string key, Dictiona
if (prev != null)
menu.Prev = prev.Parent?.Options?.Find(prev);

foreach (int Slot in new[] { 2, 3 })
foreach (int Slot in new[] { 1, 2, 3 })
{
if ((inventory || Item.IsPlayerVip(player)) && !playerSkinItems.Any(item => Item.PlayerHas(player, item.Value["type"], item.Value["uniqueid"], false)))
if (inventory && !playerSkinItems.Any(item => Item.PlayerHas(player, item.Value["type"], item.Value["uniqueid"], false)))
{
continue;
}

using (new WithTemporaryCulture(player.GetLanguage()))
{
StringBuilder builder = new();
builder.AppendFormat(Instance.Localizer[$"menu_store<{(Slot == 2 ? "t" : "ct")}_title>"]);
builder.AppendFormat(Instance.Localizer[$"menu_store<{(Slot == 1 ? "all" : Slot == 2 ? "t" : "ct")}_title>"]);

menu.Add(builder.ToString(), (CCSPlayerController player, IWasdMenuOption option) =>
{
Expand Down Expand Up @@ -158,7 +158,7 @@ public static void DisplayItem(CCSPlayerController player, bool inventory, strin
continue;
}

if ((inventory || Item.IsPlayerVip(player)) && !Item.PlayerHas(player, item["type"], item["uniqueid"], false))
if (inventory && !Item.PlayerHas(player, item["type"], item["uniqueid"], false))
{
continue;
}
Expand Down Expand Up @@ -278,6 +278,8 @@ public static void DisplayConfirmationMenu(CCSPlayerController player, Dictionar
if (prev != null)
menu.Prev = prev.Parent?.Options?.Find(prev);

AddMenuOption(player, menu, (p, o) => { }, "menu_store<confirm_item>", item["name"], item["price"]);

AddMenuOption(player, menu, (p, o) =>
{
if (Item.Purchase(p, item))
Expand All @@ -287,6 +289,7 @@ public static void DisplayConfirmationMenu(CCSPlayerController player, Dictionar
}
else
{
WasdManager.CloseSubMenu(p);
player.ExecuteClientCommand($"play {Instance.Config.Menu.MenuPressSoundNo}");
}
}, "menu_store<yes>");
Expand Down
Loading

0 comments on commit ebe9396

Please sign in to comment.