Raised This Month: $51 Target: $400
 12% 

edit the plugin damager


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
impossible89
Member
Join Date: Jun 2020
Old 07-01-2020 , 11:29   edit the plugin damager
Reply With Quote #1

Hello, I want to edit this plugin so that it is only available to VIP players with flag b

the plugin has an option to turn on and off with the command/damager

I want those who are not VIP players not to have access to this command when they write in the chat /damager for example to write to them [PremiumVIP] You have no access to that command ! with message coloring option подобно на този текст https://prnt.sc/t9voii
and when the option is set to rotate around the player does not rotate around him, but 2 meters from him if it can be done closer to him to rotate the damage


да стане подобен на тази снимка на ConnorMcLeod https://prnt.sc/t9vrz7 , https://prnt.sc/t9vsgc

this is the plugin that needs to be edited


Code:
#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
*/

//#define sFlags "abc"
/*
* comment out if you want to switch off this function
*/

new const g_szColors[][] =
{
    { 255, 100, 100 },
    { 255, 100, 100 },
    { 255, 100, 100 },
    { 255, 100, 100 },
    { 255, 100, 100 }
}

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.6";

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)
{
#if defined sFlags
    if(!(get_user_flags(iPlayer) & read_flags(sFlags)))
    {
        return PLUGIN_HANDLED;
    }
#endif

    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 defined sFlags
    if(!(get_user_flags(iAttacker) & read_flags(sFlags)))
    {
        return;
    }
#endif

    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, 100, 100, 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, 100, 100, -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);
    }
}
impossible89 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 17:35.


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