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[]);
|
// forward OnClientMessage(color, text[]);
|
||||||
int CGameMode::OnClientMessage(cell color, char *szText)
|
int CGameMode::OnClientMessage(cell color, unsigned char * szText)
|
||||||
{
|
{
|
||||||
int idx;
|
int idx;
|
||||||
cell ret = 1;
|
cell ret = 1;
|
||||||
int orig_strlen = strlen(szText) + 1;
|
int orig_strlen = strlen((char*)szText) + 1;
|
||||||
|
|
||||||
if (!amx_FindPublic(&m_amx, "OnClientMessage", &idx))
|
if (!amx_FindPublic(&m_amx, "OnClientMessage", &idx))
|
||||||
{
|
{
|
||||||
cell amx_addr, *phys_addr;
|
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_Push(&m_amx, color);
|
||||||
amx_Exec(&m_amx, &ret, idx);
|
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);
|
amx_Release(&m_amx, amx_addr);
|
||||||
}
|
}
|
||||||
return (int)ret;
|
return (int)ret;
|
||||||
|
@ -32,7 +32,7 @@ public:
|
|||||||
int OnNPCSpawn();
|
int OnNPCSpawn();
|
||||||
int OnNPCEnterVehicle(cell vehicleid, cell seatid);
|
int OnNPCEnterVehicle(cell vehicleid, cell seatid);
|
||||||
int OnNPCExitVehicle();
|
int OnNPCExitVehicle();
|
||||||
int OnClientMessage(cell color, char *szText);
|
int OnClientMessage(cell color, unsigned char * szText);
|
||||||
int OnPlayerDeath(cell playerid);
|
int OnPlayerDeath(cell playerid);
|
||||||
int OnPlayerText(cell playerid, unsigned char * szText);
|
int OnPlayerText(cell playerid, unsigned char * szText);
|
||||||
int OnPlayerStreamIn(cell playerid);
|
int OnPlayerStreamIn(cell playerid);
|
||||||
|
@ -73,6 +73,7 @@ public:
|
|||||||
|
|
||||||
CPlayerPool * GetPlayerPool() { return m_pPlayerPool; };
|
CPlayerPool * GetPlayerPool() { return m_pPlayerPool; };
|
||||||
RakClientInterface * GetRakClient() { return m_pRakClient; };
|
RakClientInterface * GetRakClient() { return m_pRakClient; };
|
||||||
|
CGameMode * GetBotMode() { return m_pGameMode; };
|
||||||
|
|
||||||
void Init(PCHAR szHostOrIp,int iPort,PCHAR szPlayerName,PCHAR szPass,PCHAR szNpcMode);
|
void Init(PCHAR szHostOrIp,int iPort,PCHAR szPlayerName,PCHAR szPass,PCHAR szNpcMode);
|
||||||
void Process();
|
void Process();
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
#include "../main.h"
|
#include "../main.h"
|
||||||
using namespace RakNet;
|
using namespace RakNet;
|
||||||
|
extern CNetGame* pNetGame;
|
||||||
|
|
||||||
#define REJECT_REASON_BAD_VERSION 1
|
#define REJECT_REASON_BAD_VERSION 1
|
||||||
#define REJECT_REASON_BAD_NICKNAME 2
|
#define REJECT_REASON_BAD_NICKNAME 2
|
||||||
@ -51,7 +52,21 @@ void ConnectionRejected(RPCParameters *rpcParams)
|
|||||||
|
|
||||||
void ClientMessage(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) {}
|
void WorldTime(RPCParameters *rpcParams) {}
|
||||||
|
Reference in New Issue
Block a user