Jump to content

DCS Lua Scripts and Multiplayer


c0ff

Recommended Posts

Mugata

 

I use the current bedrief.log file to determine game events. When players log there game report on our server, the cut and paste the debrief.log file there. I created a script to convert it to a more readable form AND determine who did what on the following premiss

 

1 - ALL weapons fired (even bullets) have an ID number.

2 - When "something" SHOOTs, its listed with this ID

3 - When something is HIT, it list the weapons ID

 

Using the above, you can track what weapon hit what "target". Since the weapon ID is matched to an "initiator", you can easily track "Who hit What".

 

For kills, they do NOT list what killed them, but by tracking who last hit a target, you can safely assume "the last hit got the kill"

 

The information also distinguishes "hits from weapons" and "self inflicted hits". This way combat damage can be tracked seperatly from self inflicted damage (mashing your rotor blade or hitting the ground).

 

Lastly (and thanks for this BS), any time a player changes helicopters, the ID changes.

 

With any luck, ED will expand what is output into this file, but so far there is enough there currently to track all the game events.

Try the Rest, then Join the Best

Link to comment
Share on other sites

  • 4 weeks later...

Hey c0ff, while working on the ServMan mod I have assembled a few suggestions for additional functions for the server.lua script, event hooks for the events.lua script, and net table functions, which could improve the available server management possibilities:

 

- Currently the scripts are completely event based. Would it be possible to add a function to the server.lua file that is similar to the LuaExportActivityNextEvent() function of the export.lua script? I.e. a function that Black Shark calls in customizable time intervals. It would be good if the function will also be called when the server is paused, so, unlike LuaExportActivityNextEvent(), time measurement should not be based on model time. This would make it very easy to write a timer. At the moment I have to base my timer on events that occur frequently (stat changes, mainly ping), which is not very convenient and has a few quirks.

 

- The net.send_chat() function can only send chat to all players or the own side, so the server can only send automatic messages (like a missionlist) to everyone and not just to the player who requested information. This causes message spamming, and I cannot send confident information to subadmins. It would be great if at least the server could send messages to single players identified by their ID, using a function like net.send_chat_to_id(id, msg).

 

- It would also be nice if one could specify different colours for messages sent by the server.

 

- An additional on_mission_score(side, score) hook would be great that is called each time the overall mission score of a side changes (or a net.get_mission_score(side) function that returns the current score of that side). That way one could for example set a score above which the next mission should be loaded automatically. At the moment automatic mission restarting/rotating can only be based on mission time, which is inconvenient because the average time needed to finish a specific mission varies alot. One could also create a mission cycle that is based on mission results, that way it would be possible to implement a multiplayer campaign system.

 

- The on_hit() function has already been mentioned above. Currently players can damage others of their team without killing them, which cannot be punished, so this would indeed be an important addition.

 

- Another problem is that players can crash into others of their side on purpose. I know it is hard to decide who is responsible for the crash, but it would already be helpful to have an on_collision(id1, id2) hook that is being called when two players collide (and maybe crash). That way it would be possible for example to let the players decide if the other player should be punished or not, or kick players automatically who have too many collisions.

 

- It would be helpful if the on_pause() and on_resume() functions could be called on the server as well, not only on clients.

 

- A server-only net.move_player(id, side) would be nice that moves a player either to a free Ka-50 slot of that side (if available) or to the spectators. This way one could implement manual or automatic team balancing.

 

- Would it be possible to add a similar function like LoGetWorldObjects() to the net table, which returns a table with all units available in the mission, and also add more properties to the net.get_unit_property(unitid, prop) function, like unit position, attitude information, heading, altitude and speed (similar to LoGetObjectById() ), information about the current target of a unit (similar to LoGet(Locked)TargetInformation() ) etc. These information could be helpful for server management, but currently you can only get them from the export.lua script, and I could not find a simple way to send them to the server.lua script, since their environments are completely separated. Of course I can write them to a file, but this is just an ad hoc workaround, and some people use the export.lua script for other purposes like Tacview, so I don't really want to touch it.

 

- One of the server hosts who beta tests my mod asked me if it is possible for the server to get and set client bandwidth settings, maybe you could add a new bandwidth stat to net.get_stat() and also a net.set_bandwidth(id) function.

 

That's all I can think of at the moment. Thanks for considering! :)


Edited by Acedy
Link to comment
Share on other sites

so this is like the IL-2 GreaterGreen IL-2 server scripting, but for Black Shark?

 

