View Single Post
SmokieCS
AlliedModders Donor
Join Date: Nov 2019
Location: Denmark
Old 08-23-2021 , 06:25   Re: Translations not going through.
Reply With Quote #3

Quote:
Originally Posted by Psyk0tik View Post
First off, you have to pass the section name of a phrase to "%t"/"%T" and then pass the actual params used in the phrase.
PHP Code:
PrintToChatAll("%t""ForcePause"name);
PrintToChatAll("%t""ForceUnpause"name);
PrintToChatAll("%t""Pause"name);
PrintToChatAll("%t""ctUnpause");
PrintToChatAll("%t""tUnpause"); 
For "%T" you'll want to pass the client index or "LANG_SERVER" before passing the params.
PHP Code:
PrintToChatAll("%T""ForcePause"clientname);
PrintToChatAll("%T""ForceUnpause"clientname);
PrintToChatAll("%T""Pause"clientname);
PrintToChatAll("%T""ctUnpause"client);
PrintToChatAll("%T""tUnpause"client); 
Then, in your translation file, you don't need any format specifiers for "ctUnpause" and "tUnpause" since you don't use any in the actual phrases.
Code:
"ctUnpause"
{
	"#format"	"{1:s}"
	"en"		"The CT team wants to unpause. Waiting for the T team to type \x05!unpause"
}

"tUnpause"
{
	"#format"	"{1:s}"
	"en"		"The T team wants to unpause. Waiting for the CT team to type \x05!unpause"
}
Finally, you can just pass the client index and use the "%N" format specifier to retrieve the client's name instead of setting up a buffer and calling "GetClientName" each time.

Plugin:
PHP Code:
PrintToChatAll("%T""ForcePause"clientclient);
PrintToChatAll("%T""ForceUnpause"clientclient);
PrintToChatAll("%T""Pause"clientclient); 
Translation file:
Code:
"ForcePause"
{
	"#format"	"{1:N}"
	"en"		"{1} has paused"
}

"ForceUnpause"
{
	"#format"	"{1:N}"
	"en"		"{1} has unpaused"
}

"Pause"
{
	"#format"	"{1:N}"
	"en"		"{1} has requested a pause"
}
Sadly this did not fix anything for me. I get the understanding of the translation process, but for some reason it is still not showing anything in the game... The code is as following now:

PHP Code:
#pragma semicolon 1
#include <cstrike>
#include <sourcemod>
#include <sdktools>

/** Bools **/
new bool:g_ctUnpaused false;
new 
bool:g_tUnpaused false;

/** Chat aliases loaded **/
#define ALIAS_LENGTH 64
#define COMMAND_LENGTH 64
ArrayList g_ChatAliases;
ArrayList g_ChatAliasesCommands;

public 
Plugin:myinfo = {
    
name "CS:GO Pause Commands",
    
author "splewis & ^kS",
    
description "Adds simple pause/unpause commands for players",
    
version "1.0.2",
    
url "https://forums.alliedmods.net"
};

