Descriere: Traduceti cuvintele scrise in chat din comenzile "say" si "say_team".
Puteți configura pluginul printr-un fișier de configurare (amx / config / words_list.txt).
Atentie, puteți traduce numai cuvinte, nu si propizitii.
Acest plugin poate fi foarte util pe serverele dvs., dacă mulți dintre jucătorii dvs. nu vorbesc aceeași limbă.
Download: Link
Autor: KRoT@L
Sursa (Link-ul oficial): amxmod.net
AmxModX/AdminMod: amxmodx
CVar-uri: -
Module necesare: -
Comenzi: -
Instalare: -
Imagini: -
.Sma:
Cod: Selectaţi tot
#include <translator>
#include <amxmod>
#include <amxmisc>
#define MAX_WORD_NUM 128 // modify here the maximum number of words
#define MAX_WORD_SIZE 32
#define MAX_MESSAGE_SIZE 192
#define MAX_USERNAME_SIZE 32
#define MAX_USERTEAM_SIZE 20
#define MAX_STEAMID_SIZE 24
#define TEAMNAME_CT "Counter-Terrorist"
#define TEAMNAME_TERRORIST "Terrorist"
#define TEAMNAME_SPEC "Spectator"
new const g_wordfile[] = "$configdir/words_list.txt"
new const g_words[MAX_WORD_NUM][2][MAX_WORD_SIZE]
new g_wnum
new gmsgSayText
new g_cvar_amx_translator
public plugin_init() {
load_translations("translator")
register_plugin(_T("Translator"), "1.1", "KRoT@L")
register_clcmd("say", "SayHandler")
register_clcmd("say_team", "SayTeamHandler")
g_cvar_amx_translator = register_cvar("amx_translator", "1")
gmsgSayText = get_user_msgid("SayText")
read_wordfile()
}
read_wordfile() {
new filename[64], text[(MAX_WORD_SIZE*2)+1], line, len
build_path(filename, charsmax(filename), g_wordfile)
if(!file_exists(filename)) {
log_amx(_T("Translator: Unable to load the words to translate, the file ^"%s^" doesn't exist."), filename)
return
}
while(g_wnum < MAX_WORD_NUM && read_file(filename, line++, text, charsmax(text), len)) {
if(!len || text[0] == ';' || text[0] == '/' || text[0] == '#') continue
if(parse(text, g_words[g_wnum][0], MAX_WORD_SIZE - 1, g_words[g_wnum][1], MAX_WORD_SIZE - 1) == 2)
g_wnum++
}
log_amx(_T("Translator: Loaded %d word%s to translate."), g_wnum, (g_wnum > 1) ? "s" : "")
if(is_module_running("fakemeta")) server_cmd("quit")
}
public SayHandler(id) {
if(g_wnum == 0 || get_cvarptr_num(g_cvar_amx_translator) <= 0) {
return PLUGIN_CONTINUE
}
static msg[MAX_MESSAGE_SIZE]
read_args(msg, MAX_MESSAGE_SIZE - 1)
remove_quotes(msg)
if(!msg[0]) return PLUGIN_CONTINUE
new len, bool:found = false, numfound = 0, j
static word[MAX_MESSAGE_SIZE]
word[0] = 0
parse(msg, word, MAX_MESSAGE_SIZE-1)
while(word[0] && len < MAX_MESSAGE_SIZE) {
//console_print(id, "Reading argument = %s", word)
for(j = 0; j < g_wnum; j++) {
if(equali(word, g_words[j][0])) {
replace(msg[len], MAX_MESSAGE_SIZE-1-len, word, g_words[j][1])
found = true
numfound++
break
}
}
if(found) {
len += strlen(g_words[j][1]) + 1
found = false
}
else {
len += strlen(word) + 1
}
while(msg[len] == ' ' || msg[len] == '"') {
len++
}
word[0] = '^0'
parse(msg[len], word, MAX_MESSAGE_SIZE-1)
}
if(numfound) {
SendMessage(id, msg, false)
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
public SayTeamHandler(id) {
if(g_wnum == 0 || get_cvarptr_num(g_cvar_amx_translator) <= 0) {
return PLUGIN_CONTINUE
}
static msg[MAX_MESSAGE_SIZE]
read_args(msg, MAX_MESSAGE_SIZE - 1)
remove_quotes(msg)
if(!msg[0]) return PLUGIN_CONTINUE
new len, found = false, numfound = 0, j
static word[MAX_MESSAGE_SIZE]
word[0] = 0
parse(msg, word, MAX_MESSAGE_SIZE-1)
while(word[0] && len < MAX_MESSAGE_SIZE) {
//console_print(id, "Reading argument = %s", word)
for(j = 0; j < g_wnum; j++) {
if(equali(word,g_words[j][0])) {
replace(msg[len], MAX_MESSAGE_SIZE-1-len, word, g_words[j][1])
found = true
numfound++
break
}
}
if(found) {
len += strlen(g_words[j][1]) + 1
found = false
}
else {
len += strlen(word) + 1
}
while(msg[len] == ' ' || msg[len] == '"') {
len++
}
word[0] = '^0'
parse(msg[len], word, MAX_MESSAGE_SIZE-1)
}
if(numfound) {
SendMessage(id, msg, true)
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
SendMessage(const iPlayerID, const sMessage[], const bToTeam = false) { // par Van der Cal
new iArrSendToList[32], nPlayers = 0
static sUserName[MAX_USERNAME_SIZE], sUserTeam[2], sUserSteamID[MAX_STEAMID_SIZE]
static sRealMessage[MAX_MESSAGE_SIZE], sUserTeamInChat[MAX_USERTEAM_SIZE]
get_user_name(iPlayerID, sUserName, MAX_USERNAME_SIZE - 1)
new iTeam = get_user_team(iPlayerID)
get_user_authid(iPlayerID, sUserSteamID, MAX_STEAMID_SIZE - 1)
// Note that if you run other mods than cs you might wanna change this part
switch(iTeam) {
case 1: copy(sUserTeamInChat, MAX_USERTEAM_SIZE - 1, TEAMNAME_TERRORIST)
case 2: copy(sUserTeamInChat, MAX_USERTEAM_SIZE - 1, TEAMNAME_CT)
default: copy(sUserTeamInChat, MAX_USERTEAM_SIZE - 1, TEAMNAME_SPEC)
}
num_to_str(iTeam, sUserTeam, charsmax(sUserTeam))
// if user is spectating, then we have to give them a special treat sadly
if ( sUserTeamInChat[0] == 'S' ) {
if ( bToTeam ) {
get_players(iArrSendToList, nPlayers, "bce", sUserTeam) // Get Dead, no bots, from given team
formatex(sRealMessage, MAX_MESSAGE_SIZE - 1, "^1(%s) ^3%s ^1: %s", sUserTeamInChat, sUserName, sMessage)
log_message("^"%s<%d><%s><%s>^" say_team ^"%s^"", sUserName, iPlayerID, sUserSteamID, sUserTeamInChat, sMessage) // say_team logging
}
else {
get_players(iArrSendToList, nPlayers, "bc") // Get Dead, no bots
formatex(sRealMessage, MAX_MESSAGE_SIZE - 1, "^1*SPEC* ^3%s ^1: %s", sUserName, sMessage)
log_message("^"%s<%d><%s><%s>^" say ^"%s^"", sUserName, iPlayerID, sUserSteamID, sUserTeamInChat, sMessage) // say_team logging
}
}
else if ( bToTeam ) {
if ( is_user_alive(iPlayerID) ) {
get_players(iArrSendToList, nPlayers, "ace", sUserTeam) // Get Alive, no bots, from given team
formatex(sRealMessage, MAX_MESSAGE_SIZE - 1, "^1(%s) ^3%s ^1: %s", sUserTeamInChat, sUserName, sMessage)
log_message("^"%s<%d><%s><%s>^" say_team ^"%s^"", sUserName, iPlayerID, sUserSteamID, sUserTeamInChat, sMessage) // say_team logging
}
else {
get_players(iArrSendToList, nPlayers, "bce", sUserTeam) // Get Dead, no bots, from given team
formatex(sRealMessage, MAX_MESSAGE_SIZE - 1, "^1*DEAD*(%s) ^3%s ^1: %s", sUserTeamInChat, sUserName, sMessage)
log_message("^"%s<%d><%s><%s>^" say_team ^"%s^" (dead)", sUserName, iPlayerID, sUserSteamID, sUserTeamInChat, sMessage) // say_team logging
}
}
else {
if ( is_user_alive(iPlayerID) ) {
get_players(iArrSendToList, nPlayers, "ac") // Get Alive, no bots
formatex(sRealMessage, MAX_MESSAGE_SIZE - 1, "^3%s ^1: %s", sUserName, sMessage)
log_message("^"%s<%d><%s><%s>^" say ^"%s^"", sUserName, iPlayerID, sUserSteamID, sUserTeamInChat, sMessage) // say logging
}
else {
get_players(iArrSendToList, nPlayers, "bc") // Get Dead, no bots
formatex(sRealMessage, MAX_MESSAGE_SIZE - 1, "^1*DEAD* ^3%s ^1: %s", sUserName, sMessage)
log_message("^"%s<%d><%s><%s>^" say ^"%s^" (dead)", sUserName, iPlayerID, sUserSteamID, sUserTeamInChat, sMessage) // say logging
}
}
// For every player in the sendto list
for (new iPlayer = 0; iPlayer < nPlayers; iPlayer++) {
message_begin(MSG_ONE_UNRELIABLE, gmsgSayText, {0,0,0}, iArrSendToList[iPlayer])
write_byte(iPlayerID)
write_string(sRealMessage)
message_end()
}
return PLUGIN_HANDLED;
}