:unsure:

 

if so

:drunk:

ASUS Strix Z790-H, i9-13900, WartHog HOTAS and MFG Crosswind

G.Skill 64 GB Ram, 2TB SSD

EVGA Nvidia RTX 2080-TI

55" Sony OLED TV, Oculus VR

 

Link to comment
Share on other sites

  • 5 weeks later...
  • ED Team
Currently the scripts are completely event based.

DONE. Added server.on_process() - called every frame.

Also replaced net.get_time() with net.get_real_time() and net.get_model_time()

 

- The net.send_chat() function can only send chat to all players or the own side

DONE. Extented send_chat:

net.send_chat(msg, false) - to my coalition

net.send_chat(msg, true) - to all players

net.send_chat(msg, id) - to specified player (server-only)

 

- It would also be nice if one could specify different colours for messages sent by the server.

Not an easy one, but possible.

 

- An additional on_mission_score(side, score) hook would be great that is called each time the overall mission score of a side changes (or a net.get_mission_score(side) function that returns the current score of that side).

There's no per-side score, but it can be implemented with the current callbacks.

Added events.lua: on_mission_end(score) callback. Now seems useless because it does not tell who triggered the condition. Will investigate into that.

 

- The on_hit() function has already been mentioned above. Currently players can damage others of their team without killing them, which cannot be punished, so this would indeed be an important addition.

Under consideration.

 

- Another problem is that players can crash into others of their side on purpose. I know it is hard to decide who is responsible for the crash, but it would already be helpful to have an on_collision(id1, id2) hook that is being called when two players collide (and maybe crash).

Not easy. Do not count on it.

 

- It would be helpful if the on_pause() and on_resume() functions could be called on the server as well, not only on clients.

The idea was, that on clients this callbacks are called when player presses Pause key, to allow admins pause the server directly. Seems, you are pretty happy with chat-based pause/resume, and it's possible to change the semantics of this callbacks to "called on actual pause/resume".

It would be easy to do.

 

- A server-only net.move_player(id, side) would be nice that moves a player either to a free Ka-50 slot of that side (if available) or to the spectators. This way one could implement manual or automatic team balancing.

Looks like extended net.set_unit(), capable to manipulate any player. You'll need a list of available slots as well.

Under consideration.

 

Would it be possible to add a similar function like LoGetWorldObjects() to the net table, which returns a table with all units available in the mission, and also add more properties to the net.get_unit_property(unitid, prop) function, like unit position, attitude information, heading, altitude and speed (similar to LoGetObjectById() ), information about the current target of a unit (similar to LoGet(Locked)TargetInformation() ) etc.

Under consideration.

 

- One of the server hosts who beta tests my mod asked me if it is possible for the server to get and set client bandwidth settings, maybe you could add a new bandwidth stat to net.get_stat() and also a net.set_bandwidth(id) function.

Please, provide more detailed info, why it is needed.


Edited by c0ff
added net.get_time note

Dmitry S. Baikov @ Eagle Dynamics

LockOn FC2 Soundtrack Remastered out NOW everywhere - https://band.link/LockOnFC2.

Link to comment
Share on other sites

Awesome!

 

About the last item, the bandwith one, I suggested that because other simulators, for example Lock On or il2, works better using the same bandwidth setup for all players. For example, for Lock On seems the 128kbit download and 128kbit upload for all players works better. Now, I don't know why, so if all those experiments are something like placebo, it's not needed, but if not, would be nice.

AMD Ryzen 1400 // 16 GB DDR4 2933Mhz // Nvidia 1060 6GB // W10 64bit // Microsoft Sidewinder Precision 2

Link to comment
Share on other sites

  • 2 weeks later...
  • ED Team
I think the idea was to force the outbound speed from client to server, but this may work also :)

 

Thanks.

Right now, client limits its outbound speed to server_max_outbound/num_players if this value is less than client_max_outbound.

So the idea is that client_max_outbound should be capped with a server-side setting.

 

 

Added server-side "client_rate_limit" which caps client's maximum outbound speed.

Dmitry S. Baikov @ Eagle Dynamics

LockOn FC2 Soundtrack Remastered out NOW everywhere - https://band.link/LockOnFC2.

Link to comment
Share on other sites

  • 2 weeks later...

Nice work Dmitry,

 

Is it possible to filter clients based upon their ping? (so that clients with a large ping will not be allowed to join)

 

