Проблема получения ника

Receiver

🥩 Передай meat, всё в скип, я в темпе
Автор темы
Проверенный
595
807
Добрейшего вечерочка друзья, с вами как всегда я – Фирамир. У меня возник очень интересный вопрос: при получении ника некоторых игроков, я получаю набор символов, почему?
Проблема очевидно в структуре:
C++:
struct  stPlayerPool {
    unsigned int                                ulMaxPlayerID;
    unsigned short                                sLocalPlayerID;
    void                                    *pVTBL_txtHandler;
    char                                szLocalPlayerName[SAMP_MAX_PLAYER_NAME];
    //int                                        iLocalPlayerNameLen;
    //int                                        iLocalPlayerNameAllocated;
    struct stLocalPlayer                    *pLocalPlayer;
    int                                        iLocalPlayerPing;
    int                                        iLocalPlayerScore;
    struct stRemotePlayer                    *pRemotePlayer[SAMP_MAX_PLAYERS];
    int                                        iIsListed[SAMP_MAX_PLAYERS];
    unsigned int                                dwPlayerIP[SAMP_MAX_PLAYERS]; // always 0
};
Структура:
struct stRemotePlayer {
    stRemotePlayerData *pPlayerData;
    int    iIsNPC;
    void *pVTBL_txtHandler;
    char szPlayerName[SAMP_MAX_PLAYER_NAME];
    //int iNameLen;
    //int    iNameAllocated;
    int    iScore;
    int iPing;
};
Дефайн:
#define SAMP_MAX_PLAYER_NAME 24
Исходники собейта я посмотрел. А используется там std::string, но попытавшись его использовать, получается лишь половина ника.
------------------------------------------------------------------
Решено:
C++:
const char *getPlayerName(int iPlayerID)
{
    if (g_Players == NULL || iPlayerID < 0 || iPlayerID > SAMP_MAX_PLAYERS)
        return NULL;

    if (iPlayerID < 0 || iPlayerID > SAMP_MAX_PLAYERS)
        return NULL;

    if (iPlayerID == g_Players->sLocalPlayerID)
    {
        if (g_Players->iLocalPlayerNameAllocated <= 0xF)
            return g_Players->szLocalPlayerName;
        return g_Players->pszLocalPlayerName;
    }

    if (g_Players->pRemotePlayer[iPlayerID] == NULL)
        return NULL;

    if (g_Players->pRemotePlayer[iPlayerID]->iNameAllocated <= 0xF)
        return g_Players->pRemotePlayer[iPlayerID]->szPlayerName;

    return g_Players->pRemotePlayer[iPlayerID]->pszPlayerName;
}
C++:
struct stRemotePlayer
{
    stRemotePlayerData    *pPlayerData;
    int                    iIsNPC;
    void                *pVTBL_txtHandler;
    union
    {
        char            szPlayerName[16];
        char            *pszPlayerName;
    };
    int                    iNameLen;
    int                    iNameAllocated;
    int                    iScore;
    int                    iPing;
};
 
Последнее редактирование: