Jump to content

Recommended Posts

Posted (edited)

Hello All,

I have been on servers that warn payers when an external even is going to happen like a server reboot.  I am looking at ways to pump in a message to server chat.   What is the best approach?   A lua script?, Python? 

 

Thank you!

Edited by lucktsm
  • 4 months later...
Posted
В 23.08.2023 в 22:36, lucktsm сказал:

Found the API the and got this working!  

 

Can you share how you did it?

  • Like 1

---

Kind Regards,

Alexander "Angry Яussian Simmer" Dementyev

simMarket Team Member

www.simmarket.com

  • 2 weeks later...
Posted (edited)
On 12/31/2023 at 12:18 AM, AlexZander_D said:

Can you share how you did it?

Something like this for instance.
It's showing two messages before the time when the reboot have to be triggered. Then at the time set in RestartAfter variable, he's checking if the number of clients active in the slots is 0, and if so, then he sets the flag "MissionRestart" to true. This way, You're sure, that thie clients will not be "ejected" forcefully at the landing approach, but server will wait unitl all clients will leave to lobby.
This script uses the MOOSE framework, so prior to loading it You have to load the MOOSE, then You have to set in ME the trigger for MissionRestart flag, so setting it to true will cause the mission restart.
 

local RestartAfter = 4 * 60 * 60

function RestartMission()
    env.info("Checking number of active clients...")

    local ClientNum = SET_CLIENT:New():FilterActive(false):FilterOnce():CountAlive()
    env.info(ClientNum)

    if ClientNum == 0 then
        env.info(">>>> REBOOT:Restarting the mission.")
        MESSAGE:New("Time to say goodbye...", 60, "EOM", true):ToAll()
        trigger.action.setUserFlag("MissionRestart", true)
    else
        SchReboot = TIMER:New(RestartMission)
        SchReboot:Start(20)
        env.info(">>>> REBOOT:Scheduled next run")    
    end
end

function Reminder1()
    MESSAGE:New("Mission end in 30 minutes, time to RTB.", 60, "INFO", false):ToAll()
end

function Reminder2()
    MESSAGE:New("Mission end in 5 minutes, time to RTB.", 60, "INFO", false):ToAll()
end

local SchReminder1 = TIMER:New(Reminder1)
SchReminder1:Start(RestartAfter - (30 * 60))

local SchReminder2 = TIMER:New(Reminder2)
SchReminder2:Start(RestartAfter - (5 * 60))

env.info(">>>> REBOOT:Scheduling first run after " .. RestartAfter .. " seconds.")
local SchReboot = TIMER:New(RestartMission)
SchReboot:Start(RestartAfter)
env.info(">>>> REBOOT:Scheduled first run")

 

Edited by Amarok_73
  • Like 1

Natural Born Kamikaze

-------------------------

AMD Ryzen 5 3600, AMD Fatal1ty B450 Gaming K4, AMD Radeon RX 5700 XT, 32 GB RAM Corsair Vengeance LPX, PSU Modecom Volcano 750W, Virpil Constellation Alpha Prime on Moza AB9 base, Virpil MongoosT-50CM3 Throttle, Turtle Beach VelocityOne Rudder.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...