├── gamedata └── FixLagCompensation.games.txt └── scripting └── FixLagCompensation.sp /gamedata/FixLagCompensation.games.txt: -------------------------------------------------------------------------------- 1 | "Games" 2 | { 3 | "cstrike" 4 | { 5 | "Offsets" 6 | { 7 | "IsMoving" 8 | { 9 | "windows" "74" 10 | "linux" "75" 11 | } 12 | } 13 | 14 | "Signatures" 15 | { 16 | "CLagCompensationManager::BacktrackPlayer" 17 | { 18 | "library" "server" 19 | "linux" "@_ZN23CLagCompensationManager15BacktrackPlayerEP11CBasePlayerf" 20 | } 21 | } 22 | 23 | "Functions" 24 | { 25 | "CLagCompensationManager__BacktrackPlayer" 26 | { 27 | "signature" "CLagCompensationManager::BacktrackPlayer" 28 | "callconv" "thiscall" 29 | "return" "void" 30 | "this" "ignore" 31 | "arguments" 32 | { 33 | "pPlayer" 34 | { 35 | "type" "cbaseentity" 36 | } 37 | "flTargetTime" 38 | { 39 | "type" "float" 40 | } 41 | } 42 | } 43 | } 44 | } 45 | "csgo" 46 | { 47 | "Offsets" 48 | { 49 | "IsMoving" 50 | { 51 | "windows" "80" // \x55\x8B\xEC\x83\xEC\x0C\x8B\x01\x8D\x55\xF4\x6A\x00 52 | "linux" "81" 53 | } 54 | } 55 | 56 | "Signatures" 57 | { 58 | "CLagCompensationManager::BacktrackEntity" 59 | { 60 | "library" "server" 61 | "linux" "\x55\x89\xE5\x57\x56\x53\x81\xEC\xEC\x00\x00\x00\x8B\x45\x20\x8B\x5D\x14" 62 | "windows" "\x55\x8B\xEC\x83\xE4\xF8\x81\xEC\xDC\x00\x00\x00\x89\x4C\x24\x18" 63 | } 64 | } 65 | 66 | "Functions" 67 | { 68 | "CLagCompensationManager__BacktrackEntity" 69 | { 70 | "signature" "CLagCompensationManager::BacktrackEntity" 71 | "callconv" "thiscall" 72 | "return" "bool" 73 | "this" "ignore" 74 | "arguments" 75 | { 76 | "entity" 77 | { 78 | "type" "cbaseentity" 79 | } 80 | "flTargetTime" 81 | { 82 | "type" "float" 83 | "windows" 84 | { 85 | "register" "xmm2" 86 | } 87 | } 88 | "track" 89 | { 90 | "type" "objectptr" 91 | } 92 | "restore" 93 | { 94 | "type" "objectptr" 95 | } 96 | "change" 97 | { 98 | "type" "objectptr" 99 | } 100 | "wantsAnims" 101 | { 102 | "type" "bool" 103 | } 104 | } 105 | } 106 | } 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /scripting/FixLagCompensation.sp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #pragma semicolon 1 7 | #pragma newdecls required 8 | 9 | public Plugin myinfo = 10 | { 11 | name = "FixLagCompensation", 12 | author = "BotoX + xen(CS:GO support)", 13 | description = "Disable player hitbox lag compensation when on moving objects", 14 | version = "1.0", 15 | url = "" 16 | }; 17 | 18 | Handle g_hBacktrackPlayer; 19 | Handle g_hBacktrackEntity; 20 | Handle g_hIsMoving; 21 | 22 | public void OnPluginStart() 23 | { 24 | Handle hGameData = LoadGameConfigFile("FixLagCompensation.games"); 25 | if(!hGameData) 26 | SetFailState("Failed to load FixLagCompensation gamedata."); 27 | 28 | if (GetEngineVersion() != Engine_CSGO) 29 | { 30 | // void CLagCompensationManager::BacktrackPlayer( CBasePlayer *pPlayer, float flTargetTime ) 31 | g_hBacktrackPlayer = DHookCreateFromConf(hGameData, "CLagCompensationManager__BacktrackPlayer"); 32 | if(!g_hBacktrackPlayer) 33 | { 34 | delete hGameData; 35 | SetFailState("Failed to setup detour for CLagCompensationManager__BacktrackPlayer"); 36 | } 37 | 38 | if(!DHookEnableDetour(g_hBacktrackPlayer, false, Detour_OnBacktrackPlayer)) 39 | { 40 | delete hGameData; 41 | SetFailState("Failed to detour CLagCompensationManager__BacktrackPlayer."); 42 | } 43 | } 44 | else 45 | { 46 | // bool CLagCompensationManager::BacktrackEntity( CBaseEntity *entity, float flTargetTime, LagRecordList *track, LagRecord *restore, LagRecord *change, bool wantsAnims ) 47 | g_hBacktrackEntity = DHookCreateFromConf(hGameData, "CLagCompensationManager__BacktrackEntity"); 48 | if(!g_hBacktrackEntity) 49 | { 50 | delete hGameData; 51 | SetFailState("Failed to setup detour for CLagCompensationManager__BacktrackEntity"); 52 | } 53 | 54 | if(!DHookEnableDetour(g_hBacktrackEntity, false, Detour_OnBacktrackEntity)) 55 | { 56 | delete hGameData; 57 | SetFailState("Failed to detour CLagCompensationManager__BacktrackEntity."); 58 | } 59 | } 60 | 61 | // CBaseEntity::IsMoving 62 | StartPrepSDKCall(SDKCall_Entity); 63 | if(!PrepSDKCall_SetFromConf(hGameData, SDKConf_Virtual, "IsMoving")) 64 | { 65 | delete hGameData; 66 | SetFailState("PrepSDKCall_SetFromConf(hGameData, SDKConf_Virtual, \"IsMoving\") failed!"); 67 | } 68 | PrepSDKCall_SetReturnInfo(SDKType_Bool, SDKPass_Plain); 69 | g_hIsMoving = EndPrepSDKCall(); 70 | 71 | delete hGameData; 72 | } 73 | 74 | // CS:S 75 | public MRESReturn Detour_OnBacktrackPlayer(Handle hParams) 76 | { 77 | if(DHookIsNullParam(hParams, 1)) 78 | return MRES_Ignored; 79 | 80 | int client = DHookGetParam(hParams, 1); 81 | if(client < 1 || client > MaxClients) 82 | return MRES_Ignored; 83 | 84 | int GroundEntity = GetEntPropEnt(client, Prop_Data, "m_hGroundEntity"); 85 | if(GroundEntity <= 0) 86 | return MRES_Ignored; 87 | 88 | bool bIsMoving = SDKCall(g_hIsMoving, GroundEntity); 89 | 90 | if(bIsMoving) 91 | return MRES_Supercede; 92 | 93 | return MRES_Ignored; 94 | } 95 | 96 | // CS:GO 97 | public MRESReturn Detour_OnBacktrackEntity(Handle hReturn, Handle hParams) 98 | { 99 | if(DHookIsNullParam(hParams, 1)) 100 | return MRES_Ignored; 101 | 102 | int client = DHookGetParam(hParams, 1); 103 | if(client < 1 || client > MaxClients) 104 | return MRES_Ignored; 105 | 106 | int GroundEntity = GetEntPropEnt(client, Prop_Data, "m_hGroundEntity"); 107 | if(GroundEntity <= 0) 108 | return MRES_Ignored; 109 | 110 | bool bIsMoving = SDKCall(g_hIsMoving, GroundEntity); 111 | 112 | if(bIsMoving) 113 | { 114 | DHookSetReturn(hReturn, false); 115 | return MRES_Supercede; 116 | } 117 | 118 | return MRES_Ignored; 119 | } 120 | --------------------------------------------------------------------------------