public 
void OnPluginStart() {
    
/** Load Translations **/
    
LoadTranslations("pauseplugin.phrases");

    
/** Cmds **/
    
RegAdminCmd("sm_forcetechpause"Command_ForceTechPauseADMFLAG_GENERIC"Forces a technical pause");
    
RegAdminCmd("sm_forcepause"Command_ForcePauseADMFLAG_GENERIC"Forces a pause");
    
RegAdminCmd("sm_forceunpause"Command_ForceUnpauseADMFLAG_GENERIC"Forces an unpause");
    
RegConsoleCmd("sm_pause"Command_Pause"Requests a pause");
    
RegConsoleCmd("sm_unpause"Command_Unpause"Requests an unpause");
    
RegConsoleCmd("sm_tech"Command_TechPause"Calls for a text pause");


    
/** Client / Admin commands **/
    
g_ChatAliases = new ArrayList(ByteCountToCells(ALIAS_LENGTH));
    
g_ChatAliasesCommands = new ArrayList(ByteCountToCells(COMMAND_LENGTH));
    
AddAliasedCommand("forcetechnical"Command_ForceTechPause"Force a technical pause");
    
AddAliasedCommand("ftech"Command_ForceTechPause"Force a technical pause");
    
AddAliasedCommand("ftec"Command_ForceTechPause"Force a technical pause");
    
AddAliasedCommand("forcepause"Command_ForcePause"Forces the game to pause");
    
AddAliasedCommand("fp"Command_ForcePause"Forces the game to pause");
    
AddAliasedCommand("forceunpause"Command_ForceUnpause"Forces the game to unpause");
    
AddAliasedCommand("fup"Command_ForceUnpause"Forces the game to unpause");
    
AddAliasedCommand("tech"Command_TechPause"Calls for a tech pause");
    
AddAliasedCommand("pause"Command_Pause"Pauses the game");
    
AddAliasedCommand("tac"Command_Pause"Pauses the game");
    
AddAliasedCommand("p"Command_Pause"Pauses the game");
    
AddAliasedCommand("tactical"Command_Pause"Pauses the game");
    
AddAliasedCommand("unpause"Command_Unpause"Unpauses the game");
    
AddAliasedCommand("up"Command_Unpause"Unpauses the game");
}

public 
OnMapStart() {
    
g_ctUnpaused false;
    
g_tUnpaused false;
}

/** Force Tech Pause **/
public Action Command_ForceTechPause(int clientint args){
    if (
IsPaused())
        return 
Plugin_Handled;

    
ServerCommand("mp_pause_match");
    
PrintToChatAll("%T, ForceTechPauseMessage"LANG_SERVER);
    return 
Plugin_Handled;
}

/** Force Pause **/
public Action Command_ForcePause(int clientint args) {
    if (
IsPaused())
        return 
Plugin_Handled;

    
ServerCommand("mp_pause_match");
    
PrintToChatAll("%T""ForcePause"LANG_SERVER);
    return 
Plugin_Handled;
}

/** Force Unpause **/
public Action Command_ForceUnpause(int clientint args) {
    if (!
IsPaused())
        return 
Plugin_Handled;
    
    
ServerCommand("mp_unpause_match");
    
PrintToChatAll("%T""ForceUnpause"client);
    return 
Plugin_Handled;
}

/** Technical Pause **/
public Action Command_TechPause(int clientint args){
    if (
IsPaused())
        return 
Plugin_Handled;

    
ServerCommand("mp_pause_match");
    
PrintToChatAll("%T, TechPauseMessage"clientclient);
    return 
Plugin_Handled;
}

/** Pause **/
public Action Command_Pause(int clientint args) {
    if (
IsPaused() || !IsValidClient(client))
        return 
Plugin_Handled;

    
g_ctUnpaused false;
    
g_tUnpaused false;

    
ServerCommand("mp_pause_match");
    
PrintToChatAll("%T""Pause"clientclient);

    return 
Plugin_Handled;
}

/** Unpause **/
public Action Command_Unpause(int clientint args) {
    if (!
IsPaused() || !IsValidClient(client))
        return 
Plugin_Handled;

    new 
team GetClientTeam(client);

    if (
team == CS_TEAM_T)
        
g_tUnpaused true;
    else if (
team == CS_TEAM_CT)
        
g_ctUnpaused true;

    if (
g_tUnpaused && g_ctUnpaused)  {
        
ServerCommand("mp_unpause_match");
    } else if (
g_tUnpaused && !g_ctUnpaused) {
        
PrintToChatAll("%T""tUnpause"LANG_SERVER);
    } else if (!
g_tUnpaused && g_ctUnpaused) {
        
PrintToChatAll("%T""ctUnpause"LANG_SERVER);
    }

    return 
Plugin_Handled;
}

/** Valid client state **/
stock bool:IsValidClient(client) {
    if (
client && client <= MaxClients && IsClientConnected(client) && IsClientInGame(client))
        return 
true;
    return 
false;
}

