Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Script to rotate cfg's?

  1. #1

    Default Script to rotate cfg's?

    can you use a script that will rotate server to a new cfg after a certain time? or day? didn't CI use to do that?

  2. #2

    Default

    yes, you can get the time with gettime(0)
    and exec a .cfg with stuffsrv( "exec myconfig.cfg" )
    IIRC Purple made a script like that using the gettime function

  3. #3

    Default

    cool going to try to fix me up one to switch server.cfg each day at midnight.

  4. #4

    Default

    OK this is what I came up with it works good just not sure about how many seconds I can have it wait before starting script, is there a limit on how long you can have it wait? It will check to make sure there is no active players before rotating cfg's also I'm going try to get it to work with the freeze tag crap...lol think I just need to change the " level.g_gametype = getcvar (g_gametype) to level.g_gametype = getcvar (g_extgametype) " all that mefy's stuff confuses me.

    Code:
    main:
    
        wait 43200  // time to wait before starting check 43200 = 12hrs
        
        iprintln "CHECKING FOR ACTIVE PLAYERS"  //added just to check scr. that the is running
         
        wait 5  // change time to thread rotate 
    
     
        for(local.i=1;local.i<= $player.size;local.i++)
        if(!(IsAlive $player[local.i]) || $player[local.i].dmteam == "spectator")
        {
            iprintln "NONE found!" //added just to check scr. that the is running
            waitthread rotate
        }
        else
        {
            end
        }
    end
    
    rotate:
    
        level.g_gametype = getcvar (g_gametype)
        if( level.g_gametype == "1" )
        {
        wait 20 // change time to rotate cfg
        iprintln "SWITCHING TO TEAM-MATCH"   //added just to check scr. that the is running
        wait 5   
        stuffsrv ( "exec cfg/tdm.cfg" )    
        }
        else if( level.g_gametype == "2" )
        {	
        wait 20 // change time to rotate cfg
        iprintln "SWITCHING TO ROUND-BASED-MATCH"   //added just to check scr. that the is running
        wait 5  
        stuffsrv ( "exec cfg/obj.cfg" )
        }
        else if( level.g_gametype == "3" )
        {
        wait 20 // change time to rotate cfg
        iprintln "SWITCHING TO OBJECTIVE-MATCH"   //added just to check scr. that the is running
        wait 5  
        stuffsrv ( "exec cfg/rbm.cfg" )  
    
        }
        else if( level.g_gametype == "4" )
        {
        wait 20 // change time to rotate cfg
        iprintln "SWITCHING TO FREE-FOR-ALL"   //added just to check scr. that the is running
        wait 5  
        stuffsrv ( "exec server.cfg" ) // FFA
    
        }
       
    end

  5. #5

    Default

    that script ain't gonna work because the countdown will be reset every new round/map
    that's why you have to use the server's time to make the check.


    this code uses the getdate function to make the check
    it will use the intermission event to make the transition between gametypes, so the gameplay won't be interrupted
    save it as global/rotation.scr and execute it from the DMprecache after "level waittill spawn"
    *if you save it with another name make sure to change the name in the line 12 too



    main:
    local.date = getdate(0);
    setcvar "_date" local.date;

    while(1) {
    local.new_date = getdate(0);
    if (getcvar("_date") != local.new_date)
    {
    setcvar "_date" local.new_date;
    stuffsrv("say It's midnight, game type will change when the map ends\n");
    local.result = unregisterev "intermission";
    local.result = registerev "intermission" global/rotation.scr::intermission;
    }
    wait 30;
    }
    end;

    intermission local.type:
    /*
    local.type - type of server intermission

    0 = Player intermission screen
    1 = Map change (happens after using commands: map, gamemap , but also right after player intermission screen)
    2 = Map restart (happens after restart command)
    */
    if (local.type == 0) {
    thread rotate;
    }
    end;

    rotate:
    if(getcvar("g_gametype") == "1")
    {
    stuffsrv("say SWITCHING TO TEAM-MATCH\n");
    stuffsrv("exec cfg/tdm.cfg");
    }

    else if(getcvar("g_gametype") == "2")
    {
    stuffsrv("say SWITCHING TO ROUND-BASED-MATCH\n");
    stuffsrv("exec cfg/rbm.cfg");
    }

    else if(getcvar("g_gametype") == "3")
    {
    stuffsrv("say SWITCHING TO OBJECTIVE-MATCH\n");
    stuffsrv("exec cfg/obj.cfg");

    }

    else if(getcvar("g_gametype") == "4")
    {
    stuffsrv("say SWITCHING TO FREE-FOR-ALL\n");
    stuffsrv("exec server.cfg");
    }
    end;

  6. #6

    Default

    @Zappa: This way will still not work because you checking the time you have set from the server not the time you whant.

    And we need to filter the time variable becaue we cant check straight away.

    @easymeat: I think theres no limit for the delay of the script (unless someone tell me ).

    To easy check if theres no players on the server you can do like this:


    if($player.size <= 0)
    {
    //stuff

    }
    Last edited by DoubleKill; March 27th, 2018 at 01:57 AM.

  7. #7
    Purple Developer Purple Elephant1au's Avatar
    Join Date
    Feb 2012
    Location
    Australia
    Posts
    1,269

    Default

    Zappas example above is a good way to do it. I like the idea of changing it on intermission event as to not disrupt players gameplay

    However, the getdate() function is bugged in the LINUX version of the patch. There was a quick fix made to it, but like a few other bugs, they were never added to the release version.
    See https://www.x-null.net/forums/showth...hlight=getdate where i originally found the bug.

    In a mapchange mod i made that changes maplist at a certain time of the day. >> https://www.x-null.net/forums/showth...ed-on-day-time <<
    I used gettime instead of getdate, but you can adjust it to suit this problem.


    PS. You gave me an idea for another mod/feature (depending if i get access to source to update at patch level). An event where you can add time or date specific tasks to be run ( or even mods ) similer to how cron works. Maybe adding simple jobs to an client_admin command maybe....
    Edit again: Maybe even create some pre-loaded jobs that admins can use, like backup/flush logfile, .. any other command tasks. I could do this in script engine, but be much better patch level
    Last edited by Purple Elephant1au; March 27th, 2018 at 02:12 AM.

    Purple's Playground
    OBJ :
    103.29.85.127:12203
    xfire: purpleelephant1au
    email: purpleelephant1au@gmail.com
    skydrive: PurpleElephantSkydrive




  8. #8

    Default

    OK back to the drawing board, Never thought about the new round thing restarting the script. I copied both of your scripts so I have somethings to work with, and DoubleKill's check for players is a whole lot simpler than what I was doing. At least I'll have something to do for a few days. My server company installed my server on a Windows OS because reborn wouldn't work on their linux OS it kept crashing the server the Tech dude said the ver. of Linux they use was too new to work with reborn patch, don't know if it's true or not but I like Windows servers better no bugs.
    Last edited by easymeat; March 27th, 2018 at 05:16 AM.

  9. #9

    Default

    Quote Originally Posted by DoubleKill View Post
    @Zappa: This way will still not work because you checking the time you have set from the server not the time you whant.
    but look the line 6, the date get updated every 30 seconds, local.date and local.new_date are not the same

    anyways, i fixed a little bit the code and now it should work with no errors
    you can test it on your pc changing your system time to 23:59


    main:
    wait 10;
    if (getcvar("_date") == "") {
    local.date = getdate(0);
    setcvar "_date" local.date;
    }

    while(1) {
    local.new_date = getdate(0);
    if (getcvar("_date") != local.new_date)
    {
    setcvar "_date" local.new_date;
    stuffsrv("say It's midnight, game type will change when the maps ends\n");
    local.result = unregisterev "intermission";
    local.result = registerev "intermission" global/rotation.scr::intermission;
    end;
    }
    wait 30;
    }
    end;

    intermission local.type:
    /*
    local.type - type of server intermission

    0 = Player intermission screen
    1 = Map change (happens after using commands: map, gamemap , but also right after player intermission screen)
    2 = Map restart (happens after restart command)
    */
    if (local.type == 0) {
    thread rotate;
    }
    end;

    rotate:
    if(getcvar("g_gametype") == "1")
    {
    stuffsrv("say SWITCHING TO TEAM-MATCH\n");
    stuffsrv("exec cfg/tdm.cfg");
    }

    else if(getcvar("g_gametype") == "2")
    {
    stuffsrv("say SWITCHING TO ROUND-BASED-MATCH\n");
    stuffsrv("exec cfg/rbm.cfg");
    }

    else if(getcvar("g_gametype") == "3")
    {
    stuffsrv("say SWITCHING TO OBJECTIVE-MATCH\n");
    stuffsrv("exec cfg/obj.cfg");

    }

    else if(getcvar("g_gametype") == "4")
    {
    stuffsrv("say SWITCHING TO FREE-FOR-ALL\n");
    stuffsrv("exec server.cfg");
    }
    end;

  10. #10

    Default

    I changed the clock to 24hrs set it to 23:59 the first message shows up " stuffsrv("say It's midnight, game type will change when the maps ends\n"); " but it don't change anything.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •