AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Solved KickClient Message translation (https://forums.alliedmods.net/showthread.php?t=321667)

Lord Nightmare 02-22-2020 12:19

KickClient Message translation
 
Hi folks
I can't figure out how to force a translated message on player kick.
Translation file has been created and still showing me a English phrase.
Can someone help me with that or maybe show me whats wrong with my code?

PHP Code:


#pragma semicolon 1

#define DEBUG

#define PLUGIN_AUTHOR "Lord N"
#define PLUGIN_VERSION "1.00"

#include <sourcemod>
#include <sdktools>
#include <cstrike>

#pragma newdecls required

int LimitPlayers 1;

public 
Plugin myinfo 
{
    
name "Test Kick Message",
    
author PLUGIN_AUTHOR,
    
description "",
    
version PLUGIN_VERSION,
    
url ""
};

public 
void OnPluginStart()
{
    
LoadTranslations("slot.phrases");
}
public 
Action OnClientPreAdminCheck(int client)
{
    
int MaxSlots GetMaxHumanPlayers();
    
int CurrentPlayers GetClientCount(false);
    
    
    if(
CurrentPlayers == MaxSlots){
        
        
KickClientEx(client"MAX PLAYERS!");
    }
    else if(
CurrentPlayers >= LimitPlayers){
        
        
MessageDeliver(client);
    }
}
public 
Action MessageDeliver(int client){
    
    
char Message[64];
    
FormatEx(Messagesizeof(Message), "%t""WarningTest");
    
KickClientEx(clientMessage);



DJ Tsunami 02-22-2020 12:58

Re: KickClient Message translation
 
As explained on https://wiki.alliedmods.net/Translat...ge_in_a_Plugin, %t only works in functions that act directly on one or more clients, like PrintToChat. For FormatEx you need to use %T and pass the client index after the phrase, like so:

PHP Code:

FormatEx(Messagesizeof(Message), "%T""WarningTest"client); 

But since KickClientEx acts directly on a client, this should also work:

PHP Code:

KickClientEx(client"%t""WarningTest"); 


Ilusion9 02-22-2020 12:59

Re: KickClient Message translation
 
1. Use KickClient instead of KickClientEx.
2. Use %T instead of %t in Format functions for translations.

Example:
PHP Code:

    char Message[64];
    
FormatEx(Messagesizeof(Message), "%T""WarningTest"client);
    
KickClientEx(clientMessage); 


Lord Nightmare 02-22-2020 13:59

Re: KickClient Message translation
 
Yeah i tried to change the code, what are you both suggest and still showing english translate.
OnAdminCheckPost force to show English lang maybe ?

Lord Nightmare 02-23-2020 04:49

Re: KickClient Message translation
 
Ok so the Lang while connect to my server is 0 (getting by getclientlanguage) but after spawn it change to my native lang "pl" so engine force a lang to en????
Can someone tell me, how to change this ?

asherkin 02-23-2020 08:30

Re: KickClient Message translation
 
The client doesn't send language information to the server until a little after connection, and if this is for CS:GO the client doesn't send the language information at all - SourceMod has to request it, so it isn't available until later in the connection process. Unfortunately there isn't anything you can do about this.

Dragokas 02-25-2020 07:18

Re: KickClient Message translation
 
Lord Nightmare, you can create own mapping based on <geoip> (ip -> Country -> language prefix).
Of course, it will be very inaccurate. Still, better than nothing. There is also GeoIpCity.

Also, you can create and auto-populate local database with information about (ip -> language prefix)
when that info come to knowlegde to sm in later connection stage, so next time that info will be available for you.

Lord Nightmare 02-25-2020 12:57

Re: KickClient Message translation
 
Dragokas yeah propably i will use a GeoIP for translations , sometimes you need to go compromise.
Thanks all for help and understatning.
Cheers


All times are GMT -4. The time now is 14:03.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.