From 50997f9f032d21a6f2086d1c975ebc19352293b9 Mon Sep 17 00:00:00 2001 From: RD42 <42702181+dashr9230@users.noreply.github.com> Date: Sun, 15 Sep 2024 23:22:20 +0800 Subject: [PATCH] [server] Implement/match `n_SetSpawnInfo(...)` --- server/player.h | 14 ++++++++++++-- server/scrcustom.cpp | 31 +++++++++++++++++++++++++++++-- 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/server/player.h b/server/player.h index 89ab1a9..5d5c0dd 100644 --- a/server/player.h +++ b/server/player.h @@ -5,7 +5,13 @@ #pragma pack(1) typedef struct _PLAYER_SPAWN_INFO { - char _pad0[46]; + BYTE byteTeam; + int iSkin; + BYTE field_5; + VECTOR vecPos; + float fRotation; + int iSpawnWeapons[3]; + int iSpawnWeaponsAmmo[3]; } PLAYER_SPAWN_INFO; //---------------------------------------------------- @@ -16,7 +22,11 @@ class CPlayer public: // Size: 11486 - char _pad0[11261]; + char _pad0[10509]; + + BOOL field_290D; + + char _pad2911[748]; PLAYER_SPAWN_INFO m_SpawnInfo; BOOL m_bHasSpawnInfo; diff --git a/server/scrcustom.cpp b/server/scrcustom.cpp index fbd47cd..ef3a93b 100644 --- a/server/scrcustom.cpp +++ b/server/scrcustom.cpp @@ -826,8 +826,35 @@ static cell AMX_NATIVE_CALL n_NetStats_GetIpPort(AMX *amx, cell *params) static cell AMX_NATIVE_CALL n_SetSpawnInfo(AMX *amx, cell *params) { - // TODO: SetSpawnInfo - return 0; + CPlayerPool *pPlayerPool = pNetGame->GetPlayerPool(); + if(!pPlayerPool) return 0; + + CPlayer *pPlayer = pPlayerPool->GetAt((PLAYERID)params[1]); + if (pPlayer) + { + PLAYER_SPAWN_INFO SpawnInfo; + SpawnInfo.byteTeam = (BYTE)params[2]; + SpawnInfo.iSkin = (int)params[3]; + SpawnInfo.vecPos.X = amx_ctof(params[4]); + SpawnInfo.vecPos.Y = amx_ctof(params[5]); + SpawnInfo.vecPos.Z = amx_ctof(params[6]); + SpawnInfo.fRotation = amx_ctof(params[7]); + SpawnInfo.iSpawnWeapons[0] = (int)params[8]; + SpawnInfo.iSpawnWeaponsAmmo[0] = (int)params[9]; + SpawnInfo.iSpawnWeapons[1] = (int)params[10]; + SpawnInfo.iSpawnWeaponsAmmo[1] = (int)params[11]; + SpawnInfo.iSpawnWeapons[2] = (int)params[12]; + SpawnInfo.iSpawnWeaponsAmmo[2] = (int)params[13]; + + pPlayer->SetSpawnInfo(&SpawnInfo); + pPlayer->field_290D = TRUE; + RakNet::BitStream bsData; + bsData.Write((PCHAR)&SpawnInfo, sizeof(PLAYER_SPAWN_INFO)); + pNetGame->SendToPlayer(RPC_ScrSetSpawnInfo, &bsData, (PLAYERID)params[1], 2); + return 1; + } else { + return 0; + } } static cell AMX_NATIVE_CALL n_SpawnPlayer(AMX *amx, cell *params)