Browse Source

Use translations for connect / disconnect

The translations remove the disconnect reason.
Using stocksoup to have nicer join / leave messages in the developer console.
nosoop 5 years ago
parent
commit
2ae066d122
4 changed files with 75 additions and 8 deletions
  1. 3 0
      .gitmodules
  2. 10 8
      scripting/botmanager.sp
  3. 1 0
      scripting/include/stocksoup
  4. 61 0
      translations/csrd_botmanager.phrases.txt

+ 3 - 0
.gitmodules

@@ -0,0 +1,3 @@
+[submodule "scripting/include/stocksoup"]
+	path = scripting/include/stocksoup
+	url = https://github.com/nosoop/stocksoup

+ 10 - 8
scripting/botmanager.sp

@@ -5,11 +5,11 @@
 #include <tf2>
 #include <tf2_stocks>
 
-#include <printvalvetranslation>
-
 #pragma newdecls required
 
-#define PLUGIN_VERSION "1.3.8"
+#include <stocksoup/color_literals>
+
+#define PLUGIN_VERSION "1.4.0"
 
 public Plugin myinfo = {
 	name = "[TF2] Bot Manager",
@@ -44,6 +44,8 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max
 }
 
 public void OnPluginStart() {
+	LoadTranslations("csrd_botmanager.phrases");
+	
 	cvarBotQuota = CreateConVar("sm_bot_quota", "0", "Number of players to keep in the server");
 	cvarBotJoinAfterPlayer = CreateConVar("sm_bot_join_after_player", "1",
 			"If nonzero, bots wait until a player joins before entering the game.");
@@ -201,7 +203,8 @@ void AddBot() {
 	Call_PushCellRef(class);
 	Call_PushCellRef(team);
 	Call_PushCellRef(difficulty);
-	Call_PushStringEx(name, sizeof(name), SM_PARAM_STRING_UTF8|SM_PARAM_STRING_COPY, SM_PARAM_COPYBACK);
+	Call_PushStringEx(name, sizeof(name), SM_PARAM_STRING_UTF8 | SM_PARAM_STRING_COPY,
+			SM_PARAM_COPYBACK);
 	Call_Finish();
 	
 	char strDifficulty[16], strTeam[16], strClass[16];
@@ -303,8 +306,7 @@ public Action Event_PlayerDisconnect(Event event, const char[] name, bool dontBr
 		char botDisplay[128];
 		Format(botDisplay, sizeof(botDisplay), "\x07%06X%N\x01",
 					GetTeamColor(GetClientTeam(client)), client);
-		PrintValveTranslationToAll(Destination_Chat, "game_player_left_game", botDisplay,
-				"TF_Scoreboard_Bot");
+		PrintColoredChatAll("%t", "game_bot_player_left_game", botDisplay);
 	}
 	return Plugin_Continue;
 }
@@ -320,13 +322,13 @@ public Action Event_PlayerTeam(Event event, const char[] name, bool dontBroadcas
 		if ((pos = joiningBots.FindValue(GetClientUserId(client))) != -1) {
 			joiningBots.Erase(pos);
 			
-			PrintToServer("%N (BOT) has joined the game", client);
+			PrintToServer("BOT %N has joined the game", client);
 			
 			char botDisplay[128];
 			Format(botDisplay, sizeof(botDisplay), "\x07%06X%N\x01",
 					GetTeamColor(event.GetInt("team")), client);
 			
-			PrintValveTranslationToAll(Destination_Chat, "game_player_joined_game", botDisplay);
+			PrintColoredChatAll("%t", "game_bot_player_joined_game", botDisplay);
 		}
 	}
 	return Plugin_Continue;

+ 1 - 0
scripting/include/stocksoup

@@ -0,0 +1 @@
+Subproject commit f76f6c399cc3aaced5035ed539e938e2088e0526

+ 61 - 0
translations/csrd_botmanager.phrases.txt

@@ -0,0 +1,61 @@
+"Phrases"
+{
+	"game_bot_player_joined_game"
+	{
+		"#format" "{1:s}"
+		"bg" "{1} се присъедини в играта"
+		"chi" "{1} 加入游戏"
+		"cze" "Hráč {1} se připojil do hry"
+		"da" "{1} har sluttet sig til spillet"
+		"de" "{1} nimmt jetzt am Spiel teil."
+		"el" "Ο χρήστης {1} εισήλθε στο παιχνίδι"
+		"en" "{1} has joined the game"
+		"es" "{1} se ha incorporado a la partida"
+		"fi" "{1} liittyi peliin"
+		"fr" "Le joueur {1} a rejoint la partie"
+		"hu" "{1} belépett a játékba"
+		"it" "{1} si è unito alla partita"
+		"ja" "プレイヤー {1} がゲームに参加しました"
+		"ko" "{1} 님이 게임에 참가했습니다."
+		"nl" "{1} neemt deel aan het spel"
+		"pl" "Gracz {1} dołączył do gry"
+		"pt" "{1} entrou na partida"
+		"pt_p" "{1} entrou na partida"
+		"ro" "Jucătorul {1} s-a alăturat jocului"
+		"ru" "{1} вступает в игру"
+		"sv" "{1} gick med i spelet"
+		"th" "{1} ได้เข้าร่วมเกม"
+		"tr" "{1} oyuna katıldı"
+		"ua" "{1} долучається до гри"
+		"zho" "玩家 {1} 加入遊戲"
+	}
+	"game_bot_player_left_game"
+	{
+		"#format" "{1:s}"
+		"bg" "{1} напусна играта"
+		"chi" "{1} 离开了游戏"
+		"cze" "Hráč {1} opustil hru"
+		"da" "{1} har forladt spillet"
+		"de" "{1} hat das Spiel verlassen."
+		"el" "Ο παίκτης {1} αποχώρησε από το παιχνίδι"
+		"en" "{1} left the game"
+		"es" "{1} ha abandonado la partida"
+		"fi" "{1} lähti pelistä"
+		"fr" "Le joueur {1} a quitté la partie"
+		"hu" "{1} kilépett a játékból"
+		"it" "{1} ha abbandonato la partita"
+		"ja" "プレイヤー {1} がゲームを退出しました"
+		"ko" "{1} 님이 게임에서 나갔습니다."
+		"nl" "{1} heeft het spel verlaten"
+		"pl" "Gracz {1} opuścił grę"
+		"pt" "{1} saiu da partida"
+		"pt_p" "{1} saiu da partida"
+		"ro" "Jucătorul {1} a părăsit jocul"
+		"ru" "{1} покидает игру"
+		"sv" "{1} har lämnat spelet"
+		"th" "{1} ออกจากเกม"
+		"tr" "{1} oyundan ayrıldı"
+		"ua" "{1} залишає гру"
+		"zho" "玩家 {1} 離開遊戲"
+	}
+}