Добавить проверку на админа

Сообщения
460
Реакции
68
Помог
7 раз(а)
Всем привет форумчане помогите пожалуйста в данном плагине добавить проверку на админа с флагом а , в авто спекторах. Скрипт я перевёл на русский для удобства а проверку на админа не могу сделать не хватает навычок скриптинга(((
Код:
#include <amxmodx>
#include <amxmisc>
#include <reapi>

#pragma semicolon 1

// You can comment out something to take off the restriction.
#define LOCK_SAY                    // Запретить использовать чат невидимому зрителю.
#define AUTO_INVISIBLE_SPECTATOR    //Когда кто-либо становится зрителем, делать его невидимым автоматически.

new HookChain:g_hSV_WriteFullClientUpdate;
new bool:g_bPlayerInVisible[MAX_CLIENTS + 1];

public plugin_init()
{
    register_plugin("Invisible Spectator", "1.0", "ReHLDS Team");

    if (!is_rehlds())
    {
        pause("ad");
        set_fail_state("This plugin is not available, ReHLDS required.");
        return;
    }

#if defined LOCK_SAY
    register_clcmd("say", "Host_Say");
    register_clcmd("say_team", "Host_Say");
#endif

#if defined AUTO_INVISIBLE_SPECTATOR
    register_event("TeamInfo", "Event_TeamInfo", "a", "2=TERRORIST", "2=CT", "2=SPECTATOR");
#else
    register_event("TeamInfo", "Event_TeamInfo", "a", "2=TERRORIST", "2=CT");
    register_clcmd("amx_spec", "ClCmd_Spectate", ADMIN_IMMUNITY, "Makes the spectator invisible.");
#endif

    DisableHookChain((g_hSV_WriteFullClientUpdate = RegisterHookChain(RH_SV_WriteFullClientUpdate, "SV_WriteFullClientUpdate")));
}

public SV_WriteFullClientUpdate(const id, buffer, const receiver)
{
    if (g_bPlayerInVisible[id])
    {
        set_key_value(buffer, "", "");
        //set_key_value(buffer, "name",  "");
        //set_key_value(buffer, "model", "");
        //set_key_value(buffer, "*sid",  "");
    }
}

public client_putinserver(id)
{
    g_bPlayerInVisible[id] = false;
}

public Event_TeamInfo()
{
    new id = read_data(1);

#if defined AUTO_INVISIBLE_SPECTATOR
    new bool:bState = g_bPlayerInVisible[id];

    new szTeamName[2];
    read_data(2, szTeamName, charsmax(szTeamName));
    switch (szTeamName[0])
    {
        case 'C', 'T':
        {
            // Reset the invisible state
            g_bPlayerInVisible[id] = false;
        }
        case 'S':
        {
            g_bPlayerInVisible[id] = true;
        }
    }

    if (g_bPlayerInVisible[id] != bState)
    {
        if (!TryDisableHookChain())
        {
            // let's me enable to hookchain, true optimization
            EnableHookChain(g_hSV_WriteFullClientUpdate);
        }
#else
    if (g_bPlayerInVisible[id])
    {
        // Reset the invisible state
        g_bPlayerInVisible[id] = false;
#endif
        // Force update user info
        rh_update_user_info(id);
    }
}

#if defined LOCK_SAY
public Host_Say(id)
{
    if (g_bPlayerInVisible[id])
    {
        client_print(id, print_chat, "Теперь вас не видно в спекторах!");
        return PLUGIN_HANDLED_MAIN;
    }

    return PLUGIN_CONTINUE;
}
#endif

#if !defined AUTO_INVISIBLE_SPECTATOR
public ClCmd_Spectate(id, level, cid)
{
    if (!cmd_access(id, level, cid, 0))
        return PLUGIN_CONTINUE;

    // Only spectator can be invisible
    if (get_member(id, m_iTeam) != TEAM_SPECTATOR)
    {
        client_print(id, print_chat, "Чтоб бить не видимым вам нужно сначала перейти в спектаторы.");
        return PLUGIN_HANDLED;
    }

    g_bPlayerInVisible[id] ^= true;
    client_print(id, print_chat, "Теперь вы %s.", g_bPlayerInVisible[id] ? "Невидимы" : "Видимы");

    if (!TryDisableHookChain())
    {
        // let's me enable to hookchain, true optimization
        EnableHookChain(g_hSV_WriteFullClientUpdate);
    }

    rh_update_user_info(id);
    return PLUGIN_HANDLED;
}
#endif

stock bool:TryDisableHookChain()
{
    // Make sure that there no one uses invisible spectator
    new iPlayers[MAX_CLIENTS], iNum, nCount;
    get_players(iPlayers, iNum, "ch");
    for (new i = 0; i < iNum; ++i)
    {
        if (g_bPlayerInVisible[iPlayers[i]])
            ++nCount;
    }

    if (nCount <= 0)
    {
        DisableHookChain(g_hSV_WriteFullClientUpdate);
        return true;
    }

    return false;
}

#if defined client_disconnected
public client_disconnected(id)
#else
public client_disconnect(id)
#endif
{
    if (g_bPlayerInVisible[id])
    {
        g_bPlayerInVisible[id] = false;
        TryDisableHookChain();
    }
}
Я знаю что нужно влепить что то в этот кусок кода
PHP:
#if defined AUTO_INVISIBLE_SPECTATOR
    new bool:bState = g_bPlayerInVisible[id];

    new szTeamName[2];
    read_data(2, szTeamName, charsmax(szTeamName));
    switch (szTeamName[0])
    {
        case 'C', 'T':
        {
            // Reset the invisible state
            g_bPlayerInVisible[id] = false;
        }
        case 'S':
        {
            g_bPlayerInVisible[id] = true;
        }
    }

    if (g_bPlayerInVisible[id] != bState)
    {
        if (!TryDisableHookChain())
        {
            // let's me enable to hookchain, true optimization
            EnableHookChain(g_hSV_WriteFullClientUpdate);
        }
но не знаю что именно и куда. Будте добры помогите. Заранее благодарствую.
 
Сообщения
1,419
Реакции
2,510
Помог
59 раз(а)
После new id = read_data(1); можете попробовать так:
if(~get_user_flags(id) & ADMIN_IMMUNITY) return PLUGIN_CONTINUE;
 
Последнее редактирование:
Сообщения
460
Реакции
68
Помог
7 раз(а)
w0w, спасибо большое попробую отпишу.
21 Апр 2018
w0w, смотрите сделал так
PHP:
public Event_TeamInfo()
{
    new id = read_data(1);
    
    if(~get_user_flags(id) & ADMIN_IMMUNITY)
    return PLUGIN_CONTINUE;

#if defined AUTO_INVISIBLE_SPECTATOR
Всё работает исправно спасибо большое но вот такая ошибка есть


1524313139065.png
21 Апр 2018
w0w, это не критично?
 
Сообщения
460
Реакции
68
Помог
7 раз(а)
Ребята не получается хоть убейте. Та же ошибка.
21 Апр 2018
Должна быть #pragma tabsize 1 ?? или 4
 
Сообщения
2,723
Реакции
2,997
Помог
60 раз(а)
Сообщения
460
Реакции
68
Помог
7 раз(а)
wopox1337,
PHP:
#include <amxmodx>
#include <amxmisc>
#include <reapi>

#pragma semicolon 1
#pragma tabsize 1

// You can comment out something to take off the restriction.
#define LOCK_SAY                    // Запретить использовать чат невидимому зрителю.
#define AUTO_INVISIBLE_SPECTATOR    //Когда кто-либо становится зрителем, делать его невидимым автоматически.

new HookChain:g_hSV_WriteFullClientUpdate;
new bool:g_bPlayerInVisible[MAX_CLIENTS + 1];

public plugin_init()
{
    register_plugin("Invisible Spectator", "1.0", "ReHLDS Team");

    if (!is_rehlds())
    {
        pause("ad");
        set_fail_state("This plugin is not available, ReHLDS required.");
        return;
    }

#if defined LOCK_SAY
    register_clcmd("say", "Host_Say");
    register_clcmd("say_team", "Host_Say");
#endif

#if defined AUTO_INVISIBLE_SPECTATOR
    register_event("TeamInfo", "Event_TeamInfo", "a", "2=TERRORIST", "2=CT", "2=SPECTATOR");
#else
    register_event("TeamInfo", "Event_TeamInfo", "a", "2=TERRORIST", "2=CT");
    register_clcmd("amx_spec", "ClCmd_Spectate", ADMIN_IMMUNITY, "Makes the spectator invisible.");
#endif

    DisableHookChain((g_hSV_WriteFullClientUpdate = RegisterHookChain(RH_SV_WriteFullClientUpdate, "SV_WriteFullClientUpdate")));
}

public SV_WriteFullClientUpdate(const id, buffer, const receiver)
{
    if (g_bPlayerInVisible[id])
    {
        set_key_value(buffer, "", "");
        //set_key_value(buffer, "name",  "");
        //set_key_value(buffer, "model", "");
        //set_key_value(buffer, "*sid",  "");
    }
}

public client_putinserver(id)
{
    g_bPlayerInVisible[id] = false;
}

public Event_TeamInfo()
{
    new id = read_data(1);
    
    if(~get_user_flags(id) & ADMIN_IMMUNITY)

    return PLUGIN_CONTINUE;

#if defined AUTO_INVISIBLE_SPECTATOR
    new bool:bState = g_bPlayerInVisible[id];

    new szTeamName[2];
    read_data(2, szTeamName, charsmax(szTeamName));
    switch (szTeamName[0])
    {
        case 'C', 'T':
        {
            // Reset the invisible state
            g_bPlayerInVisible[id] = false;
        }
        case 'S':
        {
            g_bPlayerInVisible[id] = true;
        }
    }

    if (g_bPlayerInVisible[id] != bState)
    {
        if (!TryDisableHookChain())
        {
            // let's me enable to hookchain, true optimization
            EnableHookChain(g_hSV_WriteFullClientUpdate);
            
        }
#else
    if (g_bPlayerInVisible[id])
    {
        // Reset the invisible state
        g_bPlayerInVisible[id] = false;
#endif
        // Force update user info
        rh_update_user_info(id);
        
    }
}

#if defined LOCK_SAY
public Host_Say(id)
{
    if (g_bPlayerInVisible[id])
    {
        client_print(id, print_chat, "Теперь вас не видно в спекторах!");
        return PLUGIN_HANDLED_MAIN;
    }

    return PLUGIN_CONTINUE;
}
#endif

#if !defined AUTO_INVISIBLE_SPECTATOR
public ClCmd_Spectate(id, level, cid)
{
    if (!cmd_access(id, level, cid, 0))
        return PLUGIN_CONTINUE;

    // Only spectator can be invisible
    if (get_member(id, m_iTeam) != TEAM_SPECTATOR)
    {
        client_print(id, print_chat, "Чтоб бить не видимым вам нужно сначала перейти в спектаторы.");
        return PLUGIN_HANDLED;
    }

    g_bPlayerInVisible[id] ^= true;
    client_print(id, print_chat, "Теперь вы %s.", g_bPlayerInVisible[id] ? "Невидимы" : "Видимы");

    if (!TryDisableHookChain())
    {
        // let's me enable to hookchain, true optimization
        EnableHookChain(g_hSV_WriteFullClientUpdate);
    }

    rh_update_user_info(id);
    return PLUGIN_HANDLED;
}
#endif

stock bool:TryDisableHookChain()
{
    // Make sure that there no one uses invisible spectator
    new iPlayers[MAX_CLIENTS], iNum, nCount;
    get_players(iPlayers, iNum, "ch");
    for (new i = 0; i < iNum; ++i)
    {
        if (g_bPlayerInVisible[iPlayers[i]])
            ++nCount;
    }

    if (nCount <= 0)
    {
        DisableHookChain(g_hSV_WriteFullClientUpdate);
        return true;
    }

    return false;
}

#if defined client_disconnected
public client_disconnected(id)
#else
public client_disconnect(id)
#endif
{
    if (g_bPlayerInVisible[id])
    {
        g_bPlayerInVisible[id] = false;
        TryDisableHookChain();
    }
}
если я там что то наворотил ток не смейтесь я ток учусь)))
21 Апр 2018
может просто надо было поставить #pragma warning
 
Сообщения
1,419
Реакции
2,510
Помог
59 раз(а)
Best777, уберите #pragma tabsize 1 и в спойлере одно из решений.
Код:
public Event_TeamInfo()
{
    new id = read_data(1);

    if(~get_user_flags(id) & ADMIN_IMMUNITY)
        return PLUGIN_CONTINUE;

#if defined AUTO_INVISIBLE_SPECTATOR
    new bool:bState = g_bPlayerInVisible[id];

    new szTeamName[2];
    read_data(2, szTeamName, charsmax(szTeamName));
    switch (szTeamName[0])
    {
        case 'C', 'T':
        {
            // Reset the invisible state
            g_bPlayerInVisible[id] = false;
        }
        case 'S':
        {
            g_bPlayerInVisible[id] = true;
        }
    }

    if (g_bPlayerInVisible[id] != bState)
    {
        if (!TryDisableHookChain())
        {
            // let's me enable to hookchain, true optimization
            EnableHookChain(g_hSV_WriteFullClientUpdate);
        }
#else
    if (g_bPlayerInVisible[id])
    {
        // Reset the invisible state
        g_bPlayerInVisible[id] = false;
#endif
        // Force update user info
        rh_update_user_info(id);
    }

    return PLUGIN_CONTINUE;
}
 
Сообщения
460
Реакции
68
Помог
7 раз(а)
w0w, спасибо вам большое всё получилось. Можно закрыть.
Очень полезный плагин для отлова недобросовестных игроков.
 
Сообщения
2,143
Реакции
1,223
Помог
44 раз(а)
w0w, и то, и то подойдет.

После new id = read_data(1); можете попробовать так:
if(~get_user_flags(id) & ADMIN_IMMUNITY) return PLUGIN_CONTINUE;
В этом случае я хотел написать, что будет ошибка при таком возврате, но как-то поленился.
 

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу