Jump to content

Help for autockick function on multiplayer server


Alberto_mic

Recommended Posts

Hello Community,

 

I tried to find a function or command to autockick all players from a multiplayer server but without success.

In the specific I want to kick all player from the server before the server restart that is scheduled every 4 hours beacause server dosn't restart automatically if find a connected player.

 

Could you please help me for this?

 

Thank you very much in advanced.

 


Edited by Alberto_mic
  • Like 1
Link to comment
Share on other sites

Which is the setting in your mission?

Did you set a timer?

Did you set an exit at the end of the time?

Or did you set a load mission at the end of the mission?

Or something else?

If the timer of your server is buggy,it's the way to avoid issue.

Try to set your mission with a timer. by ME

Link to comment
Share on other sites

No, we have not set a timer in the mission, we have a batch that saves an image of the mission and after the restart reloads the last save.

Sorry, I made a mistake in explaining the problem. We have seen that we can restart the server even with players inside. But in this case the batch doesn't save some mission changes. For this reason we would like to kill all sessions before rebooting.

Link to comment
Share on other sites

I also add that we have implemented a life counting system with the csar, in detail 4 for each pilot. We also need the restart to reset those lives so we would prefer not to restart once a day but every 4 hours so that we can give the possibility to fly back to those who have lost all their lives. 
Link to comment
Share on other sites

Try getting a table of all playerIDs with this

net.get_player_list()

 

then iterate through the table using a for loop, running this command for every playerID

net.kick(playerID, message)

 

 

See if you can run this using a simple scheduled function (with a delay of almost 4 hours)


Edited by Hardcard
Link to comment
Share on other sites

Thank you very much Hardcard, I tried with the functions in this way:

 

local Players = net.get_player_list()
    print(Players()) --check output 
    
    for PlayerIDIndex, playerID in pairs( Players ) do
        net.kick(playerID, message)
        net.log("RGT - Player Killed - player: "..Players..")
    end

 

But I received this error message --> SCRIPTING: Mission script error: [string "local Players = ..."]:1: attempt to index global 'net' (a nil value)

I saw that error message is realted to the first row, I tried to change and I received the same error.

I tried to execute command on "do script" trigger on the miz.

 

Why I obtain this error if you?

 


Edited by Alberto_mic
Link to comment
Share on other sites

You need to run this code in the server environment (server hook). 

Server hooks need to be placed in C:\Users\YourUserName\Saved Games\DCS.openbeta\Scripts\Hooks

 

If you try to run net commands from the mission environment, as you would a regular script, you'll get that kind of error.

 

Other stuff that could be problematic with your snippet...

 

I don't think you can dump tables using print , also, why the extra ()?

print(Players()) --check output

 

 

This line is missing a final ", syntax is invalid as is. Also, Players will return a table, are you sure you can dump it using net.log ?

net.log("RGT - Player Killed - player: "..Players..")

 

 

 

In any case, you definitely need to dump the net.get_player_list() table somewhere, so you can check its structure and build the for loop accordingly, otherwise this won't work.

 

I normally use MOOSE's BASE:I to dump tables, but MOOSE doesn't work in the server environment, so you'll need to find a serializer that works in the server environment, somewhere.

 

I guess you could try this (requires io desanitization in MissionScripting.lua) https://github.com/gideros/table.save/blob/master/table.save-0.94.lua


Edited by Hardcard
Link to comment
Share on other sites

  • Recently Browsing   0 members

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