Jump to content

So, I saw custom server announcements on a non-modded server.


Recommended Posts

The server you saw may not be modded but I believe the admin created their own script for the console commands that listens for new players and utilizes the c_announce. Sadly, I do not have the necessary knowledge to write up the script to do so. Sorry for not being much help others with better know how may be able to, good luck.

Link to comment
Share on other sites

30 minutes ago, Zillvr said:

The server you saw may not be modded but I believe the admin created their own script for the console commands that listens for new players and utilizes the c_announce. Sadly, I do not have the necessary knowledge to write up the script to do so. Sorry for not being much help others with better know how may be able to, good luck.

Ok, thanks anyway.  

Link to comment
Share on other sites

HI, i myself own a dedicated server, and I would love to know how to make the kind of script you are talking about, using the c_announce command! If any good soul could enlighten me, it would be much appreciated !

Thanks

Link to comment
Share on other sites

1. For a periodic announcement, you could do c_announce(msg,interval) on your server or via a cronjob with a Bash script.

You should be able to use the DST commands via the console. To do this, add -console when you start your server. Example :

screen -dmS dst_server1 "./dontstarve_dedicated_server_nullrenderer -conf_dir dst_server1 -console"

 

nano server_announce.sh

arg=$*
screenName=dst_server1 #The screen name of your server
screen -r $screenName -p 0 -X stuff "c_announce(\"""$arg""\")""$(echo -ne '\015')"

Ctrl + O to save, and Ctrl + X to quit.

chmod +x server_announce.sh

To test it, try : 

./announce_server.sh Your text here!

 

crontab -e

For a periodic message every hour for example, add this line to your crontab.

0 * * * * sh /path/to/server_announce.sh Your text goes here!

 

2. To welcome visitors on your server,

nano join_server_announcement.sh

while true
do
grep -m 1 "Join Announcement" <(tail -n 0 -F ~/.klei/dst_adventure_overworld/chat_log.txt)\
&& sleep 15 && sh /path/to/announce_server.sh Welcome! #Link it to the announce_server script.
done

Ctrl + O to save, and Ctrl + X to quit.

Now you can start a screen with the script in it.

screen -dmS join_server_announcement "./join_server_announcement.sh"

 

So, this is how you do this in Bash. If you have any question, do not hesitate.

 

Link to comment
Share on other sites

From my file of useful stuffs:

 

# Set announcement on player joining game
TheWorld:ListenForEvent("ms_playerjoined", function() c_announce("This is a test announcement from the console") end)

 

 

Note:  I haven't tested this recently, it might be stale.  Also, this announcement will only play until the world regens, which is fine for a Wilderness or Endless server but does mean you can't count on it for a Survival server.

Link to comment
Share on other sites

On 1/20/2016 at 11:34 AM, absimiliard said:

From my file of useful stuffs:

 

# Set announcement on player joining game
TheWorld:ListenForEvent("ms_playerjoined", function() c_announce("This is a test announcement from the console") end)

 

 

Note:  I haven't tested this recently, it might be stale.  Also, this announcement will only play until the world regens, which is fine for a Wilderness or Endless server but does mean you can't count on it for a Survival server.

Thanks!  Is there any way of re-adding a console command automatically?  This is far more useful than having to tell them myself every-time someone joins.  Also, can this be done with multiple announcements, or over time?

Link to comment
Share on other sites

My testing showed I could set several of these up at once.  So when a new player joined I'm pretty sure I could get it to say several things, I never found a way to selectively disable one once set up however.  Also note, been a while since I did this,, so I'd suggest doing some testing, my memory ain't what it used to be when I was a young sysad, now it's all full of linux-crap and sql-scraps.

 

There might be a way to get a console command to run automatically.  I think it would essentially be making a mod.  I'd suggest poking through that forum, your answer might be there.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...