From cea1b849650ae56b214e33d6f0e4f213cb574f2a Mon Sep 17 00:00:00 2001 From: BotoX Date: Sun, 8 May 2016 03:10:25 +0200 Subject: [PATCH] fixed trigger OnStartTouch/OnEndTouch bug caused by TeleportEntity fixed reloading zombiereloaded plugin reset player velocity on respawn (high speed in spec -> zspawn) --- .../sourcemod/gamedata/zombiereloaded.txt | 14 ++++++++++ src/zombiereloaded.sp | 28 +++++++++++++++++++ src/zr/respawn.inc | 4 +++ src/zr/tools.inc | 19 +++++++++++++ src/zr/tools_functions.inc | 5 +++- 5 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 cstrike/addons/sourcemod/gamedata/zombiereloaded.txt diff --git a/cstrike/addons/sourcemod/gamedata/zombiereloaded.txt b/cstrike/addons/sourcemod/gamedata/zombiereloaded.txt new file mode 100644 index 0000000..591e1a8 --- /dev/null +++ b/cstrike/addons/sourcemod/gamedata/zombiereloaded.txt @@ -0,0 +1,14 @@ +"Games" +{ + "cstrike" + { + "Signatures" + { + "CBaseEntity_SetAbsVelocity" + { + "library" "server" + "linux" "@_ZN11CBaseEntity14SetAbsVelocityERK6Vector" + } + } + } +} diff --git a/src/zombiereloaded.sp b/src/zombiereloaded.sp index be3e2d1..8502a71 100644 --- a/src/zombiereloaded.sp +++ b/src/zombiereloaded.sp @@ -121,6 +121,8 @@ #include "zr/api/api" +new bool:g_bLate = false; + /** * Record plugin info. */ @@ -151,6 +153,8 @@ public APLRes:AskPluginLoad2(Handle:myself, bool:late, String:error[], err_max) // Register library RegPluginLibrary("zombiereloaded"); + g_bLate = late; + // Let plugin load. return APLRes_Success; } @@ -257,6 +261,30 @@ public OnConfigsExecuted() // Forward event to modules. (OnModulesLoaded) ConfigOnModulesLoaded(); ClassOnModulesLoaded(); + + if(g_bLate) + { + for(new client = 1; client <= MaxClients; client++) + { + if(!IsClientConnected(client)) + continue; + + OnClientConnected(client); + + if(IsClientInGame(client)) + { + OnClientPutInServer(client); + + if(IsClientAuthorized(client)) + OnClientPostAdminCheck(client); + } + + if(AreClientCookiesCached(client)) + OnClientCookiesCached(client); + } + + g_bLate = false; + } } /** diff --git a/src/zr/respawn.inc b/src/zr/respawn.inc index 01165ab..4176749 100644 --- a/src/zr/respawn.inc +++ b/src/zr/respawn.inc @@ -183,6 +183,10 @@ bool:RespawnSpawnClient(client, bool:zombie = false, bool:zombieIfSuicide = fals // Spawn player. CS_RespawnPlayer(client); + // Reset player velocity + float fResetVelocity[3] = {0.0, 0.0, 0.0}; + TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, fResetVelocity); + // Check if first zombie has spawned. if (InfectHasZombieSpawned()) { diff --git a/src/zr/tools.inc b/src/zr/tools.inc index f70f321..26021d1 100644 --- a/src/zr/tools.inc +++ b/src/zr/tools.inc @@ -33,6 +33,7 @@ new g_iToolsLMV; new g_iToolsHasNightVision; new g_iToolsNightVisionOn; new g_iToolsFOV; +new Handle:g_hToolsSetAbsVelocity = INVALID_HANDLE; /** * @endsection @@ -90,6 +91,24 @@ ToolsFindOffsets() LogEvent(false, LogType_Fatal, LOG_CORE_EVENTS, LogModule_Tools, "Offsets", "Offset \"CBasePlayer::m_iFOV\" was not found."); } + // void CBaseEntity::SetAbsVelocity( const Vector &vecAbsVelocity ) + Handle hGameConf = LoadGameConfigFile("zombiereloaded"); + if (hGameConf != INVALID_HANDLE) + { + StartPrepSDKCall(SDKCall_Player); + if (PrepSDKCall_SetFromConf(hGameConf, SDKConf_Signature, "CBaseEntity_SetAbsVelocity")) + { + PrepSDKCall_AddParameter(SDKType_Vector, SDKPass_ByRef); + g_hToolsSetAbsVelocity = EndPrepSDKCall(); + } + else + LogEvent(false, LogType_Error, LOG_CORE_EVENTS, LogModule_Tools, "Offsets", "SDKCall \"CBaseEntity::SetAbsVelocity\" was not found."); + + CloseHandle(hGameConf); + } + else + LogEvent(false, LogType_Error, LOG_CORE_EVENTS, LogModule_Tools, "Offsets", "Couldn't load zombiereloaded game config!"); + // Forward event to modules. WeaponsOnOffsetsFound(); AccountOnOffsetsFound(); diff --git a/src/zr/tools_functions.inc b/src/zr/tools_functions.inc index e525ac6..79b5b68 100644 --- a/src/zr/tools_functions.inc +++ b/src/zr/tools_functions.inc @@ -64,7 +64,10 @@ stock ToolsClientVelocity(client, Float:vecVelocity[3], bool:apply = true, bool: } // Apply velocity on client. - TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, vecVelocity); + if(g_hToolsSetAbsVelocity == INVALID_HANDLE) // Fallback to old one + TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, vecVelocity); + else // Fixes trigger OnStartTouch/OnEndTouch bug + SDKCall(g_hToolsSetAbsVelocity, client, vecVelocity); } /**