1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Hey Guest, is it this your first time on the forums?

    Visit the Beginner's Box

    Introduce yourself, read some of the ins and outs of the community, access to useful links and information.

    Dismiss Notice

Timer + messages?

Discussion in 'Modding [KAG Classic]' started by FranticIch, Nov 3, 2012.

?

Could you use something like this?

  1. Yes

    75.0%
  2. No

    25.0%
  3. This is useless

    0 vote(s)
    0.0%
  1. FranticIch

    FranticIch Let me be your tank... Donator

    Messages:
    234
    Does someone know how, or if it´s possible, to make the server automaticly put out "/rcon /msg a message".
    My idea was to make a timer. Every x seconds he raises a variable(+1). Every number is a rcon message. When the highest value is reached, the var sets back to zero.
    var messageNumber = 0;
    timer bla bla

    if(messageNumber == 1){/rcon /msg You like the server? Visit us in the forums!;}
    if(messageNumber == 2){/rcon /msg We are currently...;}
    if(messageNumber == 3){messageNumber = 1;}
    Thats my main idea. The are two problems:
    1. I don´t know how to make the Timer.
    2. In wich cfg. file I would have to put that in?

    Anyone got a idea? I think that would be good for every/much server(s)!

    -FranticIch
     
  2. MechaTrickster

    MechaTrickster Banned Donator

    Messages:
    654
    If you could use commands in the console you could probably set up some kind of program/script that does this automatically. But it's not possible with just the current .cfgs we have now. Its a good idea though.
     
  3. FranticIch

    FranticIch Let me be your tank... Donator

    Messages:
    234
    Okey, thanks:)
     
  4. Geti

    Geti Please avoid PMing me (poke a mod instead) THD Team Administrator Global Moderator

    Messages:
    3,730
    You're wrong, it is possible with dedicated_autostart.gm , though incarnum had issues with the sleep(seconds) function not working from time to time, and the script flooding his sever. Your mileage may vary.

    In the autostart, the code that you would put at the bottom of your dedicated_autostart.gm would look something like

    Code:
    sleep(5.0);   
     
     
    global MOTDMessage = 0;
    global MOTDMessages_count = 5;
     
    while(true)
    {
      sleep(30.0); //send msg each 30 seconds
     
      // print the message that responds to the
      // number - note that we could use a switch
      // statement, but GM is kinda buggy with those.
     
      if (MOTDMessage == 0)
      {
          serverMessage("MESSAGE 1");
      }
      else if (MOTDMessage == 1)
      {
          serverMessage("MESSAGE 2");
      }
      else if (MOTDMessage == 2)
      {
          serverMessage("MESSAGE 3");
      }
      else if (MOTDMessage == 3)
      {
          serverMessage("MESSAGE 4");
      }
      else if (MOTDMessage == 4)
      {
          serverMessage("MESSAGE 5");
      }
      else { print ( "ERROR: MOTD SCRIPT IS BUGGED" ); }
     
      //increment the message number, wrapping around the count.
      MOTDMessage = (MOTDMessage + 1) % MOTDMessages_count;
     
    }
    
    Note that we decided this scripting language was too finicky and have swapped to something more versatile, so this script will not work in the coming "scripting" build, but you _can_ use GM for a MOTD hack. It's much simpler, clearer and less likely to randomly explode in the coming scripting builds that dont rely on this GM language though ;)

    You can also insert LoadMap("mapname.cfg"); and WaterLevel( 100 ); and other lines in there which could be useful for roleplay servers.
     
  5. FranticIch

    FranticIch Let me be your tank... Donator

    Messages:
    234
    Thanks:eek::D

    I already wondered why
    Code:
    if(waterLevel(0)){waterLevel(120);}
    doesn´t work... I´ve put it in the gamemode.cfgX3
     
  6. Geti

    Geti Please avoid PMing me (poke a mod instead) THD Team Administrator Global Moderator

    Messages:
    3,730
    note: waterLevel(0) doesn't return the water level afair, so that statement will crash the game with an error if you put it in a script :)
     
  7. FranticIch

    FranticIch Let me be your tank... Donator

    Messages:
    234
    Intresting, when i write
    Code:
    if(waterLevel(0)){waterLevel(120);}
    The game doesn´t crash... it just sets the waterlevel to 0... :huh?:

    Well, how would it be right then? I hadn´t much time to "play" around with it yet :)
    </br>--- merged: Nov 5, 2012 9:02 PM ---</br>
    I got a problem: Every, maybe, hour, all the messages start to freak around; They are all showing in part of a second again and again and again... after a minute it works normal again