Другие Плагин для кс 1.6 - DeadCounter

Начинающий
Статус
Оффлайн
Регистрация
9 Июн 2022
Сообщения
19
Реакции[?]
1
Поинты[?]
0
Данный плагин включает в себя команду "esp" - включение и выключение плагина.
Плагин показывает коунтер игроков после смерти.

wh_check:
Код:
#include <amxmodx>
#include <reapi>
#include <fakemeta>
#include <xs>


#define setBit(%0,%1)                                ((%0) |= (1 << (%1)))
#define clearBit(%0,%1)                             ((%0) &= ~(1 << (%1)))
#define isSetBit(%0,%1)                             ((%0) & (1 << (%1)))
#define isNotSetBit(%0,%1)                             (~(%0) & (1 << (%1)))
#define invertBit(%0,%1)                             ((%0) ^= (1 << (%1)))

#define IsPlayer(%0) (1 <= %0 <= MaxClients)

const Float:DISTANCE_BASE = 10.0
new const ESP_CLASSNAME[] = "counter"
new const SPRITE[] = "sprites/wh_marker.spr"

new g_iBitUserAlive;
new g_iBitUserConnect;
new g_iBitUserEffected;
new g_iBitUserVision;

new g_iUserTeam[MAX_PLAYERS + 1] = { 'U', ... }
new g_pEntity[MAX_PLAYERS + 1];

new VisionMode,
    ViewMode,
    ToggleEsp,
    AdminFlags = ADMIN_BAN;
   
#define EF_FORCEVISIBILITY              2048 // force visibility (https://dev-cs.ru/amxx/cssdk_const/inc)

enum _:XYZ
{
    Float:X,
    Float:Y,
    Float:Z
}

public plugin_init()
{
    register_plugin("WH View for Dead", "1.2", "LimboOc");
   
    RegisterHookChain(RG_CBasePlayer_Spawn,             "HC_CBasePlayer_PlayerSpawn_Post",         true);
    RegisterHookChain(RG_CBasePlayer_Killed,             "HC_CBasePlayer_PlayerKilled_Post",     true);
    register_forward(FM_AddToFullPack,                     "OnAddToFullPack_Post", true);
    register_event("TeamInfo", "event_TeamInfo", "a");
   
    register_clcmd("esp", "esp");
}

public plugin_cfg()
{
    new pcvar;
    pcvar = create_cvar("amx_wh_visionmode", "0", FCVAR_SERVER, "0 - показывает для всех игроков, 1- показывает только админам");
    bind_pcvar_num(pcvar, VisionMode);
   
    pcvar = create_cvar("amx_wh_access", "b", FCVAR_SERVER, "если amx_wh_mode = 1, то на какой флаг админа дать возможность");
    hook_cvar_change(pcvar, "HookChangeFlag");
   
    pcvar = create_cvar("amx_wh_viewmode", "0", FCVAR_SERVER, "Фильтрация показа ESP^n0 - фильтруется только противоположную команду, 1 - фильтует всех");
    bind_pcvar_num(pcvar, ViewMode);
   
    pcvar = create_cvar("amx_wh_esp", "0", FCVAR_SERVER, "Выборочное отключение ESP режима^n0 - принудительно не отключать esp у мертвых игроков, 1 - можно отключить введя команду в консоле toggleesp");
    bind_pcvar_num(pcvar, Esp);
   
    AutoExecConfig();
}

public HookChangeFlag(const pcvar, const oldValue[], const newValue[]) AdminFlags = read_flags(newValue);

public plugin_precache() precache_model(SPRITE)

public toggleesp(pId)
{
    if(ToggleEsp)
    {
        if(VisionMode && (AdminFlags && (get_user_flags(pId) & AdminFlags) == AdminFlags))
        {
            invertBit(g_iBitUserVision, pId);
        }
        else
        if(!VisionMode)
        {
            invertBit(g_iBitUserVision, pId);
        }
    }
}

public client_putinserver(pId)
{
    setBit(g_iBitUserConnect, pId);
   
    if(VisionMode && (AdminFlags && (get_user_flags(pId) & AdminFlags) == AdminFlags))
    {
        setBit(g_iBitUserVision, pId)
    }
    else
    if(!VisionMode)
    {
        setBit(g_iBitUserVision, pId);
    }
}

public client_disconnected(pId)
{
    clearBit(g_iBitUserConnect, pId);
   
    if(isSetBit(g_iBitUserAlive, pId))
    {
        clearBit(g_iBitUserAlive, pId);
    }
    RemoveEntity(pId);
   
    clearBit(g_iBitUserVision, pId);
}

public HC_CBasePlayer_PlayerSpawn_Post(const pId)
{
    if(isNotSetBit(g_iBitUserConnect, pId))
        return HC_CONTINUE;
    if(isNotSetBit(g_iBitUserAlive, pId))
        setBit(g_iBitUserAlive, pId);
   
    if(!g_pEntity[pId])
    {
        new pEnt = rg_create_entity("info_target", .useHashTable = false)
       
        if(!pEnt)
            abort(AMX_ERR_GENERAL, "Can't create entity")
   
        setBit(g_iBitUserEffected, pId);
        set_entvar(pEnt, var_classname, ESP_CLASSNAME);
       
        engfunc(EngFunc_SetSize, pEnt, Float:{-1.0, -1.0, -1.0}, Float:{1.0, 1.0, 1.0});
        engfunc(EngFunc_SetOrigin, pEnt, Float:{4095.0, 4095.0, 4095.0});
        engfunc(EngFunc_SetModel, pEnt, SPRITE);
        set_entvar(pEnt, var_owner, pId);
        set_entvar(pEnt, var_effects, get_entvar(pEnt, var_effects) | EF_FORCEVISIBILITY);
       
        g_pEntity[pId] = pEnt
    }
    return HC_CONTINUE;
}

