[Tutorial] Creating a basic dynamic multi-race system
#9

pawn Код:
stock LoadRaceFromFile( const szFileName[ ], const szFileFormat[ ] = ".txt" )
{
    if( !fexist( szFileName ) )
        return 0;
       
    new
        File: fHandle = fopen( szFileName, io_read ),
        szName[ 24 ],
        szLine[ 128 ],
        Float: X, Float: Y, Float: Z,
        iCheckpoints = 0
    ;
       
    strmid( szName, szFileName, 0, cellmax );
    strdel( szName, strfind( szName, szFileFormat), cellmax );
   
    new id = CreateRace( szName, 300 );
   
    while( fread( fHandle, szLine ) )
    {
        if( isnull( szLine ) ) continue;
        unformat( szLine, "'AddCheckpointToRace('p<,>s[24]fff');'", szLine, X, Y, Z );
        AddCheckpointToRace( id, X, Y, Z );
        iCheckpoints++;
    }
    printf( "Race %s has been loaded with %d checkpoints!", szName, iCheckpoints );
    fclose( fHandle );
    return 1;
}
I really cannot be stuffed investigating why the Z coordinate doesn't work, but I'll leave it to you guys to fix. I'm not going to be using it or anything. It loads and shit, just not the Z cord.

It is based on [HiC]TheKiller's exporting method and uses sscanf2.

Lorenc.txt
Код:
AddCheckpointToRace(race2, 2915.456787, -1622.428466, 12.435916);
AddCheckpointToRace(race2, 2910.672363, -1637.185913, 12.395952);
AddCheckpointToRace(race2, 2903.093994, -1660.151611, 12.430374);
AddCheckpointToRace(race2, 2898.300048, -1675.741333, 12.457112);
AddCheckpointToRace(race2, 2890.918457, -1702.602905, 12.493884);
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)