[bot] Implement ConnectionRejected(...)

* Update SAMPRPC.h

* Update `RegisterRPCs(...)`

* Update `UnRegisterRPCs(...)`
This commit is contained in:
RD42 2024-06-01 19:43:12 +08:00
parent 72ab40c2e2
commit fc879a6fdc
3 changed files with 28 additions and 8 deletions

View File

@ -1,5 +1,10 @@
#include "../main.h" #include "../main.h"
using namespace RakNet;
#define REJECT_REASON_BAD_VERSION 1
#define REJECT_REASON_BAD_NICKNAME 2
#define REJECT_REASON_BAD_MOD 3
void EnterVehicle(RPCParameters *rpcParams) {} void EnterVehicle(RPCParameters *rpcParams) {}
void ExitVehicle(RPCParameters *rpcParams) {} void ExitVehicle(RPCParameters *rpcParams) {}
@ -24,9 +29,24 @@ void GameModeRestart(RPCParameters *rpcParams)
pNetGame->ShutdownForGameModeRestart(); pNetGame->ShutdownForGameModeRestart();
} }
void Unk82(RPCParameters *rpcParams) void ConnectionRejected(RPCParameters *rpcParams)
{ {
// TODO: Unk82 PCHAR Data = reinterpret_cast<PCHAR>(rpcParams->input);
int iBitLength = rpcParams->numberOfBitsOfData;
RakNet::BitStream bsData(Data,(iBitLength/8)+1,false);
BYTE byteRejectReason;
bsData.Read(byteRejectReason);
if(byteRejectReason==REJECT_REASON_BAD_VERSION) {
//logprintf("BOT: CONNECTION REJECTED. INCORRECT SA-MP VERSION!");
}
else if(byteRejectReason==REJECT_REASON_BAD_NICKNAME) {
//logprintf("BOT: CONNECTION REJECTED. BAD NICKNAME!");
}
pNetGame->GetRakClient()->Disconnect(500);
exit(1);
} }
void ClientMessage(RPCParameters *rpcParams) void ClientMessage(RPCParameters *rpcParams)
@ -111,7 +131,7 @@ void RegisterRPCs(RakClientInterface * pRakClient)
REGISTER_STATIC_RPC(pRakClient,UpdateScoresPingsIPs); REGISTER_STATIC_RPC(pRakClient,UpdateScoresPingsIPs);
REGISTER_STATIC_RPC(pRakClient,SvrStats); REGISTER_STATIC_RPC(pRakClient,SvrStats);
REGISTER_STATIC_RPC(pRakClient,GameModeRestart); REGISTER_STATIC_RPC(pRakClient,GameModeRestart);
REGISTER_STATIC_RPC(pRakClient,Unk82); REGISTER_STATIC_RPC(pRakClient,ConnectionRejected);
REGISTER_STATIC_RPC(pRakClient,ClientMessage); REGISTER_STATIC_RPC(pRakClient,ClientMessage);
REGISTER_STATIC_RPC(pRakClient,WorldTime); REGISTER_STATIC_RPC(pRakClient,WorldTime);
REGISTER_STATIC_RPC(pRakClient,Unk5F); REGISTER_STATIC_RPC(pRakClient,Unk5F);
@ -147,7 +167,7 @@ void UnRegisterRPCs(RakClientInterface * pRakClient)
UNREGISTER_STATIC_RPC(pRakClient,UpdateScoresPingsIPs); UNREGISTER_STATIC_RPC(pRakClient,UpdateScoresPingsIPs);
UNREGISTER_STATIC_RPC(pRakClient,SvrStats); UNREGISTER_STATIC_RPC(pRakClient,SvrStats);
UNREGISTER_STATIC_RPC(pRakClient,GameModeRestart); UNREGISTER_STATIC_RPC(pRakClient,GameModeRestart);
UNREGISTER_STATIC_RPC(pRakClient,Unk82); UNREGISTER_STATIC_RPC(pRakClient,ConnectionRejected);
UNREGISTER_STATIC_RPC(pRakClient,ClientMessage); UNREGISTER_STATIC_RPC(pRakClient,ClientMessage);
UNREGISTER_STATIC_RPC(pRakClient,WorldTime); UNREGISTER_STATIC_RPC(pRakClient,WorldTime);
UNREGISTER_STATIC_RPC(pRakClient,Unk5F); UNREGISTER_STATIC_RPC(pRakClient,Unk5F);

View File

@ -24,8 +24,8 @@
#define RPC_Unk27 "\x27" #define RPC_Unk27 "\x27"
#define RPC_UpdateScoresPingsIPs "\x9B" #define RPC_UpdateScoresPingsIPs "\x9B"
#define RPC_SvrStats "\x66" #define RPC_SvrStats "\x66"
#define RPC_Unk82 "\x82"
#define RPC_GameModeRestart "\x28" #define RPC_GameModeRestart "\x28"
#define RPC_ConnectionRejected "\x82"
#define RPC_ClientMessage "\x5D" #define RPC_ClientMessage "\x5D"
#define RPC_WorldTime "\x5E" #define RPC_WorldTime "\x5E"
#define RPC_Unk5F "\x5F" #define RPC_Unk5F "\x5F"

View File

@ -13,8 +13,8 @@ void Unk26(RPCParameters *rpcParams) {}
void Unk27(RPCParameters *rpcParams) {} void Unk27(RPCParameters *rpcParams) {}
void UpdateScoresPingsIPs(RPCParameters *rpcParams) {} void UpdateScoresPingsIPs(RPCParameters *rpcParams) {}
void SvrStats(RPCParameters *rpcParams) {} void SvrStats(RPCParameters *rpcParams) {}
void Unk82(RPCParameters *rpcParams) {}
void GameModeRestart(RPCParameters *rpcParams) {} void GameModeRestart(RPCParameters *rpcParams) {}
void ConnectionRejected(RPCParameters *rpcParams) {}
void ClientMessage(RPCParameters *rpcParams) {} void ClientMessage(RPCParameters *rpcParams) {}
void WorldTime(RPCParameters *rpcParams) {} void WorldTime(RPCParameters *rpcParams) {}
void Unk5F(RPCParameters *rpcParams) {} void Unk5F(RPCParameters *rpcParams) {}
@ -64,8 +64,8 @@ void RegisterRPCs(RakClientInterface * pRakClient)
REGISTER_STATIC_RPC(pRakClient,Unk27); REGISTER_STATIC_RPC(pRakClient,Unk27);
REGISTER_STATIC_RPC(pRakClient,UpdateScoresPingsIPs); REGISTER_STATIC_RPC(pRakClient,UpdateScoresPingsIPs);
REGISTER_STATIC_RPC(pRakClient,SvrStats); REGISTER_STATIC_RPC(pRakClient,SvrStats);
REGISTER_STATIC_RPC(pRakClient,Unk82);
REGISTER_STATIC_RPC(pRakClient,GameModeRestart); REGISTER_STATIC_RPC(pRakClient,GameModeRestart);
REGISTER_STATIC_RPC(pRakClient,ConnectionRejected);
REGISTER_STATIC_RPC(pRakClient,ClientMessage); REGISTER_STATIC_RPC(pRakClient,ClientMessage);
REGISTER_STATIC_RPC(pRakClient,WorldTime); REGISTER_STATIC_RPC(pRakClient,WorldTime);
REGISTER_STATIC_RPC(pRakClient,Unk5F); REGISTER_STATIC_RPC(pRakClient,Unk5F);
@ -132,8 +132,8 @@ void UnRegisterRPCs(RakClientInterface * pRakClient)
UNREGISTER_STATIC_RPC(pRakClient,Unk27); UNREGISTER_STATIC_RPC(pRakClient,Unk27);
UNREGISTER_STATIC_RPC(pRakClient,UpdateScoresPingsIPs); UNREGISTER_STATIC_RPC(pRakClient,UpdateScoresPingsIPs);
UNREGISTER_STATIC_RPC(pRakClient,SvrStats); UNREGISTER_STATIC_RPC(pRakClient,SvrStats);
UNREGISTER_STATIC_RPC(pRakClient,Unk82);
UNREGISTER_STATIC_RPC(pRakClient,GameModeRestart); UNREGISTER_STATIC_RPC(pRakClient,GameModeRestart);
UNREGISTER_STATIC_RPC(pRakClient,ConnectionRejected);
UNREGISTER_STATIC_RPC(pRakClient,ClientMessage); UNREGISTER_STATIC_RPC(pRakClient,ClientMessage);
UNREGISTER_STATIC_RPC(pRakClient,WorldTime); UNREGISTER_STATIC_RPC(pRakClient,WorldTime);
UNREGISTER_STATIC_RPC(pRakClient,Unk5F); UNREGISTER_STATIC_RPC(pRakClient,Unk5F);