Здравствуй, читатель. В своей новости я расскажу, как перевести свой плагин, но не просто перевести, а сделать так, чтобы он поддерживал словарь. Ну что? Приступим.
I. Что нам понадобится:
1. 2 прямые руки.
2. 1 адекватно мыслящий мозг
3. Горсть терпения
4. Щепотка усидчивости.
5. Программа AkelPad ++
6. По желанию можете включить музыку, чтобы было не скучно.
II.
Выберим плагин, который будем переводить. Я взял плагин resetscore.
И так.
Открываем наш плагин, а точнее его исходник [.sma]. Ищем в нем секцию public plugin_init()
После чего добавляем строку.
register_dictionary(“resetscore.txt”)
Данная строчка отвечает за поддержку словаря вашего плагина.
Где *.txt название текстового документа с переводом, который будет храниться в amxmodx/data/lang/.
И так, что у нас должно было получиться:
До изменения
public plugin_init()
{
register_plugin(“Reset Score”, “1.0”, “Silenttt”)
//You may type /resetscore or /restartscore
register_clcmd(“say /resetscore”, “reset_score”)
register_clcmd(“say /restartscore”, “reset_score”)
//This command by default will be set at 0
//Change it to 1 in server.cfg if you want
//A message to be shown to advertise this.
pcvar_Advertise = register_cvar(“sv_rsadvertise”, “0”)
//This command by default is also 0
//Change it to 1 in server.cfg if you want
//It to show who reset their scores when they do it
pcvar_Display = register_cvar(“sv_rsdisplay”, “0”)
if(get_cvar_num(“sv_rsadvertise”) == 1)
{
set_task(adtime, “advertise”, _, _, _, “b”)
}
}
После изменения
public plugin_init()
{
register_plugin(“Reset Score”, “1.0”, “Silenttt”)
//You may type /resetscore or /restartscore
register_clcmd(“say /resetscore”, “reset_score”)
register_clcmd(“say /restartscore”, “reset_score”)
register_dictionary(“resetscore.txt”)
//This command by default will be set at 0
//Change it to 1 in server.cfg if you want
//A message to be shown to advertise this.
pcvar_Advertise = register_cvar(“sv_rsadvertise”, “0”)
//This command by default is also 0
//Change it to 1 in server.cfg if you want
//It to show who reset their scores when they do it
pcvar_Display = register_cvar(“sv_rsdisplay”, “0”)
if(get_cvar_num(“sv_rsadvertise”) == 1)
{
set_task(adtime, “advertise”, _, _, _, “b”)
}
}
Далее ищем строки с client_print, show_hudmessage и тому подобному, содержащему текстовые сообщения:
1)
client_print(0, print_chat, "%s has just reset his score", name)
2)
client_print(id, print_chat, "You have just reset your score")
3)
client_print(id, print_chat, "By typing /resetscore at any time during the game,
you can reset your deaths and kills back to 0 (rather than reconnecting)")
Вместо текстовых сообщений
1) has just reset his score
2) You have just reset your score
3) By typing /resetscore at any time during the game, you can reset your deaths and kills back to 0 (rather than reconnecting)
Пишем:
%RS
( Ну, или любой другой, например: “%L” “%SC” и т.д.)
После чего должно быть так:
1)
client_print(0, print_chat, "%s %RS", name)
2)
client_print(id, print_chat, "%RS")
3)
client_print(id, print_chat, "%RS")
Далее, изменяем следующим образом:
1)
client_print(0, print_chat, "%s %RS", name, LANG_PLAYER, "PUBLIC_RESET")
2)
client_print(id, print_chat, "%RS", LANG_PLAYER, "PRIVATE_RESET")
3)
client_print(id, print_chat, "%RS", LANG_PLAYER, "PUBLIC_MESSAGE")
Теперь сообщения будут выводиться из текстового документа data/lang/resetscore.txt
Далее:
PUBLIC_RESET, PRIVATE_RESET и PUBLIC_MESSAGE
Прописываем в resetscore.txt, пример:
[ru]
PUBLIC_RESET = Обнулил очки
PRIVATE_RESET = Вы обнулили свои очки
PUBLIC_MESSAGE = Команда /resetscore обнуляет ваш счёт фрагов и смертей
без использования команды "reconnect" или "retry"
[en]
PUBLIC_RESET = Resetscore
PRIVATE_RESET = You reset your score
PUBLIC_MESSAGE = By typing /resetscore at any time during the game,
you can reset your deaths and kills back to 0 (rather than reconnecting)
Если имееться русский перевод, не забываем сохранять текстовый документ в формате UTF-8 без BOM (можно с помощью AkelPad++)
Ссылки:
AkelPad ++ Скачано: 270
ResetScore
Смотрите, читайте, пользуйтесь и отписывайтесь