SA-MP Forums Archive
Name length problem. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Name length problem. (/showthread.php?tid=306812)



Name length problem. - HondaCBR - 28.12.2011

On my server when your name is too long it tells you to register every time, it creates your player file, but it doesnt read it or something when name is like AAAAAAAAAAAA

Short names work fine: This decides to show login or register menu:

pawn Код:
public OnPlayerConnect(playerid)
{
    new string[MAX_PLAYER_NAME];
    new plname[MAX_PLAYER_NAME];
    gPlayerAccount[playerid] = 0;
    RegistrationStep[playerid] = 0;
    gPlayerLogged[playerid] = 0;
    PlayerInfo[playerid][pLevel] = 0;
    PlayerInfo[playerid][pCash] = 0;
    PlayerInfo[playerid][pReg] = 0;
    CurrentMoney[playerid] = 0;
    gPlayerLogTries[playerid] = 0;
    gActivePlayers[playerid]++;
    SetPlayerColor(playerid,COLOR_GRAD2);
    GetPlayerName(playerid, plname, sizeof(plname));
    ONazwa[playerid]=plname;
    format(string, sizeof(string), "Konta/%s.ini", plname);
    if(fexist(string))
    {
        gPlayerAccount[playerid] = 1;//show login
    }
    else
    {
        gPlayerAccount[playerid] = 0;//show register
    }
    return 1;
}
showing the login bit:
pawn Код:
public OnPlayerRequestClass(playerid, classid)
{
//  new string[128];
    if (RegistrationStep[playerid] == 0 && gPlayerLogged[playerid] != 1)
    {
        ClearChatbox(playerid, 10);

        if (gPlayerAccount[playerid] != 0)
        {
        //  SetPlayerCameraPos(playerid, 1111.3206,-1324.8296,72.4714);
        //  SetPlayerCameraLookAt(playerid, 1111.4764,-1537.8735,29.9035);
            ShowPlayerDialog(playerid, LOGOWANIE, DIALOG_STYLE_PASSWORD, "Logowanie", "Witaj na polskim serwerze role play true life, ta postac jest\n zarejestrowana, wpisz haslo aby sie zalogowac:", "Zaloguj", "Wyjdz");
        }
        else
        {
        //  SetPlayerCameraPos(playerid, 1111.3206,-1324.8296,72.4714);
        //  SetPlayerCameraLookAt(playerid, 1111.4764,-1537.8735,29.9035);
            ShowPlayerDialog(playerid, REJESTRACJA, 1, "Rejestracja", "Witaj na Polskim Serwerze Role Play True Life, ta postac nie jest jeszcze\n zarejestrowana, aby ja zarejestrowac wpisz ponizej haslo dla tej postaci:", "Zarejestruj", "Wyjdz");
        }
    }
    else
    {
        SpawnPlayer(playerid);
    }
    return 0;
}



Re: Name length problem. - pmkrz - 28.12.2011

new string[MAX_PLAYER_NAME + 10]; *

To solve your problem you must increase, at least 10 cells, the size of "string" !


Re: Name length problem. - MP2 - 28.12.2011

Because your string has MAX_PLAYER_NAME as the length. That is 20. If this is your string:

Konta/%s.ini

The %s can be 20, but you also have "Konta/" and ".ini", which are 10 more. Change the string size to 32.


Re: Name length problem. - HondaCBR - 28.12.2011

Oh so the folder takes up the characters too, right.

Would that be fine then?
new string[MAX_PLAYER_NAME + 12];
new plname[MAX_PLAYER_NAME + 12];


Re: Name length problem. - pmkrz - 28.12.2011

You don't need to increase "plname"'s size!


Re: Name length problem. - XFlawless - 28.12.2011

pawn Код:
#undef MAX_PLAYER_NAME
#define MAX_PLAYER_NAME 24
Redefine it.

Quote:
Originally Posted by pmkrz
Посмотреть сообщение
new string[MAX_PLAYER_NAME + 10]; *

To solve your problem you must increase, at least 10 cells, the size of "string" !
Max characters(safe side) is 24.


Re: Name length problem. - MP2 - 28.12.2011

Quote:
Originally Posted by HondaCBR
Посмотреть сообщение
Would that be fine then?
new string[MAX_PLAYER_NAME + 12];
new plname[MAX_PLAYER_NAME + 12];
Read my post...
Quote:
Originally Posted by MP2
Посмотреть сообщение
Change the string size to 32.