Custom Info Connect

Плагин АМХХ Custom Info Connect 1.1.1

Нет прав для скачивания
C++:
#include <amxmodx>

new szPluginInfo[][] = { "Custom InfoConnect", "1.1.1", "ApXuTekToR" };

enum _:DATA { AUTH[32],  MSG[128]};
new Array:g_aData, g_PlayerData[DATA];
new g_szMessage[MAX_PLAYERS*2][512], CheckPlugin, Float:TaskInfo, ShowInfo_Mode;
new bool:g_sApi, hudSinc, g_ColorStr[32], g_PosStr[32], FxSet[32], TimeSet[32];
enum Colors        { RED, GREEN, BLUE };
enum Position    { Float:POS_X, Float:POS_Y };

enum e_InfoSettings {
    EFFECT,
    Float:Fx_Time,
    Float:HoldTime,
    Float:FadeInTime,
    Float:FadeOutTime,
    Channel
};
new InfoSet[e_InfoSettings];

// === Native's === //
// RBS
native ar_get_user_level(id, string[] = "", len = 0);
// AES
native aes_get_level_name(level,level_name[],len,idLang = LANG_SERVER);
// CMS
native cmsranks_get_user_level(id, string[] = "", len = 0);
native cmsapi_get_user_nick(id, szNick[], Len);
native cmsapi_get_user_group(id, szGroup[] = "", Len = 0);
// === Native's End === //

public plugin_natives()
    set_native_filter("native_filter");

public native_filter(const name[], index, trap)
    return trap ? PLUGIN_CONTINUE : PLUGIN_HANDLED;

public plugin_init() {
    register_plugin(szPluginInfo[0], szPluginInfo[1], szPluginInfo[2]);
    register_cvar("CIC_Task_ShowInfo",        "5.0"        );
    register_cvar("CIC_ShowInfo_Mode",        "1"            );
    register_cvar("CIC_ShowInfo_Color",        "0 255 155"    );
    register_cvar("CIC_ShowInfo_Position",    "0.05 0.65"    );
    register_cvar("CIC_Effects_Settings",    "0 6.0 0.1"    );
    register_cvar("CIC_Effects_TimeSet",    "5.0 0.2 -1");

    hudSinc = CreateHudSyncObj();
}

public plugin_cfg() {
    if(is_plugin_loaded("Advanced Experience System") != -1)    CheckPlugin = 1;
    else if(is_plugin_loaded("army_ranks_ultimate.amxx") != -1)    CheckPlugin    = 2;
    else if(is_plugin_loaded("CMSStats_Ranks") != -1)             CheckPlugin    = 3;
    else log_amx("[%s] There is no rank system on the server", szPluginInfo[0]);

    if(is_plugin_loaded("GameCMS_API") != -1) g_sApi = true;
    else g_sApi = false;

    new cfgFilePath[PLATFORM_MAX_PATH];
    new const fileName[64] = "/SevCorp/Custom_InfoConnect/Custom_InfoConnect.cfg";
    get_localinfo("amxx_configsdir", cfgFilePath, charsmax(cfgFilePath));
    add(cfgFilePath, charsmax(cfgFilePath), fileName);
    if(file_exists(cfgFilePath)) {
        server_cmd("exec %s", cfgFilePath);
        server_exec();
        InitCvars();
    } else {
        server_print("[%s v%s] [Error] [Config file not found (%s)] [Plugin stopped]", szPluginInfo[0], szPluginInfo[1], cfgFilePath);
        set_fail_state("[Config file not found (%s)]", cfgFilePath);
    }

    g_aData = ArrayCreate(DATA);
    new buff[256], fp = fopen("addons/amxmodx/configs/SevCorp/Custom_InfoConnect/Custom_InfoConnect.ini", "rt");
    if(!fp) return set_fail_state("File ^"addons/amxmodx/configs/SevCorp/Custom_InfoConnect/Custom_InfoConnect.ini^" not found");
    while(!feof(fp)) {
        fgets(fp, buff, charsmax(buff));
        if(buff[0] && buff[0] != ';' && parse(buff, g_PlayerData[AUTH], charsmax(g_PlayerData[AUTH]), g_PlayerData[MSG], charsmax(g_PlayerData[MSG])))
            ArrayPushArray(g_aData, g_PlayerData);
    } return fclose(fp);
}

InitCvars() {
    TaskInfo        = get_cvar_float("CIC_Task_ShowInfo");
    ShowInfo_Mode    = get_cvar_num("CIC_ShowInfo_Mode");
    get_cvar_string("CIC_ShowInfo_Color",         g_ColorStr, charsmax(g_ColorStr));
    get_cvar_string("CIC_ShowInfo_Position",     g_PosStr,     charsmax(g_PosStr)    );
    get_cvar_string("CIC_Effects_Settings",     FxSet,         charsmax(FxSet)        );
    get_cvar_string("CIC_Effects_TimeSet",         TimeSet,     charsmax(TimeSet)    );

    ParsingInfo_Settings();
}

public client_putinserver(id) {
    SearchClient(id);
    if(g_szMessage[id][0])
        set_task(TaskInfo, "ShowInfo", id);
}

