[bot] Implement n_GetPlayerName(...)

* Implement `set_amxstring(...)`

* Implement `CPlayerPool::GetPlayerName(...)`
This commit is contained in:
RD42
2024-06-08 21:56:00 +08:00
parent 36792cec63
commit a58e45731c
3 changed files with 18 additions and 2 deletions
+1
View File
@@ -19,6 +19,7 @@ public:
BOOL Process();
void SetLocalPlayerName(PCHAR szName) { strcpy(m_szLocalPlayerName,szName); };
PCHAR GetPlayerName(BYTE bytePlayerID) { return m_szPlayerNames[bytePlayerID]; };
CPlayerPool();
~CPlayerPool();
+13
View File
@@ -142,3 +142,16 @@ void AMXPrintError(CGameMode* pGameMode, AMX *amx, int error)
}
//----------------------------------------------------------------------------------
int set_amxstring(AMX *amx,cell amx_addr,const char *source,int max)
{
cell* dest = (cell *)(amx->base + (int)(((AMX_HEADER *)amx->base)->dat + amx_addr));
cell* start = dest;
while (max--&&*source)
*dest++=(cell)*source++;
*dest = 0;
return dest-start;
}
//----------------------------------------------------------------------------------
+4 -2
View File
@@ -242,8 +242,10 @@ static cell AMX_NATIVE_CALL n_IsPlayerInRangeOfPoint(AMX *amx, cell *params)
// native GetPlayerName(playerid, const name[], len)
static cell AMX_NATIVE_CALL n_GetPlayerName(AMX *amx, cell *params)
{
// TODO: n_GetPlayerName
return 0;
PLAYERID playerId = (PLAYERID)params[1];
if (playerId >= MAX_PLAYERS || !pNetGame->GetPlayerPool()->GetSlotState(playerId)) return 0;
return set_amxstring(amx, params[2], pNetGame->GetPlayerPool()->
GetPlayerName(playerId), params[3]);
}
// native IsPlayerConnected(playerid)