public HC_CBasePlayer_PlayerKilled_Post(iVictim, iKiller)
{
    if(isNotSetBit(g_iBitUserAlive, iVictim)) return;
    clearBit(g_iBitUserAlive, iVictim);
    RemoveEntity(iVictim);
}

public RemoveEntity(pPlayer)
{
    if(!isSetBit(g_iBitUserEffected, pPlayer))
        return
    clearBit(g_iBitUserEffected, pPlayer)
    if(g_pEntity[pPlayer])
    {
        set_entvar(g_pEntity[pPlayer], var_flags, FL_KILLME)
        g_pEntity[pPlayer] = 0
    }
}

public OnCheckVisibility_Pre(pEnt, pset) {
    if(is_nullent(pEnt) || !FClassnameIs(pEnt, ESP_CLASSNAME))
    {
        return FMRES_IGNORED
    }

    forward_return(FMV_CELL, 1)
    return FMRES_SUPERCEDE
}

public OnAddToFullPack_Post(es, e, ent, host, flags, player, pSet)
{
    if(player || !pev_valid(ent)) {
        return FMRES_IGNORED
    }

    new pOwner = get_entvar(ent, var_owner)

    if(
        !IsPlayer(pOwner) || !g_pEntity[pOwner] || g_pEntity[pOwner] != ent || (ViewMode == 0 && g_iUserTeam[pOwner] == g_iUserTeam[host]) ||
        isNotSetBit(g_iBitUserAlive, pOwner) || isSetBit(g_iBitUserAlive, host) || isNotSetBit(g_iBitUserVision, host) || pOwner == host
        )
    {
        return FMRES_IGNORED
    }

    new Float:fStartPos[XYZ],
        Float:endPosition[XYZ],
        Float:fEnd[XYZ],
        Float:fVector[XYZ],
        Float:fEndPosition[XYZ],
        Float:fEndVector[XYZ],
        Float:fLenNew,
        Float:fLenOld;

    func_GetStartPos(host, fStartPos)
    func_GetEndPos(pOwner, endPosition)
    func_GetVector(endPosition, fStartPos, fVector)

    func_TraceLine(fStartPos, endPosition, fEnd, host)

    movePosition(fEnd, fVector, fEndPosition)

    func_GetEndVector(fStartPos, fEndPosition, fEndVector)

    fLenNew    = xs_vec_len(fEndVector)
    fLenOld    = xs_vec_len(fVector)

    set_es(es, ES_Origin, fEndPosition)
    set_es(es, ES_Scale, fLenNew / fLenOld)

    return FMRES_HANDLED
}

public event_TeamInfo()
{
    enum
    {
        arg_player = 1,
        arg_team
    }

    new szNewTeam[2];
    read_data(arg_team, szNewTeam, charsmax(szNewTeam))

    g_iUserTeam[ read_data(arg_player) ] = szNewTeam[0]
   
}

func_GetStartPos(pPlayer, Float:fStartPos[XYZ])
{
    new Float:fOrigin[XYZ],    Float:fView[XYZ]
    get_entvar(pPlayer, var_origin, fOrigin)
    get_entvar(pPlayer, var_view_ofs, fView)
    xs_vec_add(fOrigin, fView, fStartPos)
}

func_GetEndPos(pPlayer, Float:endPosition[XYZ])
{
    get_entvar(pPlayer, var_origin, endPosition)
}

func_TraceLine(Float:startPosition[XYZ], Float:endPosition[XYZ], Float:fEnd[XYZ], idSkip)
{
    new hTraceHandle = create_tr2()
    engfunc(EngFunc_TraceLine, startPosition, endPosition, IGNORE_MONSTERS, idSkip, hTraceHandle)
    get_tr2(hTraceHandle, TR_vecEndPos, fEnd)
    free_tr2(hTraceHandle)
}

func_GetVector(Float:startPosition[XYZ] , Float:endPosition[XYZ] , Float:fVector[XYZ] )
{
    xs_vec_sub(endPosition, startPosition, fVector)
}

movePosition(Float:fPosition[XYZ], Float:fVector[XYZ], Float:fEndPosition[XYZ])
{
    new Float:fVectorCopy[XYZ]
    xs_vec_copy(fVector, fVectorCopy)
    xs_vec_normalize(fVectorCopy, fVectorCopy)
    xs_vec_mul_scalar(fVectorCopy, DISTANCE_BASE, fVectorCopy)
    xs_vec_add(fPosition, fVectorCopy, fEndPosition)
}

func_GetEndVector(Float:startPosition[XYZ], Float: fEnd[XYZ], Float: fEndVector[XYZ])
{
    xs_vec_sub(fEnd, startPosition, fEndVector)
}
 
Сверху Снизу