Info about random gmx
#2

Just like this:

PHP Code:
new last;
//OnGameModeInit
last LoadLastRestart();
//The function:
stock GetRandomRestart() //returns the id of the minigame to restart
{
    new 
x;
    do {
        
random(5); //The 5 is the max minigames
    
}
    while(
x==last);
    
SaveNewRestart(x);
    return 
x;
}
stock SaveNewRestart(x) {
    new 
File:f=fopen("restart.txt",io_write),tmp[4];
    return 
valstr(tmp,x),fwrite(f,tmp),fclose(f);
}
stock LoadLastRestart()
{
    if(!
fexist("restart.txt")) return -1;
    new 
File:f=fopen("restart.txt",io_read),tmp[4];
    return 
fread(f,tmp),fclose(f),strval(tmp);

Reply


Messages In This Thread
Info about random gmx - by Face9000 - 15.09.2015, 21:25
AW: Info about random gmx - by Kaliber - 15.09.2015, 21:49
Re: Info about random gmx - by Vince - 15.09.2015, 21:54
Re: Info about random gmx - by [KHK]Khalid - 15.09.2015, 22:05
Re: Info about random gmx - by Face9000 - 16.09.2015, 11:04
Re: Info about random gmx - by Face9000 - 17.09.2015, 22:28

Forum Jump:


Users browsing this thread: 1 Guest(s)