Thread: Ping Faker 1.5
View Single Post
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-23-2009 , 11:44   Re: Ping Faker
Reply With Quote #11

I've been looking for something like this for a long time since I run bots on my server. I through this together real fast to see if it would work. It will make only bots appear to have a realistic ping. I'm sure it can be optimized but it's a start.

PHP Code:
#include <amxmodx>
#include <fakemeta>

new  g_offset[2], g_ping[3]
new 
g_maxplayersg_connected[33]

public 
plugin_init()
{
    
register_plugin("Bot Ping Faker""1.1""MeRcyLeZZ\bugsy")

    
g_maxplayers get_maxplayers()
    
    
register_forward(FM_UpdateClientData"fw_UpdateClientData")
}

public 
client_putinserver(id)
{
    
g_connected[id] = true
}

public 
client_disconnect(id)
{
    
g_connected[id] = false
}

public 
fw_UpdateClientData(id)
{
    
// Scoreboard key being pressed?
    
if (!(pev(idpev_button) & IN_SCORE) && !(pev(idpev_oldbuttons) & IN_SCORE))
        return;
    
    static 
playersendingping
    sending 
0
    
    
for (player 1player <= g_maxplayersplayer++)
    {
        if (!
g_connected[player] || !is_user_bot(player))
             continue;
 
        
//make each players ping vary a bit
        
switch( player )
        {
            case 
1,2,3,4ping random_num1535)
            case 
5,6,7,8ping random_num(4060)
            case 
9,10,11,12ping random_num6080)
            case 
13,14,15,16ping random_num75100)
            case 
17,18,19,20ping random_num7090)
            case 
21,22,23,24ping random_num5080)
            case 
25,26,27,28ping random_num2040)
            default: 
ping random_num4565)
        }
        
        
// Calculate weird argument values based on target ping
        // -> first ping
        
for (g_offset[0] = 0g_offset[0] < 4g_offset[0]++)
        {
            if ((
ping g_offset[0]) % == 0)
            {
                
g_ping[0] = (ping g_offset[0]) / 4
                
break;
            }
        }
        
// -> second ping
        
for (g_offset[1] = 0g_offset[1] < 2g_offset[1]++)
        {
            if ((
ping g_offset[1]) % == 0)
            {
                
g_ping[1] = (ping g_offset[1]) / 2
                
break;
            }
        }
        
        
// -> third ping
        
g_ping[2] = ping
        
        
// Send message with the weird arguments
        
switch (sending)
        {
            case 
0:
            {
                
// Start a new message
                
message_begin(MSG_ONE_UNRELIABLESVC_PINGS_id)
                
write_byte((g_offset[0] * 64) + ((player) - 1))
                
write_short(g_ping[0])
                
sending++
            }
            case 
1:
            {
                
// Append additional data
                
write_byte((g_offset[1] * 128) + (* (player 1)))
                
write_short(g_ping[1])
                
sending++
            }
            case 
2:
            {
                
// Append additional data and end message
                
write_byte((* (player 1)))
                
write_short(g_ping[2])
                
write_byte(0)
                
message_end()
                
sending 0
            
}
        }
    }
    
    
// End message if not yet sent
    
if (sending)
    {
        
write_byte(0)
        
message_end()
    }

__________________
Bugsy is offline