From 6edea08481de7bb76f73d69bd025678d7281c4c6 Mon Sep 17 00:00:00 2001 From: nuclear silo Date: Sat, 29 Oct 2022 16:41:58 +0700 Subject: [PATCH] add center tag cvar to fix giveaway center tag display (tks Koen for reporting) --- addons/sourcemod/scripting/store.sp | 2 +- addons/sourcemod/scripting/store/cvars.sp | 12 ++++++++---- addons/sourcemod/scripting/store/natives.sp | 2 +- addons/sourcemod/scripting/store_combine.sp | 14 +++++++++----- addons/sourcemod/scripting/store_misc_giveaway.sp | 12 +++++++----- .../scripting/store_misc_giveaway_aidnversion.sp | 13 ++++++++----- 6 files changed, 34 insertions(+), 21 deletions(-) diff --git a/addons/sourcemod/scripting/store.sp b/addons/sourcemod/scripting/store.sp index 83d9be3..4408ee5 100644 --- a/addons/sourcemod/scripting/store.sp +++ b/addons/sourcemod/scripting/store.sp @@ -5,7 +5,7 @@ #define PLUGIN_NAME "Store - The Resurrection with preview system" #define PLUGIN_AUTHOR "Zephyrus, nuclear silo, AiDN™" #define PLUGIN_DESCRIPTION "A completely new Store system with preview rewritten by nuclear silo" -#define PLUGIN_VERSION "7.0.9" +#define PLUGIN_VERSION "7.1.0" #define PLUGIN_URL "" #define SERVER_LOCK_IP "" diff --git a/addons/sourcemod/scripting/store/cvars.sp b/addons/sourcemod/scripting/store/cvars.sp index 9b6e7db..25b5db1 100644 --- a/addons/sourcemod/scripting/store/cvars.sp +++ b/addons/sourcemod/scripting/store/cvars.sp @@ -30,7 +30,10 @@ int gc_iDescription = -1; int gc_iReloadType = -1; int gc_iReloadDelay = -1; int gc_iReloadNotify = -1; -ConVar g_cvarChatTag2; +ConVar g_cvarChatTag; + +#pragma unused g_cvarCenterTag +ConVar g_cvarCenterTag; void Store_Cvars_OnPluginStart() { @@ -61,7 +64,8 @@ void Store_Cvars_OnPluginStart() g_cvarCreditMessages = RegisterConVar("sm_store_credit_messages", "1", "Enable/disable messages when a player earns credits.", TYPE_INT); //g_cvarChatTag = RegisterConVar("sm_store_chat_tag", "[Store] ", "The chat tag to use for displaying messages.", TYPE_STRING); - g_cvarChatTag2 = AutoExecConfig_CreateConVar("sm_store_chat_tag_plugins", "[Store] ", "The chat tag to use for displaying messages."); + g_cvarChatTag = AutoExecConfig_CreateConVar("sm_store_chat_tag_plugins", "[Store] ", "The chat tag to use for displaying messages."); + g_cvarCenterTag = AutoExecConfig_CreateConVar("sm_store_center_tag", "[Store] ", "The chat tag to use for displaying messages in hint text box."); g_cvarShowSTEAM = RegisterConVar("sm_store_show_steam_items", "0", "If you enable this STEAM items will be shown in grey.", TYPE_INT); g_cvarShowVIP = RegisterConVar("sm_store_show_vip_items", "0", "If you enable this VIP items will be shown in grey.", TYPE_INT); @@ -78,7 +82,7 @@ void Store_Cvars_OnPluginStart() gc_iReloadNotify = RegisterConVar("sm_store_reload_config_notify", "1", "Store reloadconfig notify player", TYPE_INT); - g_cvarChatTag2.AddChangeHook(OnSettingChanged); + g_cvarChatTag.AddChangeHook(OnSettingChanged); // After every module was loaded we are ready to generate the cfg //AutoExecConfig(); @@ -88,7 +92,7 @@ void Store_Cvars_OnPluginStart() public void OnSettingChanged(ConVar convar, const char[] oldValue, const char[] newValue) { - if (convar == g_cvarChatTag2) + if (convar == g_cvarChatTag) { strcopy(g_sChatPrefix, sizeof(g_sChatPrefix), newValue); } diff --git a/addons/sourcemod/scripting/store/natives.sp b/addons/sourcemod/scripting/store/natives.sp index 413c0b2..a0f5a07 100644 --- a/addons/sourcemod/scripting/store/natives.sp +++ b/addons/sourcemod/scripting/store/natives.sp @@ -185,7 +185,7 @@ public int Native_SetClientCredits(Handle plugin,int numParams) int client = GetNativeCell(1); int m_iCredits = GetNativeCell(2); Store_LogMessage(client, m_iCredits-g_eClients[client].iCredits, "Set by external plugin"); - g_eClients[client].iCredits = m_iCredits; + g_eClients[client].iCredits = g_eClients[client].iCredits + m_iCredits <= 0 ? 0 : m_iCredits; Store_SaveClientData(client); return 1; } diff --git a/addons/sourcemod/scripting/store_combine.sp b/addons/sourcemod/scripting/store_combine.sp index dcde088..fa51de3 100644 --- a/addons/sourcemod/scripting/store_combine.sp +++ b/addons/sourcemod/scripting/store_combine.sp @@ -5,7 +5,7 @@ #define PLUGIN_NAME "Store - The Resurrection with preview system" #define PLUGIN_AUTHOR "Zephyrus, nuclear silo, AiDN™" #define PLUGIN_DESCRIPTION "A completely new Store system with preview rewritten by nuclear silo" -#define PLUGIN_VERSION "7.0.9" +#define PLUGIN_VERSION "7.1.0" #define PLUGIN_URL "" #define SERVER_LOCK_IP "" @@ -161,7 +161,10 @@ int hTime; Handle ReloadTimer = INVALID_HANDLE; -ConVar g_cvarChatTag2; +ConVar g_cvarChatTag; + +#pragma unused g_cvarCenterTag +ConVar g_cvarCenterTag; ////////////////////////////// // MODULES // @@ -302,7 +305,8 @@ public void OnPluginStart() g_cvarCreditMessages = RegisterConVar("sm_store_credit_messages", "1", "Enable/disable messages when a player earns credits.", TYPE_INT); //g_cvarChatTag = RegisterConVar("sm_store_chat_tag", "[Store] ", "The chat tag to use for displaying messages.", TYPE_STRING); - g_cvarChatTag2 = AutoExecConfig_CreateConVar("sm_store_chat_tag_plugins", "[Store] ", "The chat tag to use for displaying messages."); + g_cvarChatTag = AutoExecConfig_CreateConVar("sm_store_chat_tag_plugins", "[Store] ", "The chat tag to use for displaying messages."); + g_cvarCenterTag = AutoExecConfig_CreateConVar("sm_store_center_tag", "[Store] ", "The chat tag to use for displaying messages in hint text box."); g_cvarShowSTEAM = RegisterConVar("sm_store_show_steam_items", "0", "If you enable this STEAM items will be shown in grey.", TYPE_INT); g_cvarShowVIP = RegisterConVar("sm_store_show_vip_items", "0", "If you enable this VIP items will be shown in grey.", TYPE_INT); @@ -318,8 +322,8 @@ public void OnPluginStart() gc_iReloadDelay = RegisterConVar("sm_store_reload_config_delay", "10", "Time in second to reload current map on store reload config. Dependence: \"sm_store_reload_config_type\" 0", TYPE_INT); gc_iReloadNotify = RegisterConVar("sm_store_reload_config_notify", "1", "Store reloadconfig notify player", TYPE_INT); + g_cvarChatTag.AddChangeHook(OnSettingChanged); - g_cvarChatTag2.AddChangeHook(OnSettingChanged); // Register Commands RegConsoleCmd("sm_store", Command_Store); @@ -519,7 +523,7 @@ public void OnLibraryAdded(const char[] name) public void OnSettingChanged(ConVar convar, const char[] oldValue, const char[] newValue) { - if (convar == g_cvarChatTag2) + if (convar == g_cvarChatTag) { strcopy(g_sChatPrefix, sizeof(g_sChatPrefix), newValue); } diff --git a/addons/sourcemod/scripting/store_misc_giveaway.sp b/addons/sourcemod/scripting/store_misc_giveaway.sp index b283cf4..7463d93 100644 --- a/addons/sourcemod/scripting/store_misc_giveaway.sp +++ b/addons/sourcemod/scripting/store_misc_giveaway.sp @@ -10,8 +10,10 @@ ConVar gc_iCredits; ConVar gc_iMinPlayer; ConVar gc_iTimeInfo; ConVar gc_bAdmin; +ConVar g_cvCenterTag; char g_sChatPrefix[128]; +char g_sCenterPrefix[128]; //char g_sTag[32]; char admins[MAX_NAME_LENGTH]; @@ -23,7 +25,7 @@ public Plugin myinfo = { name = "Store Giveaway", author = "nuclear silo", description = "Giveaway plugin compatible with zephyrus store.", - version = "1.6", + version = "1.7", url = "" } @@ -40,14 +42,14 @@ public void OnPluginStart() AutoExecConfig(true, "giveaway", "sourcemod/store"); LoadTranslations("store.phrases"); - - // Supress warnings about unused variables..... - if(g_cvarChatTag){} } public void Store_OnConfigExecuted(char[] prefix) { strcopy(g_sChatPrefix, sizeof(g_sChatPrefix), prefix); + + g_cvCenterTag = FindConVar("sm_store_center_tag"); + g_cvCenterTag.GetString(g_sCenterPrefix, sizeof(g_sCenterPrefix)); } public int PlayerCount() @@ -140,7 +142,7 @@ public Action TimerGiveaway(Handle timer, any client) else randomNumber = GetRandomPlayerNoAdmin(); GetClientName(randomNumber, name, MAX_NAME_LENGTH); - Format(sBuffer, sizeof(sBuffer), "%t", "Giveaway winner hint text", g_sChatPrefix, name) + Format(sBuffer, sizeof(sBuffer), "%t", "Giveaway winner hint text", g_sCenterPrefix, name) PrintCenterTextAll(sBuffer); CPrintToChatAll("%t", "Giveaway winner chat", g_sChatPrefix, name, credits); diff --git a/addons/sourcemod/scripting/store_misc_giveaway_aidnversion.sp b/addons/sourcemod/scripting/store_misc_giveaway_aidnversion.sp index fb7eafb..12eae6a 100644 --- a/addons/sourcemod/scripting/store_misc_giveaway_aidnversion.sp +++ b/addons/sourcemod/scripting/store_misc_giveaway_aidnversion.sp @@ -13,8 +13,10 @@ ConVar gc_iCredits, gc_bOwnCredits, gc_vFlagStart; -//ConVar gc_sTag; +ConVar g_cvCenterTag; + char g_sChatPrefix[128]; +char g_sCenterPrefix[128]; //char g_sTag[32]; char admins[MAX_NAME_LENGTH]; @@ -28,7 +30,7 @@ public Plugin myinfo = { name = "Store Giveaway AiDN™ version", author = "nuclear silo, AiDN™", description = "Giveaway plugin compatible with zephyrus store.", - version = "1.2", + version = "1.3", url = "" } @@ -48,13 +50,14 @@ public void OnPluginStart() LoadTranslations("store.phrases"); - // Supress warnings about unused variables..... - if(g_cvarChatTag){} } public void Store_OnConfigExecuted(char[] prefix) { strcopy(g_sChatPrefix, sizeof(g_sChatPrefix), prefix); + + g_cvCenterTag = FindConVar("sm_store_center_tag"); + g_cvCenterTag.GetString(g_sCenterPrefix, sizeof(g_sCenterPrefix)); } public int PlayerCount() @@ -195,7 +198,7 @@ public Action TimerGiveaway(Handle timer, any client) else randomNumber = GetRandomPlayerNoAdmin(); GetClientName(randomNumber, name, MAX_NAME_LENGTH); - Format(sBuffer, sizeof(sBuffer), "%t", "Giveaway winner hint text", g_sChatPrefix, name) + Format(sBuffer, sizeof(sBuffer), "%t", "Giveaway winner hint text", g_sCenterPrefix, name) PrintCenterTextAll(sBuffer); CPrintToChatAll("%t", "Giveaway winner chat", g_sChatPrefix, name, credits);