My server crashes when Player Connects
#1

The server always crashes when a player connect's. The code is

OnPlayerConnect

pawn Код:
public OnPlayerConnect(playerid)
{
    format(stringZ, sizeof(stringZ), "Gangs/Spieler/%s.ini", Spieler(playerid));
    if(dini_Exists(stringZ)){OnGangLogin(playerid);}
    else{
    new File: hFile = fopen(stringZ, io_write);
    if (hFile)
    {
            new var[32];
            format(var, 32, "gang_member=%d\n", SpielerDatei[playerid][gang_member]);fwrite(hFile, var);
            format(var, 32, "gang_leader=%d\n",SpielerDatei[playerid][gang_leader]);fwrite(hFile, var);
            format(var, 32, "gang_rank=%d\n",SpielerDatei[playerid][gang_rank]);fwrite(hFile, var);
    }
    fclose(hFile);
    OnGangLogin(playerid);
    }
    return 1;
}
Reply
#2

Try this:
pawn Код:
public OnPlayerConnect(playerid)
{
    new stringZ[32];
    format(stringZ, sizeof(stringZ), "Gangs/Spieler/%s.ini", Spieler(playerid));
    if(dini_Exists(stringZ)){
    OnGangLogin(playerid);
    }else{
    new File: hFile = fopen(stringZ, io_write);
    if (hFile)
    {
        new var[128];
        format(var, 128, "gang_member=%d\n", SpielerDatei[playerid][gang_member]);fwrite(hFile, var);
        format(var, 128, "gang_leader=%d\n",SpielerDatei[playerid][gang_leader]);fwrite(hFile, var);
        format(var, 128, "gang_rank=%d\n",SpielerDatei[playerid][gang_rank]);fwrite(hFile, var);
    }
    else
    {
        fclose(hFile);
        OnGangLogin(playerid);
    }
    return 1;
}
Edit: not tested.
Reply
#3

thanks for your code, there was a little mistake though. BTW what was my mistake?

pawn Код:
public OnPlayerConnect(playerid)
{
    //new string3[32];
    format(stringZ, sizeof(stringZ), "Gangs/Spieler/%s.ini", Spieler(playerid));
    if(dini_Exists(stringZ))
    {
        OnGangLogin(playerid);
    }
    else
    {
        new File: hFile = fopen(stringZ, io_write);
        if (hFile)
        {
            new var[128];
            format(var, 128, "gang_member=%d\n", SpielerDatei[playerid][gang_member]);fwrite(hFile, var);
            format(var, 128, "gang_leader=%d\n",SpielerDatei[playerid][gang_leader]);fwrite(hFile, var);
            format(var, 128, "gang_rank=%d\n",SpielerDatei[playerid][gang_rank]);fwrite(hFile, var);
        }
        else
        {
            fclose(hFile);
            OnGangLogin(playerid);
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)