Damager (избавиться от поддержки reapi)

pollfank

Пользователь
Регистрация
10 Июл 2017
Сообщения
40
Симпатии
2
Пол
Мужской
Здравствуйте.
Пытаюсь отвязать плагин Damager 0.0.5 от поддержки reapi. Есть нужда в этом.
Вот что получилось

Код:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <nvault_array>

#define VISIBILITY_THROUGH_WALLS 2
/* comment out if you want that players saw a loss through walls
* 1 - Players can select to see a loss through walls or not
* 2 - Players cannot select. They will not see a loss through walls
*/
#define AUTO_RESET_INACTIVE_USERS 30
/*
* 30 - days through how many to execute reset
* comment out if you want to switch off this function
*/

new const g_szColors[][] =
{
    { 255, 228, 181 },
    { 30, 144, 255 },
    { 255, 255, 0 },
    { 50, 205, 50 },
    { 144, 238, 144 }
}

new const Float: g_szCoords[][] =
{
    { 0.50, 0.40 },
    { 0.56, 0.44 },
    { 0.60, 0.50 },
    { 0.56, 0.56 },
    { 0.50, 0.60 },
    { 0.44, 0.56 },
    { 0.40, 0.50 },
    { 0.44, 0.44 }
}


#if !defined MAX_PLAYERS
    const MAX_PLAYERS = 32;
#endif

#if !defined MAX_AUTHID_LENGTH
    const MAX_AUTHID_LENGTH = 64;
#endif

#define DMG_BLAST (1<<6)

new const PLUGIN_NAME[] = "Damager";
new const PLUGIN_VERSION[] = "0.0.5";

enum _:eData
{
    STATE,
    STYLE,
    TYPE,
    INCOMING,
#if defined VISIBILITY_THROUGH_WALLS
    #if VISIBILITY_THROUGH_WALLS == 1
    VISIBLE,
    #endif
#endif
    POSITION,
    AUTHID[MAX_AUTHID_LENGTH]
} new g_iDamagerData[MAX_PLAYERS+1][eData];

enum _:eState
{
    DISABLE = 0,
    ENABLE
}

enum _:eStyle
{
    NUMBERS = 0,
    STARS
}

enum _:eType
{
    DEFAULT = 0,
    CIRCLE
}
#if defined VISIBILITY_THROUGH_WALLS
    #if VISIBILITY_THROUGH_WALLS == 1
        enum _:eVisible
        {
            INVISIBLE = 0,
            VISIBLE
        }
    #endif
#endif

new g_HudSyncMessage;
new g_HudSyncMessage2;

new const m_iMenu = 205;
new const MENU_OFF = 0;

#if defined VISIBILITY_THROUGH_WALLS
    #if VISIBILITY_THROUGH_WALLS == 1
        const MENU_KEYS = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_0;
    #else
        const MENU_KEYS = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_0;
    #endif
#else
    const MENU_KEYS = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_0;
#endif

new g_hVault;
#if defined VISIBILITY_THROUGH_WALLS
    #if VISIBILITY_THROUGH_WALLS == 1
        new const VAULT_FILE[] = "damager4";
    #else
        new const VAULT_FILE[] = "damager5";
    #endif
#else
    new const VAULT_FILE[] = "damager5";
#endif

#define IsBot(%1) (!g_iDamagerData[%1][AUTHID][0])

public plugin_init()
{
    register_plugin(PLUGIN_NAME, PLUGIN_VERSION, "steelzzz");

    register_cvar("damager_version", PLUGIN_VERSION, FCVAR_SERVER | FCVAR_SPONLY); // spy

    register_clcmd("say /damager", "Command_ShowDmgMenu");

    register_menucmd(register_menuid("Command_ShowDmgMenu"), MENU_KEYS, "DmgMenu_Handler");

    RegisterHam(Ham_TakeDamage, "player", "UserTakeDamage", true)
    //RegisterHookChain(RG_CBasePlayer_TakeDamage, "CPlayer_TakeDamage_Post", .post = true);

    g_HudSyncMessage = CreateHudSyncObj();
    g_HudSyncMessage2 = CreateHudSyncObj();
    g_hVault = nvault_open(VAULT_FILE);

    if(g_hVault == INVALID_HANDLE)
    {
        set_fail_state("[!] Opening nVault failed!");
    }
#if defined AUTO_RESET_INACTIVE_USERS
    else
    {
        nvault_prune(g_hVault, 0, get_systime() - (86400 * AUTO_RESET_INACTIVE_USERS));
    }
#endif

    register_dictionary("damager.txt");
}
public plugin_end()
{
    if(g_hVault != INVALID_HANDLE)
    {
        nvault_close(g_hVault);
    }
}

public client_authorized(iPlayer)
{
    nVaultSaveData(iPlayer);
}

public client_putinserver(iPlayer)
{
    g_iDamagerData[iPlayer][AUTHID][0] = 0;

    if(is_user_bot(iPlayer) || is_user_hltv(iPlayer))
    {
        return;
    }

    get_user_authid(iPlayer, g_iDamagerData[iPlayer][AUTHID], MAX_AUTHID_LENGTH - 1);

    if(nvault_get_array(g_hVault, g_iDamagerData[iPlayer][AUTHID], g_iDamagerData[iPlayer], eData) <= 0)
    {
        g_iDamagerData[iPlayer][STATE] = ENABLE;
        g_iDamagerData[iPlayer][STYLE] = NUMBERS;
#if defined VISIBILITY_THROUGH_WALLS
    #if VISIBILITY_THROUGH_WALLS == 1
        g_iDamagerData[iPlayer][VISIBLE] = VISIBLE;
    #endif
#endif
        g_iDamagerData[iPlayer][TYPE] = DEFAULT;
        g_iDamagerData[iPlayer][INCOMING] = DISABLE;
    }
}

public Command_ShowDmgMenu(iPlayer)
{
    new szMenu[512];
    new iLen;
    
    iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "%L^n^n", iPlayer, "MENU_TITLE");

    iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "%L^n", iPlayer, "MENU_ITEM1", iPlayer, g_iDamagerData[iPlayer][STATE] ? "ENABLED" : "DISABLED");
    iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "%L^n", iPlayer, "MENU_ITEM2", iPlayer, g_iDamagerData[iPlayer][STYLE] ? "STARS" : "NUMBERS");
    iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "%L^n", iPlayer, "MENU_ITEM3", iPlayer, g_iDamagerData[iPlayer][TYPE] ? "CIRCLE" : "DEFAULT");
    iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "%L^n", iPlayer, "MENU_ITEM4", iPlayer, g_iDamagerData[iPlayer][INCOMING] ? "ENABLED" : "DISABLED");
#if defined VISIBILITY_THROUGH_WALLS
    #if VISIBILITY_THROUGH_WALLS == 1
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "%L^n", iPlayer, "MENU_ITEM5", iPlayer, g_iDamagerData[iPlayer][VISIBLE] ? "ENABLED" : "DISABLED");
    #endif
#endif
    formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n%L", iPlayer, "MENU_EXIT");

#if AMXX_VERSION_NUM < 183
    set_pdata_int(iPlayer, m_iMenu, MENU_OFF);
#endif
    show_menu(iPlayer, MENU_KEYS, szMenu, -1, "Command_ShowDmgMenu");

    return PLUGIN_CONTINUE;
}

public DmgMenu_Handler(iPlayer, iKey)
{
    if(iKey == 9)
    {
        nVaultSaveData(iPlayer);
        return PLUGIN_HANDLED;
    }

#if defined VISIBILITY_THROUGH_WALLS
    #if VISIBILITY_THROUGH_WALLS == 1
        new const iPtr[] = {STATE, STYLE, TYPE, INCOMING, VISIBLE};
    #else
        new const iPtr[] = {STATE, STYLE, TYPE, INCOMING};
    #endif
#else
    new const iPtr[] = {STATE, STYLE, TYPE, INCOMING};
#endif
    iKey = iPtr[iKey];

    g_iDamagerData[iPlayer][iKey] = !g_iDamagerData[iPlayer][iKey];
    Command_ShowDmgMenu(iPlayer);

    return PLUGIN_HANDLED;
}

public UserTakeDamage(iVictim, weapon, iAttacker, Float:flDamage, iBitsDamageType)
{
    if(!is_user_connected(iAttacker) || flDamage <= 1.0 || iVictim == iAttacker)
    {
        return;
    }

    if(iBitsDamageType & DMG_BLAST)
    {
        return;
    }

#if defined VISIBILITY_THROUGH_WALLS
    #if VISIBILITY_THROUGH_WALLS == 1
    if(!g_iDamagerData[iAttacker][STATE] || (!g_iDamagerData[iAttacker][VISIBLE] && !ExecuteHam(Ham_FVisible, iAttacker, iVictim)))
    #elseif VISIBILITY_THROUGH_WALLS == 2
    if(!g_iDamagerData[iAttacker][STATE] || (!ExecuteHam(Ham_FVisible, iAttacker, iVictim)))
    #endif
#else
    if(!g_iDamagerData[iAttacker][STATE])
#endif
    {
        return;       
    }

    new iColor = random_num(0, charsmax(g_szColors));

    if(g_iDamagerData[iAttacker][TYPE])
    {
        new iPos = ++g_iDamagerData[iAttacker][POSITION];

        if(iPos == sizeof(g_szCoords))
        {
            iPos = g_iDamagerData[iAttacker][POSITION] = 0;
        }

        if(g_iDamagerData[iVictim][INCOMING])
        {
            set_hudmessage(255, 0, 0, g_szCoords[iPos][0], g_szCoords[iPos][1]+0.06, 0, 0.1, 2.5, 0.02, 0.02, -1);
            ShowSyncHudMsg(iVictim, g_HudSyncMessage2, (g_iDamagerData[iVictim][STYLE]) ? "*" : "%.0f", flDamage);
        }
        set_hudmessage(g_szColors[iColor][0], g_szColors[iColor][1], g_szColors[iColor][2], g_szCoords[iPos][0], g_szCoords[iPos][1], 0, 0.1, 2.5, 0.02, 0.02, -1);
    }
    else
    {
        if(g_iDamagerData[iVictim][INCOMING])
        {
            set_hudmessage(255, 0, 0, -1.0, 0.45, 2, 0.1, 4.0, 0.02, 0.02, -1);
            ShowSyncHudMsg(iVictim, g_HudSyncMessage2, (g_iDamagerData[iVictim][STYLE]) ? "*" : "%.0f", flDamage);
        }
        set_hudmessage(g_szColors[iColor][0], g_szColors[iColor][1], g_szColors[iColor][2], -1.0, 0.55, 2, 0.1, 4.0, 0.02, 0.02, -1);
    }

    ShowSyncHudMsg(iAttacker, g_HudSyncMessage, (g_iDamagerData[iAttacker][STYLE]) ? "*" : "%.0f", flDamage);
}

public nVaultSaveData(iPlayer)
{
    if(!IsBot(iPlayer))
    {
        nvault_set_array(g_hVault, g_iDamagerData[iPlayer][AUTHID], g_iDamagerData[iPlayer], eData);
    }
}
Меню работает, настройки сохраняются, но не выводит в худ урон. Кто может подскажет что упустил...

Оригинал кода ниже:

Код:
#include <amxmodx>
#include <reapi>
#include <nvault_array>
#include <hamsandwich>

/**         Settings        **/

#define VISIBILITY_THROUGH_WALLS 2
/* comment out if you want that players saw a loss through walls
* 1 - Players can select to see a loss through walls or not
* 2 - Players cannot select. They will not see a loss through walls
*/
#define AUTO_RESET_INACTIVE_USERS 30
/*
* 30 - days through how many to execute reset
* comment out if you want to switch off this function
*/

new const g_szColors[][] =
{
    { 255, 228, 181 },
    { 30, 144, 255 },
    { 255, 255, 0 },
    { 50, 205, 50 },
    { 144, 238, 144 }
}

new const Float: g_szCoords[][] =
{
    { 0.50, 0.40 },
    { 0.56, 0.44 },
    { 0.60, 0.50 },
    { 0.56, 0.56 },
    { 0.50, 0.60 },
    { 0.44, 0.56 },
    { 0.40, 0.50 },
    { 0.44, 0.44 }
}

/**         Settings        **/

#if !defined MAX_PLAYERS
    const MAX_PLAYERS = 32;
#endif

#if !defined MAX_AUTHID_LENGTH
    const MAX_AUTHID_LENGTH = 64;
#endif

new const PLUGIN_NAME[] = "Damager";
new const PLUGIN_VERSION[] = "0.0.5";

enum _:eData
{
    STATE,
    STYLE,
    TYPE,
    INCOMING,
#if defined VISIBILITY_THROUGH_WALLS
    #if VISIBILITY_THROUGH_WALLS == 1
    VISIBLE,
    #endif
#endif
    POSITION,
    AUTHID[MAX_AUTHID_LENGTH]
} new g_iDamagerData[MAX_PLAYERS+1][eData];

enum _:eState
{
    DISABLE = 0,
    ENABLE
}

enum _:eStyle
{
    NUMBERS = 0,
    STARS
}

