SA-MP Forums Archive
Reloads - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Reloads (/showthread.php?tid=344595)



Reloads - Kitten - 21.05.2012

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.");
}



Re: Reloads - ViniBorn - 21.05.2012

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 ...


Re: Reloads - Kitten - 21.05.2012

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


Re: Reloads - iggy1 - 21.05.2012

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
    }

}



Re: Reloads - iGetty - 21.05.2012

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

Make it a global one, then OnGameModeInit()

add mapid = 0;

Then do it that way?


Re: Reloads - Jefff - 21.05.2012

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;
}