load random fs
#5

Quote:
Originally Posted by Jefff
Посмотреть сообщение
pawn Код:
static const ScriptNames[][] =
{
    "script_name_1",
    "script_name_2",
    "script_name_3",
    "script_name_4"
    // more ...
};
static bool:Loaded[(sizeof(ScriptNames)) char];

LoadNewFS()
{
    static ScriptsLoaded;
    if(ScriptsLoaded >= sizeof(ScriptNames))
    {
        print("Warning: All scripts loaded!");
        return -1;
    }

    new p, rand;
    while(!p)
    {
        rand = random(sizeof(ScriptNames));
        if(!Loaded{rand})
        {
            Loaded{rand} = true;
            ScriptsLoaded++;
            p = 1;
        }
    }

    new cmd[45];
    format(cmd,sizeof(cmd),"loadfs %s",ScriptNames[rand]);
    SendRconCommand(cmd);
    return rand;
}
Thanks man , but lets say I want to unload the current fs loaded before loading a new one, will this work?
pawn Код:
stock LoadNewFS()
{
    new p, rand;
    while(!p)
    {
        rand = random(sizeof(ScriptNames));
        if(!Loaded{rand})
        {
            Loaded{rand} = true;
            p = 1;
        }
        else if(Loaded{rand})
        {
            new cmd[45];
            format(cmd,sizeof(cmd),"unloadfs %s",ScriptNames[rand]);
            SendRconCommand(cmd);
        }
    }

    new cmd[45];
    format(cmd,sizeof(cmd),"loadfs %s",ScriptNames[rand]);
    SendRconCommand(cmd);
    return rand;
}
Reply


Messages In This Thread
load random fs - by Onfroi - 16.06.2014, 20:00
Re: load random fs - by VladimirMark - 16.06.2014, 20:04
Re: load random fs - by Onfroi - 16.06.2014, 20:17
Re: load random fs - by Jefff - 16.06.2014, 20:50
Re: load random fs - by Onfroi - 16.06.2014, 21:29
Re: load random fs - by Jefff - 16.06.2014, 21:45

Forum Jump:


Users browsing this thread: 1 Guest(s)