mirror of
https://github.com/dashr9230/SA-MP.git
synced 2025-07-18 17:38:12 +08:00
[saco] Implement/match ScrSetPlayerName(...)
This commit is contained in:
@ -33,12 +33,14 @@ typedef struct _GAME_SETTINGS {
|
||||
|
||||
#include "../raknet/RakClientInterface.h"
|
||||
#include "../raknet/RakNetworkFactory.h"
|
||||
#include "../raknet/BitStream.h"
|
||||
#include "../raknet/PacketEnumerations.h"
|
||||
#include "../raknet/SAMPRPC.h"
|
||||
#include "../raknet/GetTime.h"
|
||||
|
||||
#include "net/localplayer.h"
|
||||
#include "net/remoteplayer.h"
|
||||
#include "net/netplayer.h"
|
||||
#include "net/netrpc.h"
|
||||
#include "net/actorpool.h"
|
||||
#include "net/playerpool.h"
|
||||
|
2
saco/net/netplayer.cpp
Normal file
2
saco/net/netplayer.cpp
Normal file
@ -0,0 +1,2 @@
|
||||
|
||||
|
20
saco/net/netplayer.h
Normal file
20
saco/net/netplayer.h
Normal file
@ -0,0 +1,20 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
//----------------------------------------------------
|
||||
|
||||
class CNetPlayer
|
||||
{
|
||||
public:
|
||||
//char _gap0[48];
|
||||
char _gap0[4];
|
||||
int field_4;
|
||||
BOOL m_bIsNPC;
|
||||
int field_C;
|
||||
CRemotePlayer *m_pRemotePlayer;
|
||||
std::string m_PlayerName;
|
||||
};
|
||||
|
||||
//----------------------------------------------------
|
@ -7,7 +7,7 @@ CPlayerPool::CPlayerPool()
|
||||
{
|
||||
// loop through and initialize all net players to null and slot states to false
|
||||
for(PLAYERID playerId = 0; playerId < MAX_PLAYERS; playerId++) {
|
||||
field_1F8A[playerId] = 0;
|
||||
m_pPlayers[playerId] = NULL;
|
||||
field_2A[playerId] = 0;
|
||||
}
|
||||
m_pLocalPlayer = new CLocalPlayer();
|
||||
|
@ -17,11 +17,20 @@ private:
|
||||
|
||||
char _gapFDA[4016];
|
||||
|
||||
int field_1F8A[MAX_PLAYERS];
|
||||
CNetPlayer *m_pPlayers[MAX_PLAYERS];
|
||||
int field_2F3A;
|
||||
|
||||
public:
|
||||
|
||||
void SetLocalPlayerName(PCHAR szName) { field_6 = szName; };
|
||||
PCHAR GetLocalPlayerName() { return (PCHAR)field_6.c_str(); };
|
||||
void SetPlayerName(PLAYERID playerId, PCHAR szName) {
|
||||
if(playerId > MAX_PLAYERS) return;
|
||||
CNetPlayer* pPlayer = m_pPlayers[playerId];
|
||||
if(!pPlayer) return;
|
||||
pPlayer->m_PlayerName = szName;
|
||||
}
|
||||
|
||||
CLocalPlayer * GetLocalPlayer() { return m_pLocalPlayer; };
|
||||
|
||||
CPlayerPool();
|
||||
|
@ -60,7 +60,6 @@ void ScrUnk70(RPCParameters *rpcParams) {}
|
||||
void ScrSetSpawnInfo(RPCParameters *rpcParams) {}
|
||||
void ScrUnk45(RPCParameters *rpcParams) {}
|
||||
void ScrUnk99(RPCParameters *rpcParams) {}
|
||||
void ScrUnk0B(RPCParameters *rpcParams) {}
|
||||
void ScrSetPlayerPos(RPCParameters *rpcParams) {}
|
||||
void ScrUnk0D(RPCParameters *rpcParams) {}
|
||||
void ScrUnk0E(RPCParameters *rpcParams) {}
|
||||
@ -108,6 +107,40 @@ void ScrHideMenu(RPCParameters *rpcParams) {}
|
||||
|
||||
//----------------------------------------------------
|
||||
|
||||
void ScrSetPlayerName(RPCParameters *rpcParams)
|
||||
{
|
||||
PCHAR Data = reinterpret_cast<PCHAR>(rpcParams->input);
|
||||
int iBitLength = rpcParams->numberOfBitsOfData;
|
||||
PlayerID sender = rpcParams->sender;
|
||||
|
||||
PLAYERID playerId;
|
||||
BYTE byteNickLen;
|
||||
char szNewName[MAX_PLAYER_NAME+1];
|
||||
BYTE byteSuccess;
|
||||
|
||||
RakNet::BitStream bsData(Data,(iBitLength/8)+1,false);
|
||||
|
||||
CPlayerPool *pPlayerPool = pNetGame->GetPlayerPool();
|
||||
|
||||
bsData.Read(playerId);
|
||||
bsData.Read(byteNickLen);
|
||||
|
||||
if(byteNickLen > MAX_PLAYER_NAME) return;
|
||||
|
||||
bsData.Read(szNewName, byteNickLen);
|
||||
bsData.Read(byteSuccess);
|
||||
|
||||
szNewName[byteNickLen] = '\0';
|
||||
|
||||
if (byteSuccess == 1) pPlayerPool->SetPlayerName(playerId, szNewName);
|
||||
|
||||
// Extra addition which we need to do if this is the local player;
|
||||
if( pPlayerPool->GetLocalPlayerID() == playerId )
|
||||
pPlayerPool->SetLocalPlayerName( szNewName );
|
||||
}
|
||||
|
||||
//----------------------------------------------------
|
||||
|
||||
void ScrSetCameraPos(RPCParameters *rpcParams)
|
||||
{
|
||||
PCHAR Data = reinterpret_cast<PCHAR>(rpcParams->input);
|
||||
@ -205,7 +238,7 @@ void RegisterScriptRPCs(RakClientInterface* pRakClient)
|
||||
REGISTER_STATIC_RPC(pRakClient, ScrSetSpawnInfo);
|
||||
REGISTER_STATIC_RPC(pRakClient, ScrUnk45);
|
||||
REGISTER_STATIC_RPC(pRakClient, ScrUnk99);
|
||||
REGISTER_STATIC_RPC(pRakClient, ScrUnk0B);
|
||||
REGISTER_STATIC_RPC(pRakClient, ScrSetPlayerName);
|
||||
REGISTER_STATIC_RPC(pRakClient, ScrSetPlayerPos);
|
||||
REGISTER_STATIC_RPC(pRakClient, ScrUnk0D);
|
||||
REGISTER_STATIC_RPC(pRakClient, ScrUnk0E);
|
||||
@ -312,7 +345,7 @@ void UnRegisterScriptRPCs(RakClientInterface* pRakClient)
|
||||
UNREGISTER_STATIC_RPC(pRakClient, ScrUnk2B);
|
||||
UNREGISTER_STATIC_RPC(pRakClient, ScrSetSpawnInfo);
|
||||
UNREGISTER_STATIC_RPC(pRakClient, ScrUnk45);
|
||||
UNREGISTER_STATIC_RPC(pRakClient, ScrUnk0B);
|
||||
UNREGISTER_STATIC_RPC(pRakClient, ScrSetPlayerName);
|
||||
UNREGISTER_STATIC_RPC(pRakClient, ScrUnk99);
|
||||
UNREGISTER_STATIC_RPC(pRakClient, ScrSetPlayerPos);
|
||||
UNREGISTER_STATIC_RPC(pRakClient, ScrUnk0D);
|
||||
|
@ -317,6 +317,12 @@
|
||||
<File
|
||||
RelativePath=".\net\netgame.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\net\netplayer.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\net\netplayer.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\net\netrpc.cpp">
|
||||
</File>
|
||||
|
Reference in New Issue
Block a user