enum _:eType
{
    DEFAULT = 0,
    CIRCLE
}
#if defined VISIBILITY_THROUGH_WALLS
    #if VISIBILITY_THROUGH_WALLS == 1
        enum _:eVisible
        {
            INVISIBLE = 0,
            VISIBLE
        }
    #endif
#endif

new g_HudSyncMessage;
new g_HudSyncMessage2;

#if defined VISIBILITY_THROUGH_WALLS
    #if VISIBILITY_THROUGH_WALLS == 1
        const MENU_KEYS = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_0;
    #else
        const MENU_KEYS = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_0;
    #endif
#else
    const MENU_KEYS = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_0;
#endif

new g_hVault;
#if defined VISIBILITY_THROUGH_WALLS
    #if VISIBILITY_THROUGH_WALLS == 1
        new const VAULT_FILE[] = "damager4";
    #else
        new const VAULT_FILE[] = "damager5";
    #endif
#else
    new const VAULT_FILE[] = "damager5";
#endif

#define IsBot(%1) (!g_iDamagerData[%1][AUTHID][0])

public plugin_init()
{
    register_plugin(PLUGIN_NAME, PLUGIN_VERSION, "steelzzz");

    register_cvar("damager_version", PLUGIN_VERSION, FCVAR_SERVER | FCVAR_SPONLY); // spy

    register_clcmd("say /damager", "Command_ShowDmgMenu");

    register_menucmd(register_menuid("Command_ShowDmgMenu"), MENU_KEYS, "DmgMenu_Handler");

    RegisterHookChain(RG_CBasePlayer_TakeDamage, "CPlayer_TakeDamage_Post", .post = true);

    g_HudSyncMessage = CreateHudSyncObj();
    g_HudSyncMessage2 = CreateHudSyncObj();
    g_hVault = nvault_open(VAULT_FILE);

    if(g_hVault == INVALID_HANDLE)
    {
        set_fail_state("[!] Opening nVault failed!");
    }
#if defined AUTO_RESET_INACTIVE_USERS
    else
    {
        nvault_prune(g_hVault, 0, get_systime() - (86400 * AUTO_RESET_INACTIVE_USERS));
    }
#endif

    register_dictionary("damager.txt");
}
public plugin_end()
{
    if(g_hVault != INVALID_HANDLE)
    {
        nvault_close(g_hVault);
    }
}

public client_authorized(iPlayer)
{
    nVaultSaveData(iPlayer);
}

public client_putinserver(iPlayer)
{
    g_iDamagerData[iPlayer][AUTHID][0] = 0;

    if(is_user_bot(iPlayer) || is_user_hltv(iPlayer))
    {
        return;
    }

    get_user_authid(iPlayer, g_iDamagerData[iPlayer][AUTHID], MAX_AUTHID_LENGTH - 1);

    if(nvault_get_array(g_hVault, g_iDamagerData[iPlayer][AUTHID], g_iDamagerData[iPlayer], eData) <= 0)
    {
        g_iDamagerData[iPlayer][STATE] = ENABLE;
        g_iDamagerData[iPlayer][STYLE] = NUMBERS;
#if defined VISIBILITY_THROUGH_WALLS
    #if VISIBILITY_THROUGH_WALLS == 1
        g_iDamagerData[iPlayer][VISIBLE] = VISIBLE;
    #endif
#endif
        g_iDamagerData[iPlayer][TYPE] = DEFAULT;
        g_iDamagerData[iPlayer][INCOMING] = DISABLE;
    }
}

public Command_ShowDmgMenu(iPlayer)
{
    new szMenu[512];
    new iLen;
    
    iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "%L^n^n", iPlayer, "MENU_TITLE");

    iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "%L^n", iPlayer, "MENU_ITEM1", iPlayer, g_iDamagerData[iPlayer][STATE] ? "ENABLED" : "DISABLED");
    iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "%L^n", iPlayer, "MENU_ITEM2", iPlayer, g_iDamagerData[iPlayer][STYLE] ? "STARS" : "NUMBERS");
    iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "%L^n", iPlayer, "MENU_ITEM3", iPlayer, g_iDamagerData[iPlayer][TYPE] ? "CIRCLE" : "DEFAULT");
    iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "%L^n", iPlayer, "MENU_ITEM4", iPlayer, g_iDamagerData[iPlayer][INCOMING] ? "ENABLED" : "DISABLED");
#if defined VISIBILITY_THROUGH_WALLS
    #if VISIBILITY_THROUGH_WALLS == 1
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "%L^n", iPlayer, "MENU_ITEM5", iPlayer, g_iDamagerData[iPlayer][VISIBLE] ? "ENABLED" : "DISABLED");
    #endif
