AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   can someone help me...? (https://forums.alliedmods.net/showthread.php?t=192564)

timothy0711 08-11-2012 15:23

can someone help me...?
 
Can someone can help me change it to amxx ???
It is a chatting system
I have no idea why i cannot change it to amxx.

There are one error called
error 010: invalid function or declaration
in line <1>.

Maybe it cannot change to amxx because i have added some chinese words?



Code:

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <nvault>
#define MAX_WORDS 192

new const PLUGIN[] = "Hook system final"
new const VERSION[] = "3.5"
new const AUTHOR[] = "WS.Chu:)"
static const VAULTNAME[] = "signature"
new const SYS_PLUGIN_NAME[] = "\y插件名稱^n\r"
new const SYS_PLUGIN_AUTHOR[] = "\y插件作者^n\r"
new const SYS_PLUGIN_VERSION[] = "\y插件版本^n\r"
new const SYS_PLUGIN_DB[] = "\y資料庫^n\r"

new iMessages[256];
new iUserName[32], iTag[24], iPlayerTag[24] = "[普通玩家]";
new iUserAlive, iUserTeam;
new tUserTeam[16], tUserAlive[10];
new gSayText, gMaxplayers;
new szVault, szName[33][35];
new cmdType;
new iHideTag;
new CHARS_MIN = 6, CHARS_MAX = 26;
new SwearsNames[MAX_WORDS][32];
new gSwearsNum;

public plugin_init()
{
        register_plugin(PLUGIN, VERSION, AUTHOR);
        register_clcmd("say", "cmdHookSay");
        register_clcmd("say_team", "cmdHookSayTeam");
       
        cmdType = register_cvar("amx_hook_sysf_type", "0");
       
        register_cvar(SYS_PLUGIN_NAME, PLUGIN, FCVAR_SERVER|FCVAR_SPONLY);
        register_cvar(SYS_PLUGIN_AUTHOR, AUTHOR, FCVAR_SERVER|FCVAR_SPONLY);
        register_cvar(SYS_PLUGIN_VERSION, VERSION, FCVAR_SERVER|FCVAR_SPONLY);
        register_cvar(SYS_PLUGIN_DB, VAULTNAME, FCVAR_SERVER|FCVAR_SPONLY);
       
        szVault = nvault_open(VAULTNAME)
       
        gSayText = get_user_msgid("SayText");
        gMaxplayers = get_maxplayers();
       
        if(get_pcvar_num(cmdType) >= 3)
        {
                server_cmd("amxx pause hook_sys.amxx");
                server_print("[ERROR] Cvar ^"hook_sys_type^" effective value are ^"0^" and ^"1^".");
                server_print("[ERROR] Plugin info: %s %s %s, auto pause plugin.", PLUGIN, VERSION, AUTHOR);
        }
       
        readList()
}

readList()
{
    // file to read words from
        new szConfigdir[64];
        new szFileName[64];
        get_configsdir(szConfigdir, 63);
        formatex(szFileName, 63, "%s/swear/swearwords.ini", szConfigdir);

        if(!file_exists(szFileName))
        {
                server_print("[ERROR] Swear Filter: file %s not found.", szFileName);
                return;
        }
        new iLen
        while(gSwearsNum < MAX_WORDS && read_file(szFileName, gSwearsNum ,SwearsNames[gSwearsNum][1], 30, iLen))
        {
                if(SwearsNames[gSwearsNum][0] == ';') continue;
                SwearsNames[gSwearsNum][0] = iLen;
                ++gSwearsNum;
        }
        server_print("[AMXX] Swear Filter: loaded %d words", gSwearsNum);
}

public client_authorized(id)
{
    get_user_name(id , szName[id] , charsmax(szName[]));
}

public plugin_end()
{
    nvault_close(szVault);
}

public cmdHookSay(id)
{
        read_args(iMessages, 255);
        remove_quotes(iMessages);
       
        get_user_name(id, iUserName, 31);
       
        if(!is_valid_msg(iMessages))
                return PLUGIN_HANDLED;
       
        CheckSwears(id);
       
        if(get_user_flags(id) & ADMIN_LEVEL_A)
                iTag = "[場主]";
        else if(get_user_flags(id) & ADMIN_LEVEL_B)
                iTag = "[高級管理員]";
        else if(get_user_flags(id) & ADMIN_LEVEL_C)
                iTag = "[管理員]";
        else if(get_user_flags(id) & ADMIN_LEVEL_D)
                iTag = "[高級團員]";
        else if(get_user_flags(id) & ADMIN_LEVEL_E)
                iTag = "[團員]";
        else
                iTag = iPlayerTag;
       
        iUserAlive = is_user_alive(id);
       
        new szKey[32], szSingature[26], iSignature[26];
       
        formatex(szKey, 31, "%s-Signature", szName[id]);
        formatex(szSingature, charsmax(szSingature), "%s", iMessages[5]);
       
        if(iMessages[0] == '/' && iMessages[1] == 'm' && iMessages[2] == 's' && iMessages[3] == 'g' && iMessages[4] == ' ')
        {
                new iMsg = strlen(iMessages);
               
                if(iMsg < CHARS_MIN)
                {
                        client_color(id, id, "[提示] 您所鍵入的個性簽名太短了。(下限: %d 個英文字或中文字)", CHARS_MIN - 5);
                }
                else if(iMsg > CHARS_MAX)
                {
                        client_color(id, id, "[提示] 您所鍵入的個性簽名太長了。(上限: %d 個英文字或 %d 個中文字)", CHARS_MAX - 5, (CHARS_MAX - 5) / 3);
                }
                else
                {
                        client_color(id, id, "[提示] 您現在的個性簽名:^"%s^"。", iMessages[5]);
                        nvault_set(szVault, szKey, szSingature);
                }
                return PLUGIN_HANDLED;
        }
       
        if(equal(iMessages, "/delmsg"))
        {
                formatex(szSingature, charsmax(szSingature), "沒有稱號");
                nvault_set(szVault, szKey, szSingature);
                       
                client_color(id, id, "[提示] 您現在的個性簽名已經刪除。");
               
                return PLUGIN_HANDLED;
        }
       
        formatex(szKey, 31, "%s-Signature", szName[id]);
       
        if(nvault_get(szVault, szKey, szSingature, charsmax(szSingature)))
                formatex(iSignature, charsmax(iSignature), "%s", szSingature);
        else
                formatex(iSignature, charsmax(iSignature), "沒有稱號");
       
        if(get_pcvar_num(cmdType) == 0)
        {
                client_color(0, id, "^x01%s^x04[^x01%s^x04] ^x03%s ^x01: %s", is_UserAlive(), iSignature, iUserName, iMessages);
                client_print(0, print_console, "%s[%s] %s : %s", is_UserAlive(), iSignature, iUserName, iMessages);
        }
        else if(get_pcvar_num(cmdType) == 1)
        {        if(is_user_admin(id))
                {
                        if(equal(iMessages, "/hide"))
                        {
                                iHideTag = 1;
                                client_color(id, id, "[提示] 您的管理員標籤將由 %s 變成 %s。", iTag, iPlayerTag);
                                return PLUGIN_HANDLED;
                        }
                        if(equal(iMessages, "/show"))
                        {
                                iHideTag = 0;
                                client_color(id, id, "[提示] 您的管理員標籤將由 %s 還原成 %s。", iPlayerTag, iTag);
                                return PLUGIN_HANDLED;
                        }
                }
                else if(!is_user_admin(id))
                {
                        iHideTag = 0;
                }
                if(iHideTag == 1)
                {
                        client_color(0, id, "^x01%s^x04%s ^x04[^x01%s^x04] ^x03%s ^x01: %s", is_UserAlive(), iPlayerTag, iSignature, iUserName, iMessages);
                        client_print(0, print_console, "%s%s [%s] %s : %s", is_UserAlive(), iPlayerTag, iSignature, iUserName, iMessages);
                }
                else if(iHideTag == 0)
                {
                        client_color(0, id, "^x01%s^x04%s ^x04[^x01%s^x04] ^x03%s ^x01: %s", is_UserAlive(), iTag, iSignature, iUserName, iMessages);
                        client_print(0, print_console, "%s%s [%s] %s : %s", is_UserAlive(), iTag, iSignature, iUserName, iMessages);
                }
        }
        return PLUGIN_HANDLED;
}

public cmdHookSayTeam(id)
{
        read_args(iMessages, 255);
        remove_quotes(iMessages);       
       
        get_user_name(id, iUserName, 31);
       
        if(!is_valid_msg(iMessages))
                return PLUGIN_HANDLED;
               
        CheckSwears(id);
               
        iUserAlive = is_user_alive(id);
        iUserTeam = get_user_team(id);
       
        if(iMessages[0] != '@')
        {
                static player;
               
                for(player = 1; player <= gMaxplayers; player++)
                {
                        if(get_user_team(player) == iUserTeam)
                                client_color(player, id, "^x01%s^x03%s %s ^x01: %s", is_UserAlive(), i_UserTeam(), iUserName, iMessages);
                }
        }
        else
        {
                if(get_user_flags(id) & ADMIN_ADMIN)
                        iTag = "(ADMIN)"
                else
                        iTag = "(PLAYER)"
               
                new iPlayers[32], iNum;
                get_players(iPlayers, iNum, "ch");
               
//                for(new i = 0; i < iNum; i++)
//                {
//                        if(get_user_flags(iPlayers[i]) & ADMIN_CHAT)
//                        {
//                                client_color(iPlayers[i], id, "^x04%s ^x03%s ^x01: %s", iTag, iUserName, iMessages[1]);
//                        }
//                        else if(!is_user_admin(iPlayers[i]))
//                        {
//                                client_color(iPlayers[i], id, "^x04%s ^x03%s ^x01: %s", iTag, iUserName, iMessages[1]);
//                        }
//                }
                for(new i = 0; i < iNum; i++)
                {
                        if(get_user_flags(iPlayers[i]) & ADMIN_CHAT && id != iPlayers[i])
                        {
                                client_color(iPlayers[i], id, "^x04%s ^x03%s ^x01: %s", iTag, iUserName, iMessages[1]);
                        }
                }
                client_color(id, id, "^x04%s ^x03%s ^x01: %s", iTag, iUserName, iMessages[1]); 
        }
        return PLUGIN_HANDLED;
}

public CheckSwears(id)
{
        new pos, i = 0;
       
        while (i < gSwearsNum)
        {
                if((pos = containi(iMessages, SwearsNames[i][1])) != -1 )
                {
                        new len = SwearsNames[i][0]
                        while(len--)
                        iMessages[pos++] = '*';
                        continue;
                }
                ++i
        }
        return PLUGIN_HANDLED;
}

bool:is_valid_msg(const iMessages[])
{
        if(iMessages[0] == '%' || !strlen(iMessages) || equal(iMessages, "") || equal(iMessages, " "))
        {
                return false;
        }
        return true;
}

public i_UserTeam()
{
        switch(iUserTeam)
        {
                case 0: copy(tUserTeam, sizeof(tUserTeam) - 1,"( SPEC )");
                case 1: copy(tUserTeam, sizeof(tUserTeam) - 1,"( TS )");
                case 2: copy(tUserTeam, sizeof(tUserTeam) - 1,"( CT )");
                case 3: copy(tUserTeam, sizeof(tUserTeam) - 1,"( SPEC )");
        }
        return tUserTeam;
}

public is_UserAlive()
{
        if(!iUserAlive && 0 < iUserTeam < 3)
                copy(tUserAlive, sizeof(tUserAlive) - 1,"*陣亡* ");
        else
                copy(tUserAlive, sizeof(tUserAlive) - 1,"");
        return tUserAlive;
}

stock client_color(index, color, const msg[], any:...)
{
        static szMessage[192]
        szMessage[0] = 0x04
        vformat(szMessage[1], charsmax(szMessage)-1, msg, 4)
       
        static iSayText
        if (iSayText || (iSayText = gSayText))
        {
                message_begin(index ? MSG_ONE_UNRELIABLE : MSG_BROADCAST, iSayText, _, index)
                {
                        write_byte(color)
                        write_string(szMessage)
                }
                message_end()
        }
}


Torge 08-11-2012 16:46

Re: can someone help me...?
 
I can compile it without any problems...

quilhos 08-11-2012 23:20

Re: can someone help me...?
 
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <nvault>

#define MAX_WORDS 192

new const PLUGIN[] = "Hook system final"
new const VERSION[] = "3.5"
new const AUTHOR[] = "WS.Chu:)"
static const VAULTNAME[] = "signature"
new const SYS_PLUGIN_NAME[] = "\y????^n\r"
new const SYS_PLUGIN_AUTHOR[] = "\y????^n\r"
new const SYS_PLUGIN_VERSION[] = "\y????^n\r"
new const SYS_PLUGIN_DB[] = "\y???^n\r"

new iMessages[256];
new 
iUserName[32], iTag[24], iPlayerTag[24] = "[????]";
new 
iUserAliveiUserTeam;
new 
tUserTeam[16], tUserAlive[10];
new 
gSayTextgMaxplayers;
new 
szVaultszName[33][35];
new 
cmdType;
new 
iHideTag;
new 
CHARS_MIN 6CHARS_MAX 26;
new 
SwearsNames[MAX_WORDS][32];
new 
gSwearsNum;

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
register_clcmd("say""cmdHookSay");
    
register_clcmd("say_team""cmdHookSayTeam");
    
    
cmdType register_cvar("amx_hook_sysf_type""0");
    
    
register_cvar(SYS_PLUGIN_NAMEPLUGINFCVAR_SERVER|FCVAR_SPONLY);
    
register_cvar(SYS_PLUGIN_AUTHORAUTHORFCVAR_SERVER|FCVAR_SPONLY);
    
register_cvar(SYS_PLUGIN_VERSIONVERSIONFCVAR_SERVER|FCVAR_SPONLY);
    
register_cvar(SYS_PLUGIN_DBVAULTNAMEFCVAR_SERVER|FCVAR_SPONLY);
    
    
szVault nvault_open(VAULTNAME
    
    
gSayText get_user_msgid("SayText");
    
gMaxplayers get_maxplayers();
    
    if(
get_pcvar_num(cmdType) >= 3)
    {
        
server_cmd("amxx pause hook_sys.amxx");
        
server_print("[ERROR] Cvar ^"hook_sys_type^" effective value are ^"0^" and ^"1^".");
        
server_print("[ERROR] Plugin info: %s %s %s, auto pause plugin."PLUGINVERSIONAUTHOR);
    }
    
    
readList()
}

readList() 

    
// file to read words from 
    
new szConfigdir[64];
    new 
szFileName[64];
    
get_configsdir(szConfigdir63);
    
formatex(szFileName63"%s/swear/swearwords.ini"szConfigdir);

    if(!
file_exists(szFileName))
    {
        
server_print("[ERROR] Swear Filter: file %s not found."szFileName);
        return;
    }
    new 
iLen 
    
while(gSwearsNum MAX_WORDS && read_file(szFileNamegSwearsNum ,SwearsNames[gSwearsNum][1], 30iLen))
    { 
        if(
SwearsNames[gSwearsNum][0] == ';') continue;
        
SwearsNames[gSwearsNum][0] = iLen;
        ++
gSwearsNum;
    }
    
server_print("[AMXX] Swear Filter: loaded %d words"gSwearsNum);


public 
client_authorized(id)
{
    
get_user_name(id szName[id] , charsmax(szName[]));
}

public 
plugin_end()
{
    
nvault_close(szVault);
}

public 
cmdHookSay(id)
{
    
read_args(iMessages255);
    
remove_quotes(iMessages);
    
    
get_user_name(idiUserName31);
    
    if(!
is_valid_msg(iMessages))
        return 
PLUGIN_HANDLED;
    
    
CheckSwears(id);
    
    if(
get_user_flags(id) & ADMIN_LEVEL_A)
        
iTag "[??]";
    else if(
get_user_flags(id) & ADMIN_LEVEL_B)
        
iTag "[?????]";
    else if(
get_user_flags(id) & ADMIN_LEVEL_C)
        
iTag "[???]";
    else if(
get_user_flags(id) & ADMIN_LEVEL_D)
        
iTag "[????]";
    else if(
get_user_flags(id) & ADMIN_LEVEL_E)
        
iTag "[??]";
    else
        
iTag iPlayerTag;
    
    
iUserAlive is_user_alive(id);
    
    new 
szKey[32], szSingature[26], iSignature[26];
    
    
formatex(szKey31"%s-Signature"szName[id]);
    
formatex(szSingaturecharsmax(szSingature), "%s"iMessages[5]);
    
    if(
iMessages[0] == '/' && iMessages[1] == 'm' && iMessages[2] == 's' && iMessages[3] == 'g' && iMessages[4] == ' ')
    {
        new 
iMsg strlen(iMessages);
        
        if(
iMsg CHARS_MIN)
        {
            
client_color(idid"[??] ?????????????(??: %d ????????)"CHARS_MIN 5);
        }
        else if(
iMsg CHARS_MAX)
        {
            
client_color(idid"[??] ?????????????(??: %d ????? %d ????)"CHARS_MAX 5, (CHARS_MAX 5) / 3);
        }
        else
        {
            
client_color(idid"[??] ????????:^"%s^"?"iMessages[5]);
            
nvault_set(szVaultszKeyszSingature);
        }
        return 
PLUGIN_HANDLED;
    }
    
    if(
equal(iMessages"/delmsg"))
    {
        
formatex(szSingaturecharsmax(szSingature), "????");
        
nvault_set(szVaultszKeyszSingature);
            
        
client_color(idid"[??] ?????????????");
        
        return 
PLUGIN_HANDLED;
    }
    
    
formatex(szKey31"%s-Signature"szName[id]);
    
    if(
nvault_get(szVaultszKeyszSingaturecharsmax(szSingature)))
        
formatex(iSignaturecharsmax(iSignature), "%s"szSingature);
    else
        
formatex(iSignaturecharsmax(iSignature), "????");
    
    if(
get_pcvar_num(cmdType) == 0)
    {
        
client_color(0id"^x01%s^x04[^x01%s^x04] ^x03%s ^x01: %s"is_UserAlive(), iSignatureiUserNameiMessages);
        
client_print(0print_console"%s[%s] %s : %s"is_UserAlive(), iSignatureiUserNameiMessages);
    }
    else if(
get_pcvar_num(cmdType) == 1)
    {    if(
is_user_admin(id))
        {
            if(
equal(iMessages"/hide"))
            {
                
iHideTag 1;
                
client_color(idid"[??] ????????? %s ?? %s?"iTagiPlayerTag);
                return 
PLUGIN_HANDLED;
            }
            if(
equal(iMessages"/show"))
            {
                
iHideTag 0;
                
client_color(idid"[??] ????????? %s ??? %s?"iPlayerTagiTag);
                return 
PLUGIN_HANDLED;
            }
        }
        else if(!
is_user_admin(id))
        {
            
iHideTag 0;
        }
        if(
iHideTag == 1)
        {
            
client_color(0id"^x01%s^x04%s ^x04[^x01%s^x04] ^x03%s ^x01: %s"is_UserAlive(), iPlayerTagiSignatureiUserNameiMessages);
            
client_print(0print_console"%s%s [%s] %s : %s"is_UserAlive(), iPlayerTagiSignatureiUserNameiMessages);
        }
        else if(
iHideTag == 0)
        {
            
client_color(0id"^x01%s^x04%s ^x04[^x01%s^x04] ^x03%s ^x01: %s"is_UserAlive(), iTagiSignatureiUserNameiMessages);
            
client_print(0print_console"%s%s [%s] %s : %s"is_UserAlive(), iTagiSignatureiUserNameiMessages);
        }
    }
    return 
PLUGIN_HANDLED;
}

public 
cmdHookSayTeam(id)
{
    
read_args(iMessages255);
    
remove_quotes(iMessages);    
    
    
get_user_name(idiUserName31);
    
    if(!
is_valid_msg(iMessages))
        return 
PLUGIN_HANDLED;
        
    
CheckSwears(id);
        
    
iUserAlive is_user_alive(id);
    
iUserTeam get_user_team(id);
    
    if(
iMessages[0] != '@')
    {
        static 
player;
        
        for(
player 1player <= gMaxplayersplayer++)
        {
            if(
get_user_team(player) == iUserTeam)
                
client_color(playerid"^x01%s^x03%s %s ^x01: %s"is_UserAlive(), i_UserTeam(), iUserNameiMessages);
        }
    }
    else
    {
        if(
get_user_flags(id) & ADMIN_ADMIN)
            
iTag "(ADMIN)"
        
else
            
iTag "(PLAYER)"
        
        
new iPlayers[32], iNum;
        
get_players(iPlayersiNum"ch");
        
//        for(new i = 0; i < iNum; i++)
//        {
//            if(get_user_flags(iPlayers[i]) & ADMIN_CHAT)
//            {
//                client_color(iPlayers[i], id, "^x04%s ^x03%s ^x01: %s", iTag, iUserName, iMessages[1]);
//            }
//            else if(!is_user_admin(iPlayers[i]))
//            {
//                client_color(iPlayers[i], id, "^x04%s ^x03%s ^x01: %s", iTag, iUserName, iMessages[1]);
//            }
//        }
        
for(new 0iNumi++) 
        { 
            if(
get_user_flags(iPlayers[i]) & ADMIN_CHAT && id != iPlayers[i]) 
            { 
                
client_color(iPlayers[i], id"^x04%s ^x03%s ^x01: %s"iTagiUserNameiMessages[1]); 
            } 
        }
        
client_color(idid"^x04%s ^x03%s ^x01: %s"iTagiUserNameiMessages[1]);  
    }
    return 
PLUGIN_HANDLED;
}

public 
CheckSwears(id)
{
    new 
pos0;
    
    while (
gSwearsNum)
    {
        if((
pos containi(iMessagesSwearsNames[i][1])) != -)
        { 
            new 
len SwearsNames[i][0
            while(
len--)
            
iMessages[pos++] = '*';
            continue;
        }
        ++
i
    
}
    return 
PLUGIN_HANDLED;
}

bool:is_valid_msg(const iMessages[])
{
    if(
iMessages[0] == '%' || !strlen(iMessages) || equal(iMessages"") || equal(iMessages" "))
    {
        return 
false;
    }
    return 
true;
}

public 
i_UserTeam()
{
    switch(
iUserTeam)
    {
        case 
0copy(tUserTeamsizeof(tUserTeam) - 1,"( SPEC )");
        case 
1copy(tUserTeamsizeof(tUserTeam) - 1,"( TS )");
        case 
2copy(tUserTeamsizeof(tUserTeam) - 1,"( CT )");
        case 
3copy(tUserTeamsizeof(tUserTeam) - 1,"( SPEC )");
    }
    return 
tUserTeam;
}

public 
is_UserAlive()
{
    if(!
iUserAlive && iUserTeam 3)
        
copy(tUserAlivesizeof(tUserAlive) - 1,"*??* ");
    else
        
copy(tUserAlivesizeof(tUserAlive) - 1,"");
    return 
tUserAlive;
}

stock client_color(indexcolor, const msg[], any:...) 
{
    static 
szMessage[192]
    
szMessage[0] = 0x04
    vformat
(szMessage[1], charsmax(szMessage)-1msg4)
    
    static 
iSayText
    
if (iSayText || (iSayText gSayText))
    {
        
message_begin(index MSG_ONE_UNRELIABLE MSG_BROADCASTiSayText_index)
        {
            
write_byte(color)
            
write_string(szMessage)
        }
        
message_end()
    }


Edit in amxx studio it's easier for you understand that CHINESE WORDS are not allow in scripting. There are special caracters like â ã à º or something like that

timothy0711 08-12-2012 03:36

Re: can someone help me...?
 
Quote:

Originally Posted by Torge (Post 1769471)
I can compile it without any problems...

Can you give me your amxx after complie this?

Torge 08-12-2012 09:57

Re: can someone help me...?
 
Quote:

Originally Posted by timothy0711 (Post 1769740)
Can you give me your amxx after complie this?

I think I'm not allowed to attach it... Try way of quilhos.

OvidiuS 08-12-2012 11:58

Re: can someone help me...?
 
1 Attachment(s)
Here you go..
You just have to use UTF-8 without BOOM encoding.

YamiKaitou 08-12-2012 12:01

Re: can someone help me...?
 
AMXX file removed, you are not authorized to upload it


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

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