From 1ff45278eb1993ef72246035c94f30d93cdc4d72 Mon Sep 17 00:00:00 2001 From: RD42 <42702181+dashr9230@users.noreply.github.com> Date: Thu, 17 Oct 2024 17:25:56 +0800 Subject: [PATCH] [saco] Implement/match `ScrSetPlayerHealth(...)` --- raknet/SAMPRPC.h | 2 +- saco/net/scriptrpc.cpp | 22 +++++++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/raknet/SAMPRPC.h b/raknet/SAMPRPC.h index 2a06cda..24d8bf2 100644 --- a/raknet/SAMPRPC.h +++ b/raknet/SAMPRPC.h @@ -129,7 +129,7 @@ #define RPC_ScrSetPlayerName "\x0B" #define RPC_ScrSetPlayerPos "\x0C" #define RPC_ScrUnk0D "\x0D" -#define RPC_ScrUnk0E "\x0E" +#define RPC_ScrSetPlayerHealth "\x0E" #define RPC_ScrPutPlayerInVehicle "\x46" #define RPC_ScrRemovePlayerFromVehicle "\x47" #define RPC_ScrSetPlayerColor "\x48" diff --git a/saco/net/scriptrpc.cpp b/saco/net/scriptrpc.cpp index 308ea78..ad80e40 100644 --- a/saco/net/scriptrpc.cpp +++ b/saco/net/scriptrpc.cpp @@ -58,7 +58,6 @@ void ScrUnk45(RPCParameters *rpcParams) {} void ScrUnk99(RPCParameters *rpcParams) {} void ScrSetPlayerPos(RPCParameters *rpcParams) {} void ScrUnk0D(RPCParameters *rpcParams) {} -void ScrUnk0E(RPCParameters *rpcParams) {} void ScrPutPlayerInVehicle(RPCParameters *rpcParams) {} void ScrRemovePlayerFromVehicle(RPCParameters *rpcParams) {} void ScrSetPlayerColor(RPCParameters *rpcParams) {} @@ -135,6 +134,23 @@ void ScrSetPlayerName(RPCParameters *rpcParams) //---------------------------------------------------- +void ScrSetPlayerHealth(RPCParameters *rpcParams) +{ + PCHAR Data = reinterpret_cast(rpcParams->input); + int iBitLength = rpcParams->numberOfBitsOfData; + PlayerID sender = rpcParams->sender; + + CLocalPlayer *pLocalPlayer = pNetGame->GetPlayerPool()->GetLocalPlayer(); + float fHealth; + + RakNet::BitStream bsData(Data,(iBitLength/8)+1,false); + bsData.Read(fHealth); + + pLocalPlayer->GetPlayerPed()->SetHealth(fHealth); +} + +//---------------------------------------------------- + void ScrSetCameraPos(RPCParameters *rpcParams) { PCHAR Data = reinterpret_cast(rpcParams->input); @@ -312,7 +328,7 @@ void RegisterScriptRPCs(RakClientInterface* pRakClient) REGISTER_STATIC_RPC(pRakClient, ScrSetPlayerName); REGISTER_STATIC_RPC(pRakClient, ScrSetPlayerPos); REGISTER_STATIC_RPC(pRakClient, ScrUnk0D); - REGISTER_STATIC_RPC(pRakClient, ScrUnk0E); + REGISTER_STATIC_RPC(pRakClient, ScrSetPlayerHealth); REGISTER_STATIC_RPC(pRakClient, ScrPutPlayerInVehicle); REGISTER_STATIC_RPC(pRakClient, ScrRemovePlayerFromVehicle); REGISTER_STATIC_RPC(pRakClient, ScrSetPlayerColor); @@ -420,7 +436,7 @@ void UnRegisterScriptRPCs(RakClientInterface* pRakClient) UNREGISTER_STATIC_RPC(pRakClient, ScrUnk99); UNREGISTER_STATIC_RPC(pRakClient, ScrSetPlayerPos); UNREGISTER_STATIC_RPC(pRakClient, ScrUnk0D); - UNREGISTER_STATIC_RPC(pRakClient, ScrUnk0E); + UNREGISTER_STATIC_RPC(pRakClient, ScrSetPlayerHealth); UNREGISTER_STATIC_RPC(pRakClient, ScrPutPlayerInVehicle); UNREGISTER_STATIC_RPC(pRakClient, ScrRemovePlayerFromVehicle); UNREGISTER_STATIC_RPC(pRakClient, ScrSetPlayerColor);