Raised This Month: $18 Target: $400
 4% 

Solved KickClient Message translation


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Lord Nightmare
Junior Member
Join Date: Feb 2014
Location: Poland
Old 02-22-2020 , 12:19   KickClient Message translation
Reply With Quote #1

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);


Last edited by Lord Nightmare; 02-25-2020 at 12:57.
Lord Nightmare is offline
DJ Tsunami
DJ Post Spammer
Join Date: Feb 2008
Old 02-22-2020 , 12:58   Re: KickClient Message translation
Reply With Quote #2

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"); 
__________________
DJ Tsunami is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 02-22-2020 , 12:59   Re: KickClient Message translation
Reply With Quote #3

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); 
__________________
Ilusion9 is offline
Lord Nightmare
Junior Member
Join Date: Feb 2014
Location: Poland
Old 02-22-2020 , 13:59   Re: KickClient Message translation
Reply With Quote #4

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 is offline
Lord Nightmare
Junior Member
Join Date: Feb 2014
Location: Poland
Old 02-23-2020 , 04:49   Re: KickClient Message translation
Reply With Quote #5

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 ?
Lord Nightmare is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 02-23-2020 , 08:30   Re: KickClient Message translation
Reply With Quote #6

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.
__________________
asherkin is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine
Old 02-25-2020 , 07:18   Re: KickClient Message translation
Reply With Quote #7

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.
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D1 fun (Bloody Witch)
[My plugins] [My tools] [GitHub] [Articles]
Dragokas is offline
Lord Nightmare
Junior Member
Join Date: Feb 2014
Location: Poland
Old 02-25-2020 , 12:57   Re: KickClient Message translation
Reply With Quote #8

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

Last edited by Lord Nightmare; 02-25-2020 at 12:58.
Lord Nightmare is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


Powered by vBulletin®
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Theme made by Freecode