Decompiled "Ping Faker"

Shadowless

Пользователь
Регистрация
24 Фев 2019
Сообщения
237
Симпатии
4
Пол
Мужской
помогите сделать .sma file :)

C++:
#pragma semicolon 1
#pragma ctrlchar '\'

new g_cvar_ping;
new g_cvar_flux;
new g_max_players;
new g_ping;
new g_flux;
new g_off_set[33][2];
new g_argument[33][3];
new g_over_ride[33] =
{
    -1, ...
}

public plugin_init()
{
    register_plugin("Ping Faker", "1.0", "AMXX Dev Team");
    register_forward(FM_UpdateClientData, "fm_update_client_data", 0);
    g_cvar_ping = register_cvar("pf_ping", "12", 0, 0.00);
    g_cvar_flux = register_cvar("pf_flux", "4", 0, 0.00);
    g_max_players = get_maxplayers();
    return 0;
}

public plugin_cfg()
{
    set_task(0.50, "plugin_read", 3426422, "", 0, "", 0);
    return 0;
}

public plugin_read()
{
    g_ping = clamp(get_pcvar_num(g_cvar_ping), 0, 4095);
    g_flux = clamp(get_pcvar_num(g_cvar_flux), 0, 4095);
    set_task(2.00, "plugin_check", 4235621, "", 0, "b", 0);
    return 0;
}

public client_disconnect(id)
{
    g_over_ride[id] = -1;
    return 0;
}

public fm_update_client_data(id)
{
    !!! Removed Phi
    if (!pev(id, pev_button) & 32768 && !pev(id, pev_oldbuttons) & 32768)
    {
        return 0;
    }
    static sending;
    static player;
    sending = 0;
    player = 1;
    while (player <= g_max_players)
    {
        if (is_user_connected(player))
        {
            switch (sending)
            {
                case 0:
                {
                    message_begin(MSG_ONE_UNRELIABLE, SVC_PINGS, 1488, id);
                    write_byte(player + -1 * 2 + 1 + g_off_set[player][0][0][0] * 64);
                    write_short(g_argument[player][0][0][0]);
                    sending += 1;
                }
                case 1:
                {
                    write_byte(player + -1 * 4 + 2 + g_off_set[player][0][0][1] * 128);
                    write_short(g_argument[player][0][0][1]);
                    sending += 1;
                }
                case 2:
                {
                    write_byte(player + -1 * 8 + 4);
                    write_short(g_argument[player][0][0][2]);
                    write_byte(0);
                    message_end();
                    sending = 0;
                }
                default:
                {
                }
            }
        }
        player += 1;
    }
    if (sending)
    {
        write_byte(0);
        message_end();
    }
    return 0;
}


/ * ERROR! Unrecognized opcode: neg * /
function "plugin_check"
public plugin_check()
 

Вложения

Vaqtincha

aggressive
Разработчик
Скриптер
Регистрация
28 Янв 2018
Сообщения
963
Симпатии
685
Пол
Мужской
зачем декомпилить ? в ынете навалом юзай поиск.
 

Shadowless

Пользователь
Регистрация
24 Фев 2019
Сообщения
237
Симпатии
4
Пол
Мужской
C++:
/**
 * MeRcyLeZZ. It's his code, but without waste
**/

#include <amxmodx>
#include <fakemeta>

#define CheckFlag(%1,%2)  (%1 &   (1 << (%2 & 31)))
#define SetFlag(%1,%2)    (%1 |=  (1 << (%2 & 31)))
#define ClearFlag(%1,%2)  (%1 &= ~(1 << (%2 & 31)))

#define PING_MILTIPLIER 25            // Сколько процентов от реального пинга отображать  [По умолчанию: 25%]

#define TASK_ARGUMENTS 100

new g_argping[33], g_pingoverride[33] = { -1, ... }

new g_maxplayers, isUserConnect

public plugin_init()
{
    register_plugin("Fake Ping", "1.1", "MeRcyLeZZ/gyxoBka")
    register_forward(FM_UpdateClientData, "fw_UpdateClientData")
    register_event("DeathMsg", "fix_fake_pings", "a")
    register_event("TeamInfo", "fix_fake_pings", "a")
    
    g_maxplayers = get_maxplayers()
    
    set_task(2.0, "calculate_arguments", TASK_ARGUMENTS, _, _, "b")
}

public client_putinserver(id)
{
    SetFlag( isUserConnect, id );
}

#if AMXX_VERSION_NUM < 183
public client_disconnect(id)
#else
public client_disconnected(id)
#endif
{
    ClearFlag( isUserConnect, id );
    g_pingoverride[id] = -1
}   

public fix_fake_pings()
{
    static player
    for (player = 1; player <= g_maxplayers; player++)
    {
        // Player not in game?
        if (!CheckFlag( isUserConnect, player ))
             continue;
        
        // Resend fake pings
        fw_UpdateClientData(player)
    }
}

public calculate_arguments()
{
    static player, ping, loss
    for (player = 1; player <= g_maxplayers; player++)
    {
        // Calculate target ping (clamp if out of bounds)
        if (g_pingoverride[player] < 0)
        {
            get_user_ping(player, ping, loss)
            g_argping[player] = clamp(floatround(ping * 0.PING_MILTIPLIER), 0, 4095)
        }
        else
            g_argping[player] = g_pingoverride[player]
    }
}

public fw_UpdateClientData(id)
{
    // Scoreboard key being pressed?
    if (!(pev(id, pev_button) & IN_SCORE) && !(pev(id, pev_oldbuttons) & IN_SCORE))
        return;
    
    // Send fake player's pings
    static player, sending, bits, bits_added
    sending = false
    bits = 0
    bits_added = 0
    
    for (player = 1; player <= g_maxplayers; player++)
    {
        // Player not in game?
        if (!CheckFlag( isUserConnect, id ))
             continue;

        // Start message
        if (!sending)
        {
            message_begin(MSG_ONE_UNRELIABLE, SVC_PINGS, _, id)
            sending = true
        }
        
        // Add bits for this player
        AddBits(bits, bits_added, 1, 1) // flag = 1
        AddBits(bits, bits_added, player-1, 5) // player-1 since HL uses ids 0-31
        AddBits(bits, bits_added, g_argping[player], 12) // ping
        AddBits(bits, bits_added, 0, 7) // loss
        
        // Write group of 8 bits (bytes)
        WriteBytes(bits, bits_added, false)
    }
    
    // End message
    if (sending)
    {
        // Add empty bit at the end
        AddBits(bits, bits_added, 0, 1) // flag = 0
        
        // Write remaining bits
        WriteBytes(bits, bits_added, true)
        
        message_end()
    }
}

AddBits(&bits, &bits_added, value, bit_count)
{
    // No more room (max 32 bits / 1 cell)
    if (bit_count > (32 - bits_added) || bit_count < 1)
        return;
    
    // Clamp value if its too high
    if (value >= (1 << bit_count))
        value = ((1 << bit_count) - 1)
    
    // Add new bits
    bits = bits + (value << bits_added)
    // Increase bits added counter
    bits_added += bit_count
}

WriteBytes(&bits, &bits_added, write_remaining)
{
    // Keep looping if there are more bytes to write
    while (bits_added >= 8)
    {
        // Write group of 8 bits
        write_byte(bits & ((1 << 8) - 1))
        
        // Remove bits we just sent by moving all bits to the right 8 times
        bits = bits >> 8
        bits_added -= 8
    }
    
    // Write remaining bits too?
    if (write_remaining && bits_added > 0)
    {
        write_byte(bits)
        bits = 0
        bits_added = 0
    }
}
 
Сверху Снизу