Skip to content

Commit

Permalink
Respect client respawn-on-loadout preferences
Browse files Browse the repository at this point in the history
  • Loading branch information
nosoop committed Mar 17, 2021
1 parent ab73cbd commit 1c0000c
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 7 deletions.
27 changes: 20 additions & 7 deletions scripting/cwx.sp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include <tf2wearables>
#include <tf_econ_data>
#include <stocksoup/color_literals>
#include <stocksoup/convars>
#include <stocksoup/math>
#include <stocksoup/tf/econ>
Expand Down Expand Up @@ -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);
}

/**
Expand Down
29 changes: 29 additions & 0 deletions translations/cwx.phrases.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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" "注意:重生後,武器裝備的變更才會生效。"
}
}

0 comments on commit 1c0000c

Please sign in to comment.