Also, would it be possible for each copy of Black Shark to have a unique client network ID (related to that copy's serial number). This would make ban lists workable.

[sIGPIC][/sIGPIC]

Virtual Australian Air Force

Link to comment
Share on other sites

Thanks Acedy (in fact - many thanks for ServMan - it's a real life saver).

 

Auto-kicking a high ping player is a solution but it'd be even nicer to prevent a high ping client from even connecting (and downloading the mission etc.)? - I suppose this should go in the Black Shark wish list rather than the scripting thread though.

[sIGPIC][/sIGPIC]

Virtual Australian Air Force

Link to comment
Share on other sites

EDIT: I found the details on ping - embarrassingly enough it was in the readme.txt file (I originally only looked in the LUA files).

 

I've hacked this short bit of code and put it in the "on_player_stat(id, stat, value)" function in "events.lua"

 

--kick if ping too high

if(stat == 0 and value > 300) then

serv_msg(string.format("Server automatically kicked %q for high ping", get_name(id)))

return server.kick_ban(id, "Ping too high")

end

 

 

Hopefully this will do the job.

 

 

***********************************************

 

You can readout client ping from within the scripts, so it is no problem to kick somebody for high ping.

 

I just checked events.lua and server.lua and couldn't find any reference to clients ping.

 

I'm obviously missing something as I believe that I've searched through all the scripts in the "net" subdirectory and haven't found 'ping" anywhere.

 

Any ideas on how to readout the client ping?


Edited by scatter
worked it out

[sIGPIC][/sIGPIC]

Virtual Australian Air Force

Link to comment
Share on other sites

  • 10 months later...

With the release of FC2.0, I was wondering what has changed?

 

It is already apparent that on_start() and on_stop() have changed to on_net_start() and on_net_stop().

 

What else has changed?

There are only 10 types of people in the world: Those who understand binary, and those who don't.

Link to comment
Share on other sites

I would like to know, it is possible to deactivate somewhere the messages if someone joyned the misssion or has someone/something shot down?

CPU: Intel i7-5820K 3,3GHz

Motherboard: ASUS X99-A

Grafik Card: NVIDIA Geforce GTX1080 Ti 337.50

RAM: 32GB

PIMAX 5k+ BE

Hotas Warthog with Simped Pedals

WIN 10 64bit

DirctX 11.0

Link to comment
Share on other sites

  • ED Team
I would like to know, it is possible to deactivate somewhere the messages if someone joyned the misssion or has someone/something shot down?

 

Yep. Add

disable_events = true,

to server section of your Config/network.cfg (watch the comma!)

Dmitry S. Baikov @ Eagle Dynamics

LockOn FC2 Soundtrack Remastered out NOW everywhere - https://band.link/LockOnFC2.

Link to comment
Share on other sites

  • ED Team
With the release of FC2.0, I was wondering what has changed?

 

It is already apparent that on_start() and on_stop() have changed to on_net_start() and on_net_stop().

 

What else has changed?

 

These callbacks were renamed because events.lua is now loaded directly into server and client tables (i.e. you can replace one without touching the other).

 

API changes: write_debriefing() was added, dostring_in() became server-only.

Dmitry S. Baikov @ Eagle Dynamics

LockOn FC2 Soundtrack Remastered out NOW everywhere - https://band.link/LockOnFC2.

Link to comment
Share on other sites

These callbacks were renamed because events.lua is now loaded directly into server and client tables (i.e. you can replace one without touching the other).

 

API changes: write_debriefing() was added, dostring_in() became server-only.

Thanks c0ff!

 

one more question; in the on_landing() and on_takeoff() functions the airbase name is provided. Is it also possible to retrieve the airbase coalition, whether it is RED, BLUE or NEUTRAL?

 

EDIT: Also is it possible to retrieve the time in the mission? Like Day 166, 06:23:15?


Edited by Case

There are only 10 types of people in the world: Those who understand binary, and those who don't.

Link to comment
Share on other sites

Yep. Add
disable_events = true,

to server section of your Config/network.cfg (watch the comma!)

 

Tried as you wrote, but it will not work. :cry:

CPU: Intel i7-5820K 3,3GHz

Motherboard: ASUS X99-A

Grafik Card: NVIDIA Geforce GTX1080 Ti 337.50

RAM: 32GB

PIMAX 5k+ BE

Hotas Warthog with Simped Pedals

WIN 10 64bit

DirctX 11.0

Link to comment
Share on other sites

  • Recently Browsing   0 members

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