public ShowInfo(id) {
    new szName[32];    get_user_name(id, szName, charsmax(szName));
    replace_all(g_szMessage[id], charsmax(g_szMessage[]), "!n", "^1");
    replace_all(g_szMessage[id], charsmax(g_szMessage[]), "!t", "^3");
    replace_all(g_szMessage[id], charsmax(g_szMessage[]), "!g", "^4");
    replace_all(g_szMessage[id], charsmax(g_szMessage[]), "%Name%", szName);
    if(ShowInfo_Mode == 2 || ShowInfo_Mode == 3) {
        replace_all(g_szMessage[id], charsmax(g_szMessage[]), "\n", "^n");
    }

    if(CheckPlugin) {
        new szRank[64];
        switch(CheckPlugin) {
            case 0: log_amx("[%s] [WARNING] I didn't find any rank system", szPluginInfo[0]);
            case 1: aes_get_level_name(id, szRank, charsmax(szRank));
            case 2: ar_get_user_level(id, szRank, charsmax(szRank));
            case 3: cmsranks_get_user_level(id, szRank, charsmax(szRank));
        }
        replace_all(g_szMessage[id], charsmax(g_szMessage[]), "%Rank%", szRank);
    }

    if(g_sApi) {
        new szUserGroup[32], szUserNick[32];
        cmsapi_get_user_nick(id, szUserNick, charsmax(szUserNick));
        cmsapi_get_user_group(id, szUserGroup, charsmax(szUserGroup));
        replace_all(g_szMessage[id], charsmax(g_szMessage[]), "%UserNick%", szUserNick);
        replace_all(g_szMessage[id], charsmax(g_szMessage[]), "%UserGroup%", szUserGroup);
    }

    switch(ShowInfo_Mode) {
        case 0: log_amx("[%s] The output mode is Not selected. Please check seetings", szPluginInfo[0]);
        case 1: client_print_color(0, print_team_default, "%s", g_szMessage[id]);
        case 2: {
            static colors[Colors]; getColors(g_ColorStr, colors);
            static pos[Position]; getPosition(g_PosStr, pos);
            set_hudmessage(colors[RED], colors[GREEN], colors[BLUE], pos[POS_X], pos[POS_Y],
                            InfoSet[EFFECT], InfoSet[Fx_Time], InfoSet[HoldTime], InfoSet[FadeInTime], InfoSet[FadeOutTime], InfoSet[Channel]);
            ShowSyncHudMsg(0, hudSinc, "%s", g_szMessage[id]);
        }
        case 3: {
            static colors[Colors]; getColors(g_ColorStr, colors);
            static pos[Position]; getPosition(g_PosStr, pos);
            set_dhudmessage(colors[RED], colors[GREEN], colors[BLUE], pos[POS_X], pos[POS_Y], 0, 6.0, 12.0, 0.1, 0.2);
            show_dhudmessage(0, "%s", g_szMessage[id]);
        }
    }
}

stock SearchClient(const id) {
    new szIP[16];      get_user_ip(id, szIP, charsmax(szIP), 1);
    new szAuthid[25]; get_user_authid(id, szAuthid, charsmax(szAuthid));

    for(new i, flags = get_user_flags(id); i < ArraySize(g_aData); i++) {
        ArrayGetArray(g_aData, i, g_PlayerData);
        switch(g_PlayerData[AUTH][0]) {
            case '#': {
                if(is_user_steam(id))
                    return copy(g_szMessage[id], charsmax(g_szMessage[]), g_PlayerData[MSG]);
            }
            case '*': {
                return copy(g_szMessage[id], charsmax(g_szMessage[]), g_PlayerData[MSG]);
            }
            case 'S', 'V': {
                if(strcmp(g_PlayerData[AUTH], szAuthid) == 0)
                    return copy(g_szMessage[id], charsmax(g_szMessage[]), g_PlayerData[MSG]);
            }
            default: {
                if(isdigit(g_PlayerData[AUTH][0])) {
                    if(strcmp(g_PlayerData[AUTH], szIP) == 0)
                        return copy(g_szMessage[id], charsmax(g_szMessage[]), g_PlayerData[MSG]);
                }
                else if(flags & read_flags(g_PlayerData[AUTH]))
                    return copy(g_szMessage[id], charsmax(g_szMessage[]), g_PlayerData[MSG]);
            }
        }
    }
    return g_szMessage[id][0] = 0;
}

ParsingInfo_Settings() {
    new md[2], shine[6], print[6], holdtime[10], fdouttime[8], channel[2];

    parse(FxSet, md, charsmax(md), shine, charsmax(shine), print, charsmax(print));
    parse(TimeSet, holdtime, charsmax(holdtime), fdouttime, charsmax(fdouttime), channel, charsmax(channel));

    InfoSet[EFFECT]            = str_to_num(md);
    InfoSet[Fx_Time]        = str_to_float(shine);
    InfoSet[FadeInTime]        = str_to_float(print);
    InfoSet[HoldTime]        = str_to_float(holdtime);
    InfoSet[FadeOutTime]    = str_to_float(fdouttime);
    InfoSet[Channel]        = str_to_num(channel);
}

getColors(const str[], output[Colors]) {
    static colors[3][11];
    if(parse(str, colors[0], 10, colors[1], 10, colors[2], 10) != 3){
        log_error(AMX_ERR_PARAMS, "Invalid colors string '%s'", str);
        return;
    }
    output[RED]         = str_to_num(colors[0]);
    output[GREEN]    = str_to_num(colors[1]);
    output[BLUE]    = str_to_num(colors[2]);
}

getPosition(const str[], output[Position]) {
    static pos[2][11];
    if(parse(str, pos[0], 10, pos[1], 10) != 2) {
        log_error(AMX_ERR_PARAMS, "Invalid position string '%s'", str);
        return;
    }
    output[POS_X]  = str_to_float(pos[0]);
    output[POS_Y]  = str_to_float(pos[1]);
}

stock bool:is_user_steam(id) {
    static dp_pointer;
    if(dp_pointer || (dp_pointer = get_cvar_pointer("dp_r_id_provider"))) {
        server_cmd("dp_clientinfo %d", id);
        server_exec();
        return (get_pcvar_num(dp_pointer) == 2) ? true : false;
    }
    return false;
}
Назад
Сверху