Junior Member
|
12-03-2019
, 09:32
Re: Help - Wrong %T syntax?
|
#5
|
Quote:
Originally Posted by Chrissy
What am I looking at?
You pass the name of the translation for %T and that's it. Why have you got so many parameters?
Code:
PrintToChat(client, "\x02ğ \x10 %T", "Helpful Commands");
|
Because I used so many colorcodes everywhere. I thought by seperating it And didn't think commands, phrases and colorcodes
PHP Code:
#include <sourcemod>
#pragma semicolon 1
#pragma newdecls required
public Plugin myinfo =
{
name = "Helpful Commands",
author = "Denaegte",
description = "Server command robot",
version = "1.1",
url = "https://forums.alliedmods.net/member.php?u=250706"
};
public void OnPluginStart()
{
LoadTranslations("helpful.phrases");
RegConsoleCmd("sm_commands", helpful_Commands);
RegConsoleCmd("sm_kommando", helpful_Commands);
RegConsoleCmd("sm_helpful", helpful_Commands);
RegConsoleCmd("sm_hjĉlp", helpful_Commands);
RegConsoleCmd("sm_cheat", helpful_Cheat);
RegConsoleCmd("sm_cheats", helpful_Cheat);
RegConsoleCmd("sm_anticheat", helpful_Cheat);
RegConsoleCmd("sm_website", helpful_Website);
RegConsoleCmd("sm_ladder", helpful_Website);
RegConsoleCmd("sm_report", helpful_Report);
RegConsoleCmd("sm_rapport", helpful_Report);
}
// Commmands
public Action helpful_Commands(int client, int args)
{
PrintToChat(client, "_______________________________________________________________________________________________________________________");
PrintToChat(client, "\x02ğ \x10"."%T", "[JML]" JML."-"."%T", "Helpful Commands", HelpfulCommands.":");
PrintToChat(client, "\x01 1v1"."%T", "Preferences", Preferences.": \x02!guns\x01,"."%T", "manage voice rooms", ManageVoiceRooms.": \x02!vr\x01,""%T", "anti-cheat info", AntiCheatInfo.": \x02!cheat\x01.");
PrintToChat(client, "\x01"."%T", "View your rank", ViewYourRank.": \x02!rank\x01,"."%T", "list of top players", ListOfTopPlayers.": \x02!top\x01,"."%T", "reset your rank", ResetYourRank.": \x02!resetrank\x01.");
PrintToChat(client, "\x01"."%T", "Skin changer", SkinChanger.": \x02!ws\x01,"."%T", "knife changer", KnifeChanger.": \x02!knife\x01,"."%T", "glove changer", GloveChanger": \x02!gloves\x01.");
PrintToChat(client, "\x01"."%T", "Challenge someone", ChallengeSomeone.": \x02!chall\x01,"."%T", "reset your score".": \x02!rs\x01, %T", "report a player"": \x02!report\x01.");
PrintToChat(client, "\x01...\x08"."%T", "you can use", YouCanUse."\x0B '/' \x08"."%T", "instead of", InsteadOf."\x0B '!' \x08"."%T", "to hide your commands", ToHideYourCommands."!");
PrintToChat(client, "_______________________________________________________________________________________________________________________");
}
// Anti-cheat
public Action helpful_Cheat(int client, int args)
{
PrintToChat(client, "\x01ğ \x10"."%T", "[JML]", JML"\x01 - ""%T", "This server is closely being monitored by", ThisServerIsCloselyBeingMonitoredBy"\x04 "."%T", "SMAC", Smac"\x01 and \x04"."%T", "SourceBans", SourceBans."\x01.");
}
// Spillerrapportering
public Action helpful_Report(int client, int args)
{
PrintToChat(client, "\x01ğ \x10[JML] \x0BSpillerrapporteringer indgives her: \x04jml.lissner.dk/forum");
}
// Website
public Action helpful_Website(int client, int args)
{
PrintToChat(client, "\x01ğ \x10"."%T", "[JML]", JML"\x01 - \x08"."%T", " Join the family ", JoinOurFamily" @ "."\x0Bjml.lissner.dk/forum");
PrintToChat(client, "> "."T%", "Where the forum, among other things, open up for options like:", WhereTheForum);
PrintToChat(client, "> "."T%", "Expanded leaderboards, clan/team search, map requests, reports, server polls, ideas, application forms and much more.", LeaderboardsForumsExpansion);
PrintToChat(client, "> \x0A"."T%", "En komplet liste med forandringer kan tjekkes her", CompleteList." -> "."\x04jml.lissner.dk/forum");
}
Quote:
Originally Posted by Ilusion9
%T requires the client as a parameter:
Example:
PHP Code:
PrintToChat(client, "%T", "Helpful Commands", client);
%T is for Format() function to specify the language of the client. PrintToChat already handles that, so you can use %t in it.
Example:
PHP Code:
PrintToChat(client, "%t", "Helpful Commands");
|
So if I add client as parameter at det end of my code, it should work? Or
http://forums.alliedmods.net/attachm...1&d=1575382454
Quote:
Originally Posted by NomisCZ
If you want to use %T, don't forget to client parameter. You can also use %t, but then the translation is not client scoped (client language preference).
https://wiki.alliedmods.net/Translat...eMod_Scripting)
PHP Code:
PrintToChat(client, "[YourPortal] %T", "Language Set Force", client);
translations/my_plugin.phrases.txt
PHP Code:
"Phrases"
{
"Menu Title"
{
"en" "≡ Language settings \nŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ\n"
}
"Language Set Info"
{
"#format" "{1:s}" // File Format - https://wiki.alliedmods.net/Translations_(SourceMod_Scripting)
"en" " Your language has been automatically set to {1}. To change your language type !lang / !language"
}
"Language Set Force"
{
"en" "You can't change language on this server."
}
"en"
{
"en" "English"
}
"cze"
{
"en" "Czech"
}
}
my_plugin.sp
PHP Code:
#include <sourcemod>
#define PLUGIN_PREFIX "[MyPlugin]"
#pragma semicolon 1
#pragma newdecls required
char g_sLanguagePref[MAXPLAYERS+1][4];
public Plugin myinfo = {
...
}
public void OnPluginStart()
{
LoadTranslations("my_plugin.phrases");
}
public void MyFunction(int client)
{
// Basic example - client language preference
// Result: [MyPlugin] You can't change language on this server.
PrintToChat(client, "%s %T", PLUGIN_PREFIX, "Language Set Force", client);
// Or "auto" language preference
// Sometimes it can cause problems with incorrect translation according to client preference (multicolors include).
PrintToChat(client, "%s %t", PLUGIN_PREFIX, "Language Set Force");
// Format example
// Dynamic translation format depending on the value of the variable
char translationString[32];
// g_sLanguagePref[client] is "cze" or "en"
// Result: "Czech" or "English"
Format(translationString, sizeof(translationString), "%T", g_sLanguagePref[client], client);
// PrintToChat with format {1:s}
// Phrase also contains one parameter in itself "#format" "{1:s}", so next parameter after client is string - translationString
// Result: "[MyPlugin] Your language has been automatically set to Czech/English. To change your language type !lang / !language"
PrintToChat(client, "%s %T", PLUGIN_PREFIX, "Language Set Info", client, translationString);
// Or "auto" language preference
PrintToChat(client, "%s %t", PLUGIN_PREFIX, "Language Set Info", translationString);
}
|
|
|