mirror of
https://github.com/dashr9230/SA-MP.git
synced 2026-10-10 03:33:04 +08:00
[bot] Implement n_GetPlayerName(...)
* Implement `set_amxstring(...)` * Implement `CPlayerPool::GetPlayerName(...)`
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user