Updated basetriggers to use more translation friendly phrases (bug 3330, r=dvander).
Updated basetriggers to use more translation friendly phrases (
bug 3330, r=dvander).
Basetriggers now counts rounds remaining for mp_maxrounds output.
1.1 --- a/plugins/basetriggers.sp Wed Oct 15 20:42:47 2008 +1300
1.2 +++ b/plugins/basetriggers.sp Thu Oct 16 10:54:23 2008 +1300
1.3 @@ -64,6 +64,8 @@
1.4
1.5 new bool:mapchooser;
1.6
1.7 +new g_TotalRounds;
1.8 +
1.9 public OnPluginStart()
1.10 {
1.11 LoadTranslations("common.phrases");
1.12 @@ -81,6 +83,11 @@
1.13
1.14 HookConVarChange(g_Cvar_TimeleftInterval, ConVarChange_TimeleftInterval);
1.15
1.16 + HookEvent("round_end", Event_RoundEnd);
1.17 + HookEvent("game_start", Event_GameStart);
1.18 + HookEventEx("teamplay_win_panel", Event_TeamPlayWinPanel);
1.19 + HookEventEx("teamplay_restart_round", Event_TFRestartRound);
1.20 + HookEventEx("arena_win_panel", Event_TeamPlayWinPanel);
1.21
1.22 g_Cvar_WinLimit = FindConVar("mp_winlimit");
1.23 g_Cvar_FragLimit = FindConVar("mp_fraglimit");
1.24 @@ -89,6 +96,37 @@
1.25 mapchooser = LibraryExists("mapchooser");
1.26 }
1.27
1.28 +public OnMapStart()
1.29 +{
1.30 + g_TotalRounds = 0;
1.31 +}
1.32 +
1.33 +/* Round count tracking */
1.34 +public Event_TFRestartRound(Handle:event, const String:name[], bool:dontBroadcast)
1.35 +{
1.36 + /* Game got restarted - reset our round count tracking */
1.37 + g_TotalRounds = 0;
1.38 +}
1.39 +
1.40 +public Event_GameStart(Handle:event, const String:name[], bool:dontBroadcast)
1.41 +{
1.42 + /* Game got restarted - reset our round count tracking */
1.43 + g_TotalRounds = 0;
1.44 +}
1.45 +
1.46 +public Event_TeamPlayWinPanel(Handle:event, const String:name[], bool:dontBroadcast)
1.47 +{
1.48 + if(GetEventInt(event, "round_complete") == 1 || StrEqual(name, "arena_win_panel"))
1.49 + {
1.50 + g_TotalRounds++;
1.51 + }
1.52 +}
1.53 +/* You ask, why don't you just use team_score event? And I answer... Because CSS doesn't. */
1.54 +public Event_RoundEnd(Handle:event, const String:name[], bool:dontBroadcast)
1.55 +{
1.56 + g_TotalRounds++;
1.57 +}
1.58 +
1.59 public OnLibraryRemoved(const String:name[])
1.60 {
1.61 if (StrEqual(name, "mapchooser"))
1.62 @@ -330,12 +368,27 @@
1.63 new len = strlen(finalOutput);
1.64 if (len < sizeof(finalOutput))
1.65 {
1.66 - FormatEx(finalOutput[len], sizeof(finalOutput)-len, "%T", "WinLimitAppend" ,client, winlimit, (winlimit == 1)? "":"s");
1.67 + if (winlimit > 1)
1.68 + {
1.69 + FormatEx(finalOutput[len], sizeof(finalOutput)-len, "%T", "WinLimitAppendPlural" ,client, winlimit);
1.70 + }
1.71 + else
1.72 + {
1.73 + FormatEx(finalOutput[len], sizeof(finalOutput)-len, "%T", "WinLimitAppend" ,client);
1.74 + }
1.75 }
1.76 }
1.77 else
1.78 {
1.79 - FormatEx(finalOutput, sizeof(finalOutput), "%T", "WinLimit", client, winlimit, (winlimit == 1)? "":"s");
1.80 + if (winlimit > 1)
1.81 + {
1.82 + FormatEx(finalOutput, sizeof(finalOutput), "%T", "WinLimitPlural", client, winlimit);
1.83 + }
1.84 + else
1.85 + {
1.86 + FormatEx(finalOutput, sizeof(finalOutput), "%T", "WinLimit", client);
1.87 + }
1.88 +
1.89 written = true;
1.90 }
1.91 }
1.92 @@ -352,12 +405,27 @@
1.93 new len = strlen(finalOutput);
1.94 if (len < sizeof(finalOutput))
1.95 {
1.96 - FormatEx(finalOutput[len], sizeof(finalOutput)-len, "%T", "FragLimitAppend", client, fraglimit, (fraglimit == 1)? "":"s");
1.97 + if (fraglimit > 1)
1.98 + {
1.99 + FormatEx(finalOutput[len], sizeof(finalOutput)-len, "%T", "FragLimitAppendPlural", client, fraglimit);
1.100 + }
1.101 + else
1.102 + {
1.103 + FormatEx(finalOutput[len], sizeof(finalOutput)-len, "%T", "FragLimitAppend", client);
1.104 + }
1.105 }
1.106 }
1.107 else
1.108 {
1.109 - FormatEx(finalOutput, sizeof(finalOutput), "%T", "FragLimit", client, fraglimit, (fraglimit == 1)? "":"s");
1.110 + if (fraglimit > 1)
1.111 + {
1.112 + FormatEx(finalOutput, sizeof(finalOutput), "%T", "FragLimitPlural", client, fraglimit);
1.113 + }
1.114 + else
1.115 + {
1.116 + FormatEx(finalOutput, sizeof(finalOutput), "%T", "FragLimit", client);
1.117 + }
1.118 +
1.119 written = true;
1.120 }
1.121 }
1.122 @@ -369,17 +437,34 @@
1.123
1.124 if (maxrounds > 0)
1.125 {
1.126 + new remaining = maxrounds - g_TotalRounds;
1.127 +
1.128 if (written)
1.129 {
1.130 new len = strlen(finalOutput);
1.131 if (len < sizeof(finalOutput))
1.132 {
1.133 - FormatEx(finalOutput[len], sizeof(finalOutput)-len, "%T", "MaxRoundsAppend", client, maxrounds, (maxrounds == 1)? "":"s");
1.134 + if (remaining > 1)
1.135 + {
1.136 + FormatEx(finalOutput[len], sizeof(finalOutput)-len, "%T", "MaxRoundsAppendPlural", client, remaining);
1.137 + }
1.138 + else
1.139 + {
1.140 + FormatEx(finalOutput[len], sizeof(finalOutput)-len, "%T", "MaxRoundsAppend", client);
1.141 + }
1.142 }
1.143 }
1.144 else
1.145 {
1.146 - FormatEx(finalOutput, sizeof(finalOutput), "%T", "MaxRounds", client, maxrounds, (maxrounds == 1)? "":"s");
1.147 + if (remaining > 1)
1.148 + {
1.149 + FormatEx(finalOutput, sizeof(finalOutput), "%T", "MaxRoundsPlural", client, remaining);
1.150 + }
1.151 + else
1.152 + {
1.153 + FormatEx(finalOutput, sizeof(finalOutput), "%T", "MaxRounds", client);
1.154 + }
1.155 +
1.156 written = true;
1.157 }
1.158 }
2.1 --- a/translations/basetriggers.phrases.txt Wed Oct 15 20:42:47 2008 +1300
2.2 +++ b/translations/basetriggers.phrases.txt Thu Oct 16 10:54:23 2008 +1300
2.3 @@ -29,37 +29,68 @@
2.4
2.5 "WinLimitAppend"
2.6 {
2.7 - "#format" "{1:i},{2:s}"
2.8 - "en" ", or change map after a team wins {1} round{2}"
2.9 + "en" ", or change map after a team wins one round"
2.10 }
2.11
2.12 "WinLimit"
2.13 {
2.14 - "#format" "{1:i},{2:s}"
2.15 - "en" "Map will change after a team wins {1} round{2}"
2.16 + "en" "Map will change after a team wins one round"
2.17 }
2.18
2.19 "MaxRoundsAppend"
2.20 {
2.21 - "#format" "{1:i},{2:s}"
2.22 - "en" ", or change map after {1} round{2}"
2.23 + "en" ", or change map after one more round"
2.24 }
2.25
2.26 "MaxRounds"
2.27 {
2.28 - "#format" "{1:i},{2:s}"
2.29 - "en" "Map will change after {1} round{2}"
2.30 + "en" "Map will change after one more round"
2.31 }
2.32
2.33 "FragLimitAppend"
2.34 {
2.35 - "#format" "{1:i},{2:s}"
2.36 - "en" ", or change map after player reaches {1} frag{2}"
2.37 + "en" ", or change map after player reaches one frag"
2.38 }
2.39 +
2.40 "FragLimit"
2.41 {
2.42 - "#format" "{1:i},{2:s}"
2.43 - "en" "Map will change after a player reaches {1} frag{2}"
2.44 + "en" "Map will change after a player reaches one frag"
2.45 + }
2.46 +
2.47 + "WinLimitAppendPlural"
2.48 + {
2.49 + "#format" "{1:i}"
2.50 + "en" ", or change map after a team wins {1} rounds"
2.51 + }
2.52 +
2.53 + "WinLimitPlural"
2.54 + {
2.55 + "#format" "{1:i}"
2.56 + "en" "Map will change after a team wins {1} rounds"
2.57 + }
2.58 +
2.59 + "MaxRoundsAppendPlural"
2.60 + {
2.61 + "#format" "{1:i}"
2.62 + "en" ", or change map after {1} more rounds"
2.63 + }
2.64 +
2.65 + "MaxRoundsPlural"
2.66 + {
2.67 + "#format" "{1:i}"
2.68 + "en" "Map will change after {1} more rounds"
2.69 + }
2.70 +
2.71 + "FragLimitAppendPlural"
2.72 + {
2.73 + "#format" "{1:i}"
2.74 + "en" ", or change map after player reaches {1} frags"
2.75 + }
2.76 +
2.77 + "FragLimitPlural"
2.78 + {
2.79 + "#format" "{1:i}"
2.80 + "en" "Map will change after a player reaches {1} frags"
2.81 }
2.82
2.83 "LastRound"