CS服务器伪造ping值插件源码 [转DE]

社区服务
高级搜索
猴岛论坛CSGO反恐精英CS服务器伪造ping值插件源码 [转DE]
发帖 回复
倒序阅读 最近浏览的帖子最近浏览的版块
2个回复

CS服务器伪造ping值插件源码 [转DE]

楼层直达
乀︶FireWolF 〆

ZxID:4938

等级: 少将
举报 只看楼主 使用道具 楼主   发表于: 2012-08-06 0
/*================================================================================

        

        ----------------------

        -*- Ping Faker 1.0 -*-

        ----------------------

        

        ~~~~~~~~~~~~~~~

        - 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 [1/0] - Enable/disable ping faking

        * pingfake_ping [1337] - The ping you want displayed (min: 0 // max: 4095)

        * pingfake_flags [""] - Affect players with these flags only (empty = all)

        * pingfake_target [1/0] - Whether to display fake ping to its target too

        

        Note: changes to these will take effect after a new round.

        

        ~~~~~~~~

        - 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 more than one ping on the

        same 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

        

=================================================================================*/



#include <amxmodx>

#include <fakemeta>



new cvar_enable, cvar_ping, cvar_flags, cvar_target

new g_enable, g_offset, g_ping, g_flags, g_target

new g_maxplayers, g_connected[33]



public plugin_init()

{

        register_plugin("Ping Faker", "1.0", "MeRcyLeZZ")

        

        cvar_enable = register_cvar("pingfake_enable", "1")

        cvar_ping = register_cvar("pingfake_ping", "1")

        cvar_flags = register_cvar("pingfake_flags", "")

        cvar_target = register_cvar("pingfake_target", "1")

        g_maxplayers = get_maxplayers()

        

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

        register_forward(FM_UpdateClientData, "fw_UpdateClientData")

        

        set_task(1.0, "event_round_start")

}



public event_round_start()

{

        // Cache CVAR values

        g_enable = get_pcvar_num(cvar_enable)

        g_ping = clamp(get_pcvar_num(cvar_ping), 0, 4095)

        g_target = get_pcvar_num(cvar_target)

        

        // Calculate weird argument values based on target ping

        for (g_offset = 0; g_offset <= 3; g_offset++)

        {

                if ((g_ping - g_offset) % 4 == 0)

                {

                        g_ping = (g_ping - g_offset) / 4

                        break;

                }

        }

        

        // Cache flags

        new flags[6]

        get_pcvar_string(cvar_flags, flags, sizeof flags - 1)

        g_flags = read_flags(flags)

}



public client_putinserver(id)

{

        g_connected[id] = true

}



public client_disconnect(id)

{

        g_connected[id] = false

}



public fw_UpdateClientData(id)

{

        // Ping faking disabled?

        if (!g_enable) return;

        

        // 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

        for (player = 1; player <= g_maxplayers; player++)

        {

                // Player not in game?

                if (!g_connected[player])

                         continue;

                

                // Fake latency for its target too?

                if (!g_target && id == player)

                        continue;

                

                // Need to have specific flags?

                if (g_flags && !(get_user_flags(player) & g_flags))

                        continue;

                

                // Send message with the weird arguments

                message_begin(MSG_ONE_UNRELIABLE, SVC_PINGS, _, id)

                write_byte((g_offset*64) + (2*player-1))

                write_short(g_ping)

                write_byte(0)

                message_end()

        }

}
本帖de评分: 1 条评分 DB +10
DB+10 2012-08-06

精品文章

SVGTEAM、亡灵战线 <a href="www.svgteam.com" >亡灵战线</a>
一纸荒年Avaん、

ZxID:16558760

等级: 元老
困瓶困君换我永生无邪

举报 只看该作者 沙发   发表于: 2012-08-06 0
谢谢分享

楼主留言:

嘿嘿~最近时间好少、、




如果你的帖子
   几乎都会出现某人的身影

                那么    请你珍惜Ta
泽 

ZxID:15747326

等级: 元老
配偶: 彩 
   彩,你在哪里..      

举报 只看该作者 板凳   发表于: 2012-08-06 0
好吧,看不懂
有三种人,我们不要去打扰他:
1.没有梦想的人我们不要打扰他
2.借口太多的人我们不要打扰他
3.没有主见的人我们不要打扰他
« 返回列表
发帖 回复