/** IsPaused state **/
stock bool:IsPaused() {
    return 
bool:GameRules_GetProp("m_bMatchWaitingForResume");
}

/** Add Aliased Command callback **/
public void AddAliasedCommand(const char[] commandConCmd callback, const char[] description) {
  
char smCommandBuffer[COMMAND_LENGTH];
  
Format(smCommandBuffersizeof(smCommandBuffer), "sm_%s"command);
  
RegConsoleCmd(smCommandBuffercallbackdescription);

  
char dotCommandBuffer[ALIAS_LENGTH];
  
Format(dotCommandBuffersizeof(dotCommandBuffer), ".%s"command);
  
AddChatAlias(dotCommandBuffersmCommandBuffer);
}

/** Add Chat Alias Callback */
public void AddChatAlias(const char[] alias, const char[] command) {
  
// Don't allow duplicate aliases to be added.
  
if (g_ChatAliases.FindString(alias) == -1) {
    
g_ChatAliases.PushString(alias);
    
g_ChatAliasesCommands.PushString(command);
  }
}

/** Check to chat alias callback **/
public void CheckForChatAlias(int client, const char[] command, const char[] sArgs) {
  
// Splits to find the first word to do a chat alias command check.
  
char chatCommand[COMMAND_LENGTH];
  
char chatArgs[255];
  
int index SplitString(sArgs" "chatCommandsizeof(chatCommand));

  if (
index == -1) {
    
strcopy(chatCommandsizeof(chatCommand), sArgs);
  } else if (
index strlen(sArgs)) {
    
strcopy(chatArgssizeof(chatArgs), sArgs[index]);
  }

  if (
chatCommand[0] && IsValidClient(client)) {
    
char alias[ALIAS_LENGTH];
    
char cmd[COMMAND_LENGTH];
    for (
int i 0GetArraySize(g_ChatAliases); i++) {
      
GetArrayString(g_ChatAliasesialiassizeof(alias));
      
GetArrayString(g_ChatAliasesCommandsicmdsizeof(cmd));
      if (
CheckChatAlias(aliascmdchatCommandchatArgsclient)) {
        break;
      }
    }
  }
}

/* Checking if the alias is a command callback */
static bool CheckChatAlias(const char[] alias, const char[] command, const char[] chatCommand,
                           const 
char[] chatArgsint client) {
  if (
StrEqual(chatCommandaliasfalse)) {
    
// Get the original cmd reply source so it can be restored after the fake client command.
    // This means and ReplyToCommand will go into the chat area, rather than console, since
    // *chat* aliases are for *chat* commands.
    
ReplySource replySource GetCmdReplySource();
    
SetCmdReplySource(SM_REPLY_TO_CHAT);
    
char fakeCommand[256];
    
Format(fakeCommandsizeof(fakeCommand), "%s %s"commandchatArgs);
    
FakeClientCommand(clientfakeCommand);
    
SetCmdReplySource(replySource);
    return 
true;
  }
  return 
false;

Phrases file:
PHP Code:
"Phrases"
{
  
"ForceTechPauseMessage"
  
{
    
"en"      "An admin has called for a technical pause."
  
}

  
"ForcePause"
  
{
    
"en"      "An admin forced a pause!"
  
}

  
"ForceUnpause"
  
{
    
"en"      "An admin forced a unpause!"
  
}

  
"TechPauseMessage"
  
{
    
"#format" "{1:N}"
    "en"      "{1} has called for a technical pause."
  
}

  
"Pause"
  
{
    
"#format" "{1:N}"
    "en"      "{1} has requested a pause"
  
}

  
"ctUnpause"
  
{
    
"en"      "The CT team wants to unpause. Waiting for the T team to type \x05!unpause"
  
}

  
"tUnpause"
  
{
    
"en"      "The T team wants to unpause. Waiting for the CT team to type \x05!unpause"
  
}

__________________
Server Manager & Chairman of the Board - https://esportharte.dk/
Freelance Server Support
Former Co-Owner - https://tfrag.dk/
SmokieCS is offline