From 1c0000cb28143e062b62888418a5f91d02e2f7ae Mon Sep 17 00:00:00 2001 From: nosoop Date: Wed, 17 Mar 2021 04:41:22 -0700 Subject: [PATCH] Respect client respawn-on-loadout preferences --- scripting/cwx.sp | 27 ++++++++++++++++++++------- translations/cwx.phrases.txt | 29 +++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 7 deletions(-) diff --git a/scripting/cwx.sp b/scripting/cwx.sp index 61495d3..018f36e 100644 --- a/scripting/cwx.sp +++ b/scripting/cwx.sp @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -287,15 +288,27 @@ void UnsetClientCustomLoadoutItem(int client, int playerClass, int itemSlot) { } void OnClientCustomLoadoutItemModified(int client) { - if (!IsPlayerInRespawnRoom(client)) { - // TODO: notify that the player will get the item when they resup - + if (IsPlayerInRespawnRoom(client)) { + // see if the player is into being respawned on loadout changes + QueryClientConVar(client, "tf_respawn_on_loadoutchanges", OnLoadoutRespawnPreference); } else { - // player is respawned - TF2_RespawnPlayer(client); + PrintColoredChatEx(client, CHAT_SOURCE_SELF, COLOR_TEAM ... "%t", + "LoadoutChangesUpdate"); + } +} + +void OnLoadoutRespawnPreference(QueryCookie cookie, int client, ConVarQueryResult result, + const char[] cvarName, const char[] cvarValue) { + if (result != ConVarQuery_Okay) { + return; + } else if (!StringToInt(cvarValue) || !IsPlayerInRespawnRoom(client)) { + // the second check for respawn room is in case we're somehow not in one between + // the query and the callback + PrintColoredChatEx(client, CHAT_SOURCE_SELF, COLOR_TEAM ... "%t", + "LoadoutChangesUpdate"); + return; } - // NOTE: we don't do active reequip on live players, because that's kind of a mess - // return LookupAndEquipItem(client, itemuid); + TF2_RespawnPlayer(client); } /** diff --git a/translations/cwx.phrases.txt b/translations/cwx.phrases.txt index d01aa24..85925bf 100644 --- a/translations/cwx.phrases.txt +++ b/translations/cwx.phrases.txt @@ -896,4 +896,33 @@ "ua" "(надягнено)" "zho" "(已裝備)" } + "LoadoutChangesUpdate" + { + "bg" "Забележка: Промените по снаряжението ще бъдат приложени при следващото прераждане." + "chi" "注意:配置更改将在重生后生效。" + "cze" "Poznámka: Změny vybavení se projeví po respawnu." + "da" "Bemærk: Udstyret ændres først, når du vender tilbage." + "de" "Hinweis: Ausrüstungsänderungen nach Respawn verfügb." + "el" "Σημειωση: Οι αλλαγεσ στον εξοπλισμο θα συμβουν με την αναβιωση." + "en" "Note: Loadout changes will take effect on respawn." + "es" "Aviso: Los cambios en el equipamiento surtirán efecto al regenerarse." + "fi" "HUOMAA! VARUSTELASTIMUUTOKSET VAIKUTTAVAT UUDELLEENSYNTYMISEEN" + "fr" "Remarque : Les modifications d'équipement prendront effet à la réapparition." + "hu" "Megjegyzés: A felszerelés változása újraéledéskor lép érvénybe." + "it" "Nota: I cambi d'equipaggiamento avranno effetto al rientro in gioco." + "ja" "注:装備の変更は復活後から有効になります" + "ko" "주의: 장비 설정을 변경하면 부활에 영향을 줄 수 있습니다." + "nl" "Opmerking: Wijzigingen in de uitrusting worden van kracht wanneer je respawnt." + "no" "Merk: Endring av oppakning trer i kraft ved gjenoppliving." + "pl" "Uwaga: Zmiany w wyposażeniu uaktywnią się po odrodzeniu." + "pt" "Aviso: Alterações no equipamento surtirão efeito ao renascer." + "pt_p" "Nota: As alterações de equipamento são aplicadas ao reentrar em jogo." + "ro" "Atenţie: Schimbările echipamentului în meniul de arme vor avea efect în momentul reînvierii." + "ru" "Примечание: Снаряжение изменится после возрождения" + "sv" "Obs! Utrustningsändringar träder i kraft vid återskapande." + "th" "หมายเหตุ: การเปลี่ยนชุดอุปกรณ์จะได้ผลเมื่อเกิดใหม่" + "tr" "Not: Ekİpman değİşİmİ canlanmada uygulanacak." + "ua" "Увага: Зміни спорядження стануться після відродження." + "zho" "注意:重生後,武器裝備的變更才會生效。" + } }