1

Topic: [HELP]Register system - Check for characters

Hi. I create account system. ReD|FoX created crash. He shuts down my the server. How to create check for characters: ",.;:"?
My cod:
if(!str_comp_num(pMsg->m_pMessage, "/register", 9))
            {
                if(sscanf(pMsg->m_pMessage, "/register %s %s", pPlayer->m_Name, pPlayer->m_Pass))
                {
                    char acc[128];
                    str_format(acc, 128, "accounts/%s.acc", pPlayer->m_Name);
                    if(Exists(acc))
                    {
                        SendChatTarget(ClientID, "Account already exist");
                        return;
                    }
                    if(strlen(m_apPlayers[ClientID]->m_Pass) > 8)
                    {
                        SendChatTarget(ClientID, "You password is to long!");
                        return;
                    }
                    if(strlen(m_apPlayers[ClientID]->m_Name) > 8)
                    {
                        SendChatTarget(ClientID, "You login is to long!");
                        return;
                    }
                    if(strlen(m_apPlayers[ClientID]->m_Pass) < 3)
                    {
                        SendChatTarget(ClientID, "You password is to short!");
                        return;
                    }
                    if(strlen(m_apPlayers[ClientID]->m_Name) < 3)
                    {
                        SendChatTarget(ClientID, "You login is to short!");
                        return;
                    }
                    FILE* f;
                    f = fopen(acc, "a+");
                    fprintf(f, "%s\n%s\n1\n0\n0\n0\n1\n0\n0\n0", pPlayer->m_Name, pPlayer->m_Pass); // login pass lvl exp score money damage regenammo regenhealth vip
                    fclose(f);
                    SendChatTarget(ClientID, "Registration Done!\nUse /login to join the game!");
                    pPlayer->m_Lvl = 1;
                }
                else
                    SendChatTarget(ClientID, "Use /register <login> <password>");
            }

Please, i need help!

2

Re: [HELP]Register system - Check for characters

pPlayer->m_Name and pPlayer->m_Pass need to be 512 bytes big.
scan through the name and pass and check for illegal chars:

int Pos = 0;
while(pPlayer->m_Name[Pos] != 0)
{
if(pPlayer->m_Name[Pos] == ';' || pPlayer->m_Name[Pos] == ':')
{
SendChat("Illegal character");
return;
}
Pos++
}

This is just a example.

3

Re: [HELP]Register system - Check for characters

Big thanks. You is very good coder!

4

Re: [HELP]Register system - Check for characters

FEAR-Di3el wrote:

Big thanks. You is very good coder!

<sarcastic sentence>