mirror of
https://github.com/dashr9230/SA-MP.git
synced 2025-09-19 20:26:14 +08:00
[bot] Implement ClientMessage(...)
* Make the szText parameter unsigned char pointer for `CGameMode::OnClientMessage(...)`
This commit is contained in:
@ -233,19 +233,19 @@ int CGameMode::OnNPCExitVehicle()
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// forward OnClientMessage(color, text[]);
|
||||
int CGameMode::OnClientMessage(cell color, char *szText)
|
||||
int CGameMode::OnClientMessage(cell color, unsigned char * szText)
|
||||
{
|
||||
int idx;
|
||||
cell ret = 1;
|
||||
int orig_strlen = strlen(szText) + 1;
|
||||
int orig_strlen = strlen((char*)szText) + 1;
|
||||
|
||||
if (!amx_FindPublic(&m_amx, "OnClientMessage", &idx))
|
||||
{
|
||||
cell amx_addr, *phys_addr;
|
||||
amx_PushString(&m_amx, &amx_addr, &phys_addr, szText, 0, 0);
|
||||
amx_PushString(&m_amx, &amx_addr, &phys_addr, (char*)szText, 0, 0);
|
||||
amx_Push(&m_amx, color);
|
||||
amx_Exec(&m_amx, &ret, idx);
|
||||
amx_GetString(szText, phys_addr, 0, orig_strlen);
|
||||
amx_GetString((char*)szText, phys_addr, 0, orig_strlen);
|
||||
amx_Release(&m_amx, amx_addr);
|
||||
}
|
||||
return (int)ret;
|
||||
|
@ -32,7 +32,7 @@ public:
|
||||
int OnNPCSpawn();
|
||||
int OnNPCEnterVehicle(cell vehicleid, cell seatid);
|
||||
int OnNPCExitVehicle();
|
||||
int OnClientMessage(cell color, char *szText);
|
||||
int OnClientMessage(cell color, unsigned char * szText);
|
||||
int OnPlayerDeath(cell playerid);
|
||||
int OnPlayerText(cell playerid, unsigned char * szText);
|
||||
int OnPlayerStreamIn(cell playerid);
|
||||
|
@ -73,6 +73,7 @@ public:
|
||||
|
||||
CPlayerPool * GetPlayerPool() { return m_pPlayerPool; };
|
||||
RakClientInterface * GetRakClient() { return m_pRakClient; };
|
||||
CGameMode * GetBotMode() { return m_pGameMode; };
|
||||
|
||||
void Init(PCHAR szHostOrIp,int iPort,PCHAR szPlayerName,PCHAR szPass,PCHAR szNpcMode);
|
||||
void Process();
|
||||
|
@ -1,6 +1,7 @@
|
||||
|
||||
#include "../main.h"
|
||||
using namespace RakNet;
|
||||
extern CNetGame* pNetGame;
|
||||
|
||||
#define REJECT_REASON_BAD_VERSION 1
|
||||
#define REJECT_REASON_BAD_NICKNAME 2
|
||||
@ -51,7 +52,21 @@ void ConnectionRejected(RPCParameters *rpcParams)
|
||||
|
||||
void ClientMessage(RPCParameters *rpcParams)
|
||||
{
|
||||
// TODO: ClientMessage
|
||||
PCHAR Data = reinterpret_cast<PCHAR>(rpcParams->input);
|
||||
int iBitLength = rpcParams->numberOfBitsOfData;
|
||||
RakNet::BitStream bsData(Data,(iBitLength/8)+1,false);
|
||||
DWORD dwStrLen;
|
||||
DWORD dwColor;
|
||||
|
||||
bsData.Read(dwColor);
|
||||
bsData.Read(dwStrLen);
|
||||
unsigned char* szMsg = (unsigned char *)malloc(dwStrLen+1);
|
||||
bsData.Read((char *)szMsg, dwStrLen);
|
||||
szMsg[dwStrLen] = 0;
|
||||
|
||||
if(pNetGame->GetBotMode()) pNetGame->GetBotMode()->OnClientMessage(dwColor, szMsg);
|
||||
|
||||
free(szMsg);
|
||||
}
|
||||
|
||||
void WorldTime(RPCParameters *rpcParams) {}
|
||||
|
Reference in New Issue
Block a user