#endif
    formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n%L", iPlayer, "MENU_EXIT");

#if AMXX_VERSION_NUM < 183
    set_member(iPlayer, m_iMenu, Menu_OFF);
#endif
    show_menu(iPlayer, MENU_KEYS, szMenu, -1, "Command_ShowDmgMenu");

    return PLUGIN_CONTINUE;
}

public DmgMenu_Handler(iPlayer, iKey)
{
    if(iKey == 9)
    {
        nVaultSaveData(iPlayer);
        return PLUGIN_HANDLED;
    }

#if defined VISIBILITY_THROUGH_WALLS
    #if VISIBILITY_THROUGH_WALLS == 1
        new const iPtr[] = {STATE, STYLE, TYPE, INCOMING, VISIBLE};
    #else
        new const iPtr[] = {STATE, STYLE, TYPE, INCOMING};
    #endif
#else
    new const iPtr[] = {STATE, STYLE, TYPE, INCOMING};
#endif
    iKey = iPtr[iKey];

    g_iDamagerData[iPlayer][iKey] = !g_iDamagerData[iPlayer][iKey];
    Command_ShowDmgMenu(iPlayer);

    return PLUGIN_HANDLED;
}

public CPlayer_TakeDamage_Post(iVictim, iInflictor, iAttacker, Float:flDamage, iBitsDamageType)
{
    if(!is_user_connected(iAttacker) || flDamage <= 1.0 || !rg_is_player_can_takedamage(iVictim, iAttacker) || iVictim == iAttacker)
    {
        return;
    }

    if(iBitsDamageType & DMG_BLAST)
    {
        return;
    }

#if defined VISIBILITY_THROUGH_WALLS
    #if VISIBILITY_THROUGH_WALLS == 1
    if(!g_iDamagerData[iAttacker][STATE] || (!g_iDamagerData[iAttacker][VISIBLE] && !ExecuteHam(Ham_FVisible, iAttacker, iVictim)))
    #elseif VISIBILITY_THROUGH_WALLS == 2
    if(!g_iDamagerData[iAttacker][STATE] || (!ExecuteHam(Ham_FVisible, iAttacker, iVictim)))
    #endif
#else
    if(!g_iDamagerData[iAttacker][STATE])
#endif
    {
        return;       
    }

    new iColor = random_num(0, charsmax(g_szColors));

    if(g_iDamagerData[iAttacker][TYPE])
    {
        new iPos = ++g_iDamagerData[iAttacker][POSITION];

        if(iPos == sizeof(g_szCoords))
        {
            iPos = g_iDamagerData[iAttacker][POSITION] = 0;
        }

        if(g_iDamagerData[iVictim][INCOMING])
        {
            set_hudmessage(255, 0, 0, g_szCoords[iPos][0], g_szCoords[iPos][1]+0.06, 0, 0.1, 2.5, 0.02, 0.02, -1);
            ShowSyncHudMsg(iVictim, g_HudSyncMessage2, (g_iDamagerData[iVictim][STYLE]) ? "*" : "%.0f", flDamage);
        }
        set_hudmessage(g_szColors[iColor][0], g_szColors[iColor][1], g_szColors[iColor][2], g_szCoords[iPos][0], g_szCoords[iPos][1], 0, 0.1, 2.5, 0.02, 0.02, -1);
    }
    else
    {
        if(g_iDamagerData[iVictim][INCOMING])
        {
            set_hudmessage(255, 0, 0, -1.0, 0.45, 2, 0.1, 4.0, 0.02, 0.02, -1);
            ShowSyncHudMsg(iVictim, g_HudSyncMessage2, (g_iDamagerData[iVictim][STYLE]) ? "*" : "%.0f", flDamage);
        }
        set_hudmessage(g_szColors[iColor][0], g_szColors[iColor][1], g_szColors[iColor][2], -1.0, 0.55, 2, 0.1, 4.0, 0.02, 0.02, -1);
    }

    ShowSyncHudMsg(iAttacker, g_HudSyncMessage, (g_iDamagerData[iAttacker][STYLE]) ? "*" : "%.0f", flDamage);
}

public nVaultSaveData(iPlayer)
{
    if(!IsBot(iPlayer))
    {
        nvault_set_array(g_hVault, g_iDamagerData[iPlayer][AUTHID], g_iDamagerData[iPlayer], eData);
    }
}
 
Сверху Снизу