Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ML support for property name in modes for config #5

Merged
merged 3 commits into from
May 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions cstrike/addons/amxmodx/configs/redm/gamemode_deathmatch.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
},
"modes": [
{
"name": "Pistols - HS ONLY",
"name": "PISTOLS_ONLY_HS",
"equip": {
"secondary": [
"weapon_usp",
Expand All @@ -96,7 +96,7 @@
}
},
{
"name": "Second round weapons",
"name": "SECOND_ROUND_WAEPONS",
"equip": {
"primary": [
"weapon_scout",
Expand Down Expand Up @@ -128,13 +128,13 @@
}
},
{
"name": "All weapons - HS ONLY",
"name": "ALL_WEAPONS_HS_ONLY",
"cvars": {
"mp_damage_headshot_only": "1"
}
},
{
"name": "All weapons"
"name": "ALL_WEAPONS"
}
]
}
11 changes: 11 additions & 0 deletions cstrike/addons/amxmodx/data/lang/redm/modes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[en]
ALL_WEAPONS = All weapons
ALL_WEAPONS_HS_ONLY = All weapons (only HS)
PISTOLS_ONLY_HS = Pistols (only HS)
SECOND_ROUND_WAEPONS = Second round weapons

[ru]
ALL_WEAPONS = Все оружия
ALL_WEAPONS_HS_ONLY = Все оружия (только HS)
PISTOLS_ONLY_HS = Пистолеты (только HS)
SECOND_ROUND_WAEPONS = Оружия 2-го раунда
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ Disabled = disabled
PrimaryEquip = Primary equip
SecondaryEquip = Secondary equip
ToClosePressG = \wTo close the menu - press `\yG\w`
CurrentMode = Current mode
CurrentMode = Current mode:
NextMode = Next Mode -
GunsHelp = Say ^3guns ^1to open equip menu.

[ru]
Expand All @@ -21,5 +22,6 @@ Disabled = отключено
PrimaryEquip = Основное оружие
SecondaryEquip = Дополнительное оружие
ToClosePressG = \wЧтобы закрыть меню - нажмите `\yG\w`
CurrentMode = Текущий режим
CurrentMode = Текущий режим:
NextMode = Следующий режим -
GunsHelp = Напишите ^3guns ^1чтобы открыть меню экипировки.
2 changes: 1 addition & 1 deletion cstrike/addons/amxmodx/scripting/ReDeathmatch.sma
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ static const g_soundEffects[][] = {

public plugin_init() {
register_plugin("ReDeathmatch", VERSION, "Sergey Shorokhov")
register_dictionary("redm.txt")
register_dictionary("redm/redm.txt")

create_cvar("redm_version", VERSION, (FCVAR_SERVER|FCVAR_SPONLY))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ static g_currentRoundModeIdx = -1
static redm_modes_switch[32]

RoundModes_Init() {
register_dictionary("redm/modes.txt")

RegisterHookChain(RG_RoundEnd, "RoundEnd", .post = false)
RegisterHookChain(RG_CSGameRules_RestartRound, "CSGameRules_RestartRound", .post = false)
RegisterHookChain(RG_CBasePlayer_OnSpawnEquip, "CBasePlayer_OnSpawnEquip", .post = false)
Expand All @@ -28,7 +30,9 @@ public RoundEnd(WinStatus: status, ScenarioEventEndRound: event, Float: tmDelay)
new modeName[32]
GetModeInfo(nextModeIdx, modeName, charsmax(modeName))

client_print_color(0, print_team_red, "[Re:DM] Next mode is `^3%s^1`",
client_print_color(0, print_team_red,
HasLangKey(modeName) ? "[Re:DM] %l ^3%l^1" : "[Re:DM] %l ^3%s^1",
"NextMode",
modeName
)

Expand All @@ -39,8 +43,7 @@ public CSGameRules_RestartRound() {
if (g_currentRoundModeIdx == -1)
return

new modeName[32]
if (!GetModeInfo(g_currentRoundModeIdx, modeName, charsmax(modeName)))
if (!GetModeInfo(g_currentRoundModeIdx))
return

ApplyMode(g_currentRoundModeIdx)
Expand Down Expand Up @@ -70,18 +73,16 @@ public CBasePlayer_OnSpawnEquip(const player, bool: addDefault, bool: equipGame)

SetGlobalTransTarget(player)

new bool: isLang = (GetLangTransKey(modeName) != TransKey_Bad)

show_dhudmessage(
player,
isLang ? "%l: %l" : "%l: %s",
HasLangKey(modeName) ? "%l %l" : "%l %s",
"CurrentMode",
modeName
)
}


static GetModeInfo(const index, name[], len) {
static GetModeInfo(const index, name[] = "", len = 0) {
if (!json_object_has_value(Config_GetCurrent(), "modes"))
return false

Expand Down
4 changes: 4 additions & 0 deletions cstrike/addons/amxmodx/scripting/include/redm.inc
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,7 @@ stock UTIL_DumpJSON(JSON: obj, msg[]) {

server_print("%s:`%s`", msg, buffer)
}

stock bool: HasLangKey(const string[]) {
return (GetLangTransKey(string) != TransKey_Bad)
}