Server crash when logging in!?
#4

okay, sorry I'm not sure what to show, so ill show my onplayerconnect:
pawn Код:
public OnPlayerConnect(playerid)
{
if(!NameValidator(playerid))
    {
        new string[128];
        format(string,sizeof(string),"%s has been kicked by The server. Reason: Get a Roleplay name, Example: Boris_Klaus.",GetPlayerNameEx(playerid));
        SendClientMessageToAll(COLOR_RED,string);
        SendClientMessage(playerid,COLOR_WHITE,"HINT: Your name must be in Firstname_Lastname format, (E.G: John_Gunterstein)");
        Kick(playerid);
        return 0;//<--I added this
    }
    new Query[80],pName[24],string[164];
    GetPlayerName(playerid,pName,24);
    format(Query,sizeof(Query),"SELECT `Username` FROM `Users` WHERE `Username` = '%s' LIMIT 1;",pName);
    mysql_query(Query);
    mysql_store_result();
    if(mysql_num_rows() != 0)//if number of rows is different from 0 then continue
    {
        format(string,sizeof(string),"Hey, %s! \nYour account is registered.\nPlease enter the password to log in!",pName);
        ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Log in",string,"Login","");
    }
    else
    {
        SendClientMessage(playerid,COLOR_RED,"Registering is currently disbled due to beta testing!");
        Kick(playerid);
        /*format(string,sizeof(string),"Hey, %s! \nYour account is not registered. \nPlease register to continue!",pName);
        ShowPlayerDialog(playerid,DIALOG_REGISTER1,DIALOG_STYLE_PASSWORD,"Register",string,"Register","");
        */

    }
}
The "namevalidator" code
pawn Код:
stock NameValidator(playerid)
{
    new pname[MAX_PLAYER_NAME],underline=0;
    GetPlayerName(playerid, pname, sizeof(pname));
    if(strfind(pname,"[",true) != (-1)) return 0;
    else if(strfind(pname,"]",true) != (-1)) return 0;
    else if(strfind(pname,"$",true) != (-1)) return 0;
    else if(strfind(pname,"(",true) != (-1)) return 0;
    else if(strfind(pname,")",true) != (-1)) return 0;
    else if(strfind(pname,"=",true) != (-1)) return 0;
    else if(strfind(pname,"@",true) != (-1)) return 0;
    else if(strfind(pname,"1",true) != (-1)) return 0;
    else if(strfind(pname,"2",true) != (-1)) return 0;
    else if(strfind(pname,"3",true) != (-1)) return 0;
    else if(strfind(pname,"4",true) != (-1)) return 0;
    else if(strfind(pname,"5",true) != (-1)) return 0;
    else if(strfind(pname,"6",true) != (-1)) return 0;
    else if(strfind(pname,"7",true) != (-1)) return 0;
    else if(strfind(pname,"8",true) != (-1)) return 0;
    else if(strfind(pname,"9",true) != (-1)) return 0;
    new maxname = strlen(pname);
    for(new i=0; i<maxname; i++)
    {
        if(pname[i] == '_') underline ++;
    }
    if(underline != 1) return 0;
    pname[0] = toupper(pname[0]);
    for(new x=1; x<maxname; x++)
    {
        if(pname[x] == '_') pname[x+1] = toupper(pname[x+1]);
        else if(pname[x] != '_' && pname[x-1] != '_') pname[x] = tolower(pname[x]);
    }
    SetPlayerName(playerid, "New_Name");
    SetPlayerName(playerid, pname);
    return 1;
}
@kikito err.. no i only compiled it with the new sscanf.. do you think that that is the problem?
Reply


Messages In This Thread
Server crash when logging in!? - by Jstylezzz - 09.05.2012, 19:36
Re: Server crash when logging in!? - by JaTochNietDan - 09.05.2012, 19:39
Re: Server crash when logging in!? - by kikito - 09.05.2012, 19:40
Re: Server crash when logging in!? - by Jstylezzz - 09.05.2012, 19:44
Re: Server crash when logging in!? - by kikito - 09.05.2012, 19:46
[No subject] - by Jstylezzz - 09.05.2012, 19:48

Forum Jump:


Users browsing this thread: 1 Guest(s)