Reloads
#1

I've made this code to load the next mission available, but it seems to load the same mission again, it does not load the other one any idea what i'm doing wrong?

pawn Код:
stock LoadNewMission()
{
    new file[64],mapid;
    for( ; mapid != MAX_MISSION_FILES; ++mapid)
    {
        format(file,sizeof(file),"/Missions/%d.ini",mapid);
        if(fexist(file))
        {
            mapid++;
        }
    }
   
    format(file, sizeof(file), "/Missions/%d.ini", mapid);
    if(fexist(file))
    {
        LastMissionStarted = mapid;
        return mapid;
    }
    else return printf("[NOTICE] File Bugged.");
}
Reply
#2

From what I understand, that's enough.
pawn Код:
stock LoadNewMission()
{
    new file[64],mapid;
    for( ; mapid != MAX_MISSION_FILES; ++mapid)
    {
        format(file,sizeof(file),"/Missions/%d.ini",mapid);
        if(fexist(file))
        {
            mapid++;
            break;
        }
    }
   
    format(file, sizeof(file), "/Missions/%d.ini", mapid);
    if(fexist(file))
    {
        LastMissionStarted = mapid;
        return mapid;
    }
    else return printf("[NOTICE] File Bugged.");
}
Correct me if I misunderstood ...
Reply
#3

Still seems to be reloading the same mission, any other methods of doing this?
Reply
#4

Try something like this maybe?

pawn Код:
LoadNextMission()
{
    new
        szFilePath[ 64 ];
   
    format( szFilePath, sizeof(szFilePath), "/Missions/%d.ini", LastMissionStarted +1);//last mission plus 1
   
    if( fexist(szFilePath) )
    {
        //.. next mission
    }
    else
    {
        //next game does not exist
    }

}
Reply
#5

Or, could it be regarding your variable:
pawn Код:
mapid
?

Make it a global one, then OnGameModeInit()

add mapid = 0;

Then do it that way?
Reply
#6

pawn Код:
stock LoadNewMission()
{
    new file[64];
    static mapid;
    mapid %= MAX_MISSION_FILES;
    format(file, sizeof(file), "/Missions/%d.ini", mapid);
    if(!fexist(file)) return printf("[NOTICE] File Bugged.");
    LastMissionStarted = mapid;
    mapid++;
    return mapid-1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)