diff --git a/bot/net/playerpool.h b/bot/net/playerpool.h index 1babfc2..205373a 100644 --- a/bot/net/playerpool.h +++ b/bot/net/playerpool.h @@ -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(); diff --git a/bot/scrcore.cpp b/bot/scrcore.cpp index 752df1e..3a285de 100644 --- a/bot/scrcore.cpp +++ b/bot/scrcore.cpp @@ -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; +} + +//---------------------------------------------------------------------------------- + diff --git a/bot/scrcustom.cpp b/bot/scrcustom.cpp index ee7532f..8cd19e6 100644 --- a/bot/scrcustom.cpp +++ b/bot/scrcustom.cpp @@ -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)