Server crashing on fread
#6

The only thing I can think of is if TeamInfo[index][spawnfilename] haven't stored a file that exists in some index and then the second way comes true (io_read in file that doesn't exist).

Do some debugging:
pawn Код:
public OnGameModeInit()
{
    SetGameModeText("- City DM v1.0 -");
   
    new string[128], File:spawnfile;
   
    if (!fexist("CityDM/teams.ini")) print("CityDM/teams.ini doesn't exist");
    else
    {
        spawnfile = fopen("CityDM/teams.ini",io_read);
        if (spawnfile)
        {
            while(fread(spawnfile,string))
            {
                sscanf(string,"p<,>s[15]dddds[30]",TeamInfo[TeamsCreated][TeamName],TeamInfo[TeamsCreated][TeamSkin],TeamInfo[TeamsCreated][TeamWeapon][0],TeamInfo[TeamsCreated][TeamWeapon][1],TeamInfo[TeamsCreated][TeamWeapon][2],TeamInfo[TeamsCreated][spawnfilename]);
                TeamInfo[TeamsCreated][TeamCreated] = 1;
                AddPlayerClass(TeamInfo[TeamsCreated][TeamSkin],0.0,0.0,0.0,0.0,TeamInfo[TeamsCreated][TeamWeapon][0],15000,TeamInfo[TeamsCreated][TeamWeapon][1],10000,TeamInfo[TeamsCreated][TeamWeapon][2],10000);
                printf("CREATED A TEAM (Team %s) (%d)",TeamInfo[TeamsCreated][TeamName],TeamsCreated);
                TeamsCreated ++;
            }
            fclose(spawnfile);
        }
    }
    for(new i = 0; i < TeamsCreated; i ++)
    {
        new count = SpawnCount[i],file[30];
        if (!fexist(TeamInfo[i][spawnfilename])) printf("%s doesn't exist", TeamInfo[i][spawnfilename]);
        else
        {
            spawnfile = fopen(TeamInfo[i][spawnfilename],io_read);
            if (spawnfile)
            {
                while(fread(spawnfile,string))
                {
                    sscanf(string,"p<,>ffff",Spawns[i][count][X],Spawns[i][count][Y],Spawns[i][count][Z],Spawns[i][count][A]);
                    printf("SPAWN ADDED (team %s) (%d) %.2f %.2f %.2f",TeamInfo[i][TeamName],i,Spawns[i][count][X],Spawns[i][count][Y],Spawns[i][count][Z]);
                    count ++;
                }
                fclose(spawnfile);
                SpawnCount[i] = count;
            }
        }
    }
    return 1;
}
Reply


Messages In This Thread
Server crashing on fread - by Jochemd - 01.03.2014, 12:34
Re: Server crashing on fread - by Konstantinos - 01.03.2014, 12:37
Re: Server crashing on fread - by Jochemd - 01.03.2014, 12:41
Re: Server crashing on fread - by Konstantinos - 01.03.2014, 12:46
Re: Server crashing on fread - by Jochemd - 01.03.2014, 12:49
Re: Server crashing on fread - by Konstantinos - 01.03.2014, 13:00
Re: Server crashing on fread - by Jochemd - 01.03.2014, 13:02
Re: Server crashing on fread - by Konstantinos - 01.03.2014, 13:35
Re: Server crashing on fread - by Jochemd - 01.03.2014, 13:55

Forum Jump:


Users browsing this thread: 1 Guest(s)