AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   pingfaker.amxx not working (https://forums.alliedmods.net/showthread.php?t=95261)

HLM 06-21-2009 19:34

pingfaker.amxx not working
 
info:
server is running TFC

Code:

L 06/21/2009 - 23:30:33: Start of error session.
L 06/21/2009 - 23:30:33: Info (map "shortbus3") (file "addons/amxmodx/logs/error_20090621.log")
L 06/21/2009 - 23:30:33: Invalid event (name "HLTV") (plugin "pingfaker.amxx")
L 06/21/2009 - 23:30:33: [AMXX] Displaying debug trace (plugin "pingfaker.amxx")
L 06/21/2009 - 23:30:33: [AMXX] Run time error 10: native error (native "register_event")
L 06/21/2009 - 23:30:33: [AMXX]    [0] 38903.attach::plugin_init (line 131)


just say if you need more info... but im pretty sure you wont, other than the fact that my provider is gameservers.com and that I dont run hltv

Exolent[jNr] 06-21-2009 19:36

Re: pingfaker.amxx not working
 
Show the register_event() line.

HLM 06-21-2009 20:10

Re: pingfaker.amxx not working
 
PHP Code:

public plugin_init()
{
    
register_plugin("Ping Faker""1.4""MeRcyLeZZ")
    
    
cvar_enable register_cvar("pingfake_enable""1")
    
cvar_ping register_cvar("pingfake_ping""1337")
    
cvar_flux register_cvar("pingfake_flux""0")
    
cvar_target register_cvar("pingfake_target""1")
    
cvar_flags register_cvar("pingfake_flags""")
    
cvar_bots register_cvar("pingfake_bots""0")
    
cvar_multiplier register_cvar("pingfake_multiplier""0.0")
    
cvar_showactivity get_cvar_pointer("amx_show_activity")
    
    
g_maxplayers get_maxplayers()
    
    
register_event("HLTV""event_round_start""a""1=0""2=0")
    
register_forward(FM_UpdateClientData"fw_UpdateClientData")
    
    
register_concmd("amx_fakeping""cmd_fakeping"ADMIN_KICK"<target> <ping> - Toggle fake ping override on player (-1 to disable)")
    
    
g_loaded_authid ArrayCreate(321)
    
g_loaded_ping ArrayCreate(11)
    
    
load_pings_from_file()


line 131 is
PHP Code:

register_event("HLTV""event_round_start""a""1=0""2=0"

im sorry I forgot the original, here it is

PHP Code:

/*================================================================================
    
    ----------------------
    -*- Ping Faker 1.4 -*-
    ----------------------
    
    ~~~~~~~~~~~~~~~
    - Description -
    ~~~~~~~~~~~~~~~
    
    This plugin can fake the display of a player's latency (ping) shown on
    the scoreboard. Unlike the "fakelag" command, it does not affect the
    player's real latency in any way.
    
    You can have all players report the same ping, or only fake it for those
    who have a specific admin flag. This last feature is especially useful
    when running a dedicated server from your own computer, when you don't
    want people to guess you're an admin/owner by looking at your low ping.
    
    ~~~~~~~~~
    - CVARS -
    ~~~~~~~~~
    
    * pingfake_enable [0/1] - Enable/disable ping faking
    * pingfake_ping [1337] - The ping you want displayed (min: 0 // max: 4095)
    * pingfake_flux [0] - Fake ping fluctuation amount (0 = none)
    * pingfake_target [0/1] - Whether to display fake ping to its target too
    * pingfake_flags [""] - Affect players with these flags only (empty = all)
    * pingfake_bots [0/1/2] - Affect bots too (set to 2 for bots ONLY setting)
    * pingfake_multiplier [0.0] // Set this to have the fake ping be a multiple
       of the player's real ping instead of fixed values (0.0 = disabled)
    
    Note: changes to these will take effect after a new round.
    
    ~~~~~~~~~~~~
    - Commands -
    ~~~~~~~~~~~~
    
    * amx_fakeping <target> <ping>
       - Toggle fake ping override for player (use -1 to disable)
    
    You can also have players automatically get fake pings by editing the
    "fakepings.ini" file in your configs folder.
    
    ~~~~~~~~
    - ToDo -
    ~~~~~~~~
    
    * Find out exactly what the arguments for the SVC_PINGS message mean, so
       as to send a single message with all pings on it and reduce bandwidth
       usage (does the HLSDK say anything about those?)
    
    ~~~~~~~~~~~~~~~~~~~
    - Developer Notes -
    ~~~~~~~~~~~~~~~~~~~
    
    The SVC_PINGS message can't be intercepted by Metamod/AMXX (it is purely
    handled by the engine) so the only way to supercede it is to send our own
    custom message right after the original is fired. This works as long as
    the custom message is parsed AFTER the original. To achieve this here, we
    send it as an unreliable message (cl_messages 1 helps see arrival order).
    
    The next difficulty is in figuring out what the message arguments are.
    For this I did some trial and error until I finally got it working, though
    in a really odd way. I also can't seem to send all of the pings in a single
    message without getting weird results or triggering heaps of message
    parsing errors (namely svc_bad).
    
    A final consideration is bandwidth usage. I found out (with cl_shownet 1)
    the packet size increases by 102 bytes when the original SVC_PINGS message
    is sent for 32 players. Sending our own message right after means the size
    will grow even larger, so we should only send the message when absolutely
    needed. In this case that's once every client data update (any less often
    than that and the ping wasn't properly overridden sometimes).
    
    ~~~~~~~~~~~~~
    - Changelog -
    ~~~~~~~~~~~~~
    
    * v1.0: (Feb 23, 2009)
       - Public release
    
    * v1.1: (Feb 23, 2009)
       - Managed to send up to 3 pings on a single message,
          thus reducing bandwidth usage by 26%
    
    * v1.2: (Feb 23, 2009)
       - Added fake ping fluctuation and affect bots settings
    
    * v1.2a: (Feb 24, 2009)
       - Fixed is_user_bot flag not being reset on disconnect
    
    * v1.3: (Feb 24, 2009)
       - Added admin command to manually toggle fake ping for players
       - Added feature to automatically load fake pings from file
    
    * v1.4: (Mar 15, 2009)
       - Added feature (+CVAR) to have the fake ping be a multiple
          of the player's real ping
    
=================================================================================*/

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>

new const FAKEPINGS_FILE[] = "fakepings.ini"
const TASK_ARGUMENTS 100

new cvar_enablecvar_pingcvar_fluxcvar_targetcvar_flagscvar_botscvar_multiplier
new g_enableg_pingg_fluxg_targetg_flagsg_botsFloat:g_multiplierg_maxplayers
new g_connected[33], g_isbot[33], g_offset[33][2], g_argping[33][3], g_hasflags[33]
new 
g_loaded_countercvar_showactivityg_pingoverride[33] = { -1, ... }
new Array:
g_loaded_authid, Array:g_loaded_ping

public plugin_init()
{
    
register_plugin("Ping Faker""1.4""MeRcyLeZZ")
    
    
cvar_enable register_cvar("pingfake_enable""1")
    
cvar_ping register_cvar("pingfake_ping""1337")
    
cvar_flux register_cvar("pingfake_flux""0")
    
cvar_target register_cvar("pingfake_target""1")
    
cvar_flags register_cvar("pingfake_flags""")
    
cvar_bots register_cvar("pingfake_bots""0")
    
cvar_multiplier register_cvar("pingfake_multiplier""0.0")
    
cvar_showactivity get_cvar_pointer("amx_show_activity")
    
    
g_maxplayers get_maxplayers()
    
    
register_event("HLTV""event_round_start""a""1=0""2=0")
    
register_forward(FM_UpdateClientData"fw_UpdateClientData")
    
    
register_concmd("amx_fakeping""cmd_fakeping"ADMIN_KICK"<target> <ping> - Toggle fake ping override on player (-1 to disable)")
    
    
g_loaded_authid ArrayCreate(321)
    
g_loaded_ping ArrayCreate(11)
    
    
load_pings_from_file()
}

public 
plugin_cfg()
{
    
// Cache CVARs after configs are loaded
    
set_task(0.5"event_round_start")
}

public 
event_round_start()
{
    
// Cache CVAR values
    
g_ping get_pcvar_num(cvar_ping)
    
g_flux abs(get_pcvar_num(cvar_flux))
    
g_target get_pcvar_num(cvar_target)
    
g_enable get_pcvar_num(cvar_enable)
    
g_bots get_pcvar_num(cvar_bots)
    
g_multiplier get_pcvar_float(cvar_multiplier)
    
    
// Calculate weird argument values based on target ping
    
calculate_arguments()
    
    
// Calculate them regularly if also faking ping fluctuations or if faking a multiple of the real ping
    
remove_task(TASK_ARGUMENTS)
    if (
g_flux || g_multiplier 0.0set_task(2.0"calculate_arguments"TASK_ARGUMENTS__"b")
    
    
// Cache flags
    
new flags[6]
    
get_pcvar_string(cvar_flagsflagssizeof flags 1)
    
g_flags read_flags(flags)
    
    
// Check flags again for all players
    
for (new id 1id <= g_maxplayersid++)
        if (
g_connected[id]) check_flags(id)
}

public 
client_authorized(id)
{
    
check_for_loaded_pings(id)
    
check_flags(id)
}

public 
client_infochanged(id)
{
    
check_flags(id)
}

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

public 
client_disconnect(id)
{
    
g_connected[id] = false
    g_isbot
[id] = false
    g_pingoverride
[id] = -1
    g_hasflags
[id] = 0
}

public 
fw_UpdateClientData(id)
{
    
// Ping faking disabled?
    
if (!g_enable) return;
    
    
// Scoreboard key being pressed?
    
if (!(pev(idpev_button) & IN_SCORE) && !(pev(idpev_oldbuttons) & IN_SCORE))
        return;
    
    
// Send fake player's pings
    
static playersending
    sending 
0
    
for (player 1player <= g_maxplayersplayer++)
    {
        
// Player not in game?
        
if (!g_connected[player])
             continue;
        
        
// Fake latency for its target too?
        
if (!g_target && id == player)
            continue;
        
        
// Only do these checks if not overriding ping for player
        
if (g_pingoverride[player] < 0)
        {
            
// Is this a bot?
            
if (g_isbot[player])
            {
                
// Bots setting disabled?
                
if (!g_bots) continue;
            }
            else
            {
                
// Bots only setting?
                
if (g_bots == 2) continue;
                
                
// Need to have specific flags?
                
if (g_flags && !(g_hasflags[player]))
                    continue;
            }
        }
        
        
// 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[player][0] * 64) + (* (player 1)))
                
write_short(g_argping[player][0])
                
sending++
            }
            case 
1:
            {
                
// Append additional data
                
write_byte((g_offset[player][1] * 128) + (* (player 1)))
                
write_short(g_argping[player][1])
                
sending++
            }
            case 
2:
            {
                
// Append additional data and end message
                
write_byte((* (player 1)))
                
write_short(g_argping[player][2])
                
write_byte(0)
                
message_end()
                
sending 0
            
}
        }
    }
    
    
// End message if not yet sent
    
if (sending)
    {
        
write_byte(0)
        
message_end()
    }
}

public 
cmd_fakeping(idlevelcid)
{
    
// Check for access flag
    
if (!cmd_access(idlevelcid3))
        return 
PLUGIN_HANDLED;
    
    
// Retrieve arguments
    
static arg[32], playerping
    read_argv
(1argsizeof arg 1)
    
player cmd_target(idargCMDTARGET_ALLOW_SELF)
    
read_argv(2argsizeof arg 1)
    
ping str_to_num(arg)
    
    
// Invalid target
    
if (!player) return PLUGIN_HANDLED;
    
    
// Update ping overrides for player
    
g_pingoverride[player] = min(ping4095)
    
calculate_arguments()
    
    
// Get player's name for displaying/logging activity
    
static name1[32], name2[32]
    
get_user_name(idname1sizeof name1 1)
    
get_user_name(playername2sizeof name2 1)
    
    
// Negative value means disable fakeping
    
if (ping 0)
    {
        
// Show activity?
        
switch (get_pcvar_num(cvar_showactivity))
        {
            case 
1client_print(0print_chat"ADMIN - fake ping override disabled on %s"name2)
            case 
2client_print(0print_chat"ADMIN %s - fake ping override disabled on %s"name1name2)
        }
        
        
// Log activity
        
static logdata[100], authid[32], ip[16]
        
get_user_authid(idauthidsizeof authid 1)
        
get_user_ip(idipsizeof ip 11)
        
formatex(logdatasizeof logdata 1"ADMIN %s <%s><%s> - fake ping override disabled on %s"name1authidipname2)
        
log_amx(logdata)
    }
    else
    {
        
// Show activity?
        
switch (get_pcvar_num(cvar_showactivity))
        {
            case 
1client_print(0print_chat"ADMIN - fake ping override of %d enabled on %s"pingname2)
            case 
2client_print(0print_chat"ADMIN %s - fake ping override of %d enabled on %s"name1pingname2)
        }
        
        
// Log activity
        
static logdata[100], authid[32], ip[16]
        
get_user_authid(idauthidsizeof authid 1)
        
get_user_ip(idipsizeof ip 11)
        
formatex(logdatasizeof logdata 1"ADMIN %s <%s><%s> - fake ping override of %d enabled on %s"name1authidippingname2)
        
log_amx(logdata)
    }
    
    return 
PLUGIN_HANDLED;
}

public 
calculate_arguments()
{
    static 
playerpingloss
    
for (player 1player <= g_maxplayersplayer++)
    {
        
// Calculate target ping (clamp if out of bounds)
        
if (g_pingoverride[player] < 0)
        {
            if (
g_multiplier 0.0)
            {
                
get_user_ping(playerpingloss)
                
ping clamp(floatround(ping g_multiplier), 04095)
            }
            else
                
ping clamp(g_ping random_num(-g_fluxg_flux), 04095)
        }
        else
            
ping g_pingoverride[player]
        
        
// First argument's ping
        
for (g_offset[player][0] = 0g_offset[player][0] < 4g_offset[player][0]++)
        {
            if ((
ping g_offset[player][0]) % == 0)
            {
                
g_argping[player][0] = (ping g_offset[player][0]) / 4
                
break;
            }
        }
        
// Second argument's ping
        
for (g_offset[player][1] = 0g_offset[player][1] < 2g_offset[player][1]++)
        {
            if ((
ping g_offset[player][1]) % == 0)
            {
                
g_argping[player][1] = (ping g_offset[player][1]) / 2
                
break;
            }
        }
        
// Third argument's ping
        
g_argping[player][2] = ping
    
}
}

load_pings_from_file()
{
    
// Build file path
    
new path[64]
    
get_configsdir(pathsizeof path 1)
    
format(pathsizeof path 1"%s/%s"pathFAKEPINGS_FILE)
    
    
// File not present, skip loading
    
if (!file_exists(path)) return;
    
    
// Open file for reading
    
new linedata[40], authid[32], ping[8], file fopen(path"rt")
    
    while (
file && !feof(file))
    {
        
// Read one line at a time
        
fgets(filelinedatasizeof linedata 1)
        
        
// Replace newlines with a null character to prevent headaches
        
replace(linedatasizeof linedata 1"^n""")
        
        
// Blank line or comment
        
if (!linedata[0] || linedata[0] == ';') continue;
        
        
// Get authid and ping
        
strbreak(linedataauthidsizeof authid 1pingsizeof ping -1)
        
remove_quotes(ping)
        
        
// Store data into global arrays
        
ArrayPushString(g_loaded_authidauthid)
        
ArrayPushCell(g_loaded_pingclamp(str_to_num(ping), 04095))
        
        
// Increase loaded data counter
        
g_loaded_counter++
    }
    if (
filefclose(file)
}

check_for_loaded_pings(id)
{
    
// Nothing to check for
    
if (g_loaded_counter <= 0) return;
    
    
// Get steamid and ip
    
static authid[32], ip[16], ibuffer[32]
    
get_user_authid(idauthidsizeof authid 1)
    
get_user_ip(idipsizeof ip 11)
    
    for (
0g_loaded_counteri++)
    {
        
// Retrieve authid
        
ArrayGetString(g_loaded_authidibuffersizeof buffer 1)
        
        
// Compare it with this player's steamid and ip
        
if (equali(bufferauthid) || equal(bufferip))
        {
            
// We've got a match!
            
g_pingoverride[id] = ArrayGetCell(g_loaded_pingi)
            
calculate_arguments()
            break;
        }
    }
}

check_flags(id)
{
    
g_hasflags[id] = get_user_flags(id) & g_flags




All times are GMT -4. The time now is 15:44.

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