AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Multilang Help (https://forums.alliedmods.net/showthread.php?t=112837)

STr!ker 12-21-2009 13:35

Multilang Help
 
2 Attachment(s)
Helo
I want to make a Spam Blocker Multilaguage. I have do it, so i think, but it donīt work.
Maybe somebody can help me, and say, what i have made wrong.

greez STr!ker

Arkshine 12-21-2009 15:05

Re: Multilang Help
 
It's easy to do. See the "Spam_Forbidden_player" keylang.

client_print( id, "%L", id, "Spam_Forbidden_player" );
client_print( 0, "%L", LANG_PLAYER, "Spam_Forbidden_player" );

You need to use %L instead of %s.
Also, like you see you need to specify the player's index as param. Use the player's index when it's passed, otherwise use LANG_PLAYER when you use 0.

STr!ker 12-22-2009 08:18

Re: Multilang Help
 
I have tried it, but i am too sily for this :( . I didnīt understand all, what you mean. So can somebody do it, so I can compare the original and the new, for later Plugins. ;)

greez STrike

Arkshine 12-22-2009 08:25

Re: Multilang Help
 
Others examples :

Code:
client_print (0, print_chat, "* [Spam Blocker] "Spam_public"")
->
Code:
client_print (0, print_chat, "* [Spam Blocker] %L", LANG_PLAYER, "Spam_public")


Code:
client_print (id, print_chat, "* [Spam Blocker] "Spam_warn"")
->
Code:
client_print (id, print_chat, "* [Spam Blocker] %L", id, "Spam_warn")

Code:
log_amx (""Spam_Forbidden_player" ^"%s^" (%s) "Spam_block %s"", szName, szAuthID, text)
->
Code:
log_amx ( "%L", LANG_SERVER, "Spam_Forbidden_player", szName, szAuthID, text)
and you need to modify you .txt :
Code:

Spam_block = ^"%s^" (%s) has been blocked: %s

STr!ker 12-22-2009 19:39

Re: Multilang Help
 
2 Attachment(s)
AT compilare it shows me 7 errors.

Here is what i have maked. I have trieded but i canīt do it :(

fysiks 12-22-2009 22:13

Re: Multilang Help
 
I don't think you followed what Arkshine said.

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <regex>

#define PLUGIN "Spam Blocker"
#define VERSION "3.6"
#define AUTHOR "Teo"
#define MAXIMUM 512
#define PUB_TASK 22210
#define IMMUNITY_FLAG ADMIN_LEVEL_E

new bantimeipmodeszAuthID [32], szName [64], jkuchecknickbanmode
new configfolder [256], check_ipbt_msg [20], log_hidesFloat:is_amxbans
new words [6] [MAXIMUM] [128], patt [6] [16], activetotal [6], mnotify
new const pattern [] = "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)"
new Regex:compiledreterror [2], warningFloat:is_advancedbans
public plugin_init () {
    
register_plugin (PLUGINVERSIONAUTHOR)
    
compiled regex_compile (patternreterrorcharsmax (error))
    
register_dictionary("spamblocker.txt")
    
is_amxbans get_cvar_float ("amxbans_version")
    
is_advancedbans get_cvar_float ("advanced_bans")
    
active register_cvar ("spam_blocker_active""1")
    
ipmode register_cvar ("spam_ip_mode""3")
    
checknick register_cvar ("spam_check_nick""1")
    
bantime register_cvar ("spam_bantime""1440")
    
check_ip register_cvar ("spam_detect_ip""0")
    
log_hides register_cvar ("spam_log_hides""0")
    
warning register_cvar ("spam_warning""1")
    
notify register_cvar ("spam_notify_admins""1")
    
banmode register_cvar ("spam_ban_mode""1")
    
register_cvar("spam_blocker"VERSIONFCVAR_SERVER|FCVAR_EXTDLL|FCVAR_UNLOGGED|FCVAR_SPONLY)
    
register_clcmd ("say""check")
    
register_clcmd ("say_team""check")
    
set_task (200.0"spam_pub"PUB_TASK""0"b")
    
get_configsdir (configfolder255)
    
server_cmd ("exec ^"%s/spam_blocker/config.cfg^""configfolder)
    
patt [1] = "hide.ini"
    
patt [2] = "kick.ini"
    
patt [3] = "ban.ini"
    
patt [4] = "warn.ini"
    
patt [5] = "whitelist.ini"
    
for (16u++) {
        
total [u] = 0
        scan 
(wordspatt [u], configfolderu)
    }
}
public 
scan (output [] [] [], const filename [], const conf [], const flag) {
    static 
path [64]
    
format (path63"%s/spam_blocker/%s"conffilename)
    new 
file_handle fopen (path"rt+")
    new 
file_text [256]
    new 
0
    
while (!feof (file_handle) && MAXIMUM) {
        
fgets (file_handlefile_text255)
        
trim (file_text)
        
copy (output [flag] [k], strlen (file_text), file_text)
        
k++
    }
    
total [flag] = k
    fclose 
(file_handle)
    return 
PLUGIN_CONTINUE
}
stock bool:is_ip (const src []) {
    return 
regex_match_c (srccompiledret) > 0
}
public 
immunity (id) {
    return 
access (idIMMUNITY_FLAG)
}
public 
client_infochanged (id) {
    if (
get_pcvar_num (checknick) == 1) {
        new 
newname [64], oldname [64]
        
get_user_name (idoldname63)
        
get_user_info (id"name"newname63)
        if (!
immunity (id) && !equal (newnameoldname)) {
            
check_nick (id)
        }
    }

public 
client_putinserver (id) {
    if (
get_pcvar_num (checknick) == && !immunity (id)) {
        
check_nick (id)
    }
}
public 
check_nick (id) {
    new 
nick [64]
    
get_user_info (id"name"nick63
    
strtolower (nick)
    return 
check_spam (nickid" in nick"false)
}
public 
check (id) {
    if (
get_pcvar_num (active) == 1) {
        new 
said [128]
        
read_args (said127)
        
strtolower (said)
        
replace (said127"^"", "")
        replace (said, 127, "
^"""")
        return 
check_spam (saidid""true)
    }
    return 
PLUGIN_CONTINUE
}
public 
bool:whitelist (const msg []) {
    new 
bool:ret
    ret 
false
    
for (0total [5]; m++) {
        if (
contain (msgwords [5] [m]) != -1) {
        
ret true    
        
}
    }
    return 
ret
}
public 
check_spam (txt [], idins [], bool:fl) {
    if (!
immunity (id) && get_pcvar_num (check_ip) == && is_ip (txt) && whitelist (txt) == false) {
        
do_punish (idtxtget_pcvar_num (ipmode), insfl)
        return 
PLUGIN_HANDLED
    
}
    for (
15k++) {
        for (
0total [k]; j++) {
            if ((
!= && contain (txtwords [k] [j]) != -&& whitelist (txt) == false) || (== && equal (txtwords [k] [j]))) {
                if (!
immunity (id)) {
                    
do_punish (idtxtkinsfl)
                    return 
PLUGIN_HANDLED
                
}
                if (
== && immunity (id)) {
                    
do_punish (idtxtkinsfl)
                    return 
PLUGIN_HANDLED
                
}
            }
        }
    }
    return 
PLUGIN_CONTINUE
}
public 
do_punish (idtext [], modeins [], bool:fl) {
    new 
bnmd get_pcvar_num (banmode)
    switch (
bnmd) {
        case 
1: {
            
get_user_authid (idszAuthID31)
        }
        case 
2: {
            
get_user_ip (idszAuthID311)
        }
    }
    
get_user_name (idszName63)
    new 
userid get_user_userid (id)
    switch (
mode)
    {
        case 
1:
        {
            if (
get_pcvar_num (log_hides) == && fl == true)
            {
                
client_print(0print_chat"%L"LANG_PLAYER"SPAM_FORBIDDEN_PLAYER"szNameszAuthIDtext)
            }
        }
        case 
2:
        {
            
server_cmd ("amx_kick ^"%s^" ^"AUTOKICKSpam%s^""szNameins)
            if (
get_pcvar_num (notify) == 2)
            {
                
client_print(0print_chat,"%L"LANG_PLAYER"SPAM_KICK"szNametext)
            }
            
log_amx ("%L"LANG_SERVER"SPAM_KICK_MSG"szNameszAuthIDinstext)
        }
        case 
3:
        {
            if (
is_amxbans <= && is_advancedbans <= 0)
            {
//default ban method sucks
                
if (bnmd == 1)
                {
                    
server_cmd ("amx_ban ^"%s^" %d ^"AUTOBANSpam%s^""szAuthIDget_pcvar_num (bantime), ins)
                }
                if (
bnmd == 2)
                {
                    
server_cmd ("amx_banip #%d %d ^"AUTOBANSpam%s^""useridget_pcvar_num (bantime), ins)
                }
            }
            if (
is_amxbans && is_advancedbans <= 0)
            {
//kosher amxbans :)
                
server_cmd ("amx_ban %d %s AUTOBAN: Spam%s"get_pcvar_num (bantime), szAuthIDins)
            }
            if (
is_amxbans <= && is_advancedbans 0)
            {
//advanced bans. well, better that nothing.
                
if (bnmd == 1)
                {
                    
server_cmd ("amx_ban #%d %d ^"AUTOBANSpam%s^""useridget_pcvar_num (bantime), ins)
                }
                if (
bnmd == 2)
                {
                    
server_cmd ("amx_banip #%d %d ^"AUTOBANSpam%s^""useridget_pcvar_num (bantime), ins)
                }
            }
            if (
get_pcvar_numbantime) == 0)
            {
                
bt_msg "permanently"
            
}
            if (
get_pcvar_num (bantime) > 0)
            {
                
format (bt_msg30"(%d min)"get_pcvar_num (bantime))
            }
            if (
get_pcvar_num (notify) == 2)
            {
                
client_print(0print_chat"%L"LANG_PLAYER"SPAM_BAN"szNametext)
            }
            
log_amx "%L"LANG_SERVER"SPAM_BAN_MSG"szNameszAuthIDbt_msginstext)
        }
        case 
4:
        {
            
client_print(idprint_chat"%L"LANG_PLAYER,  "SPAM_BLOCK")
            if (
get_pcvar_num (notify) > 0)
            {
                
client_print(idprint_chat"%L""SPAM_WARN"szNametext)
            }
            
log_amx ("%L"id"SPAM_WARN_MSG"szNameszAuthIDinstext)
        }
    }
    return 
PLUGIN_CONTINUE
}
public 
spam_pub (){
    if (
get_pcvar_num (warning) == 1) {
        
client_print (0print_chat"%L"LANG_PLAYER"SPAM_PUBLIC")
    }



STr!ker 12-23-2009 12:31

Re: Multilang Help
 
Thank you both. I try to make other Plugins Multilang, with the example.
If i have more question i ask here.

Thank you very much.


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

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