Skip to content

Commit c59e47a

Browse files
author
karel26
committed
CHANGES:
- SlotBlocking / Coalitions: workaround to support dynamic slots
1 parent de236ae commit c59e47a

File tree

4 files changed

+31
-3
lines changed

4 files changed

+31
-3
lines changed

core/autoexec.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ def __post_init__(self):
4848
else:
4949
mydict[key] = value
5050
elif line.startswith('log'):
51-
mydict['log'] = line[4:]
51+
if 'log' not in mydict:
52+
mydict['log'] = []
53+
mydict['log'].append(line[4:])
5254
elif line.startswith('table'):
5355
if 'table' not in mydict:
5456
mydict['table'] = []
@@ -102,7 +104,8 @@ def update(self):
102104
with open(outfile, mode='w', encoding='utf-8') as outcfg:
103105
for key, value in self.values.items():
104106
if key == 'log':
105-
outcfg.write(f"{key}.{value}\n")
107+
for log in value:
108+
outcfg.write(f"{key}.{log}\n")
106109
continue
107110
elif key == 'net':
108111
outcfg.write('if not net then net = {} end\n')

plugins/gamemaster/lua/callbacks.lua

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,15 @@ function gamemaster.onPlayerTryChangeSlot(playerID, side, slotID)
3737
end
3838
end
3939

40+
function gamemaster.onPlayerChangeSlot(id)
41+
local side = net.get_player_info(id, 'side')
42+
local slot = net.get_player_info(id, 'slot')
43+
local _, _slot, _ = utils.getMulticrewAllParameters(id)
44+
45+
-- workaround for non-working onPlayerTryChangeSlot calls on dynamic spawns
46+
if _slot > 1000000 and gamemaster.onPlayerTryChangeSlot(id, side, slot) == false then
47+
net.force_player_slot(id, side, 1)
48+
end
49+
end
50+
4051
DCS.setUserCallbacks(gamemaster)

plugins/mission/lua/callbacks.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ end
4242

4343
function mission.onPlayerTryConnect(addr, name, ucid, playerID)
4444
log.write('DCSServerBot', log.DEBUG, 'Mission: onPlayerTryConnect()')
45+
if dcsbot.params == nil then
46+
-- don't block players, if the bot is not up
47+
return
48+
end
4549
config = dcsbot.params['mission']
4650
if locate(default_names, name) then
4751
return false, config['messages']['message_player_default_username']

plugins/slotblocking/lua/callbacks.lua

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
local base = _G
22
local dcsbot = base.dcsbot
33
local utils = base.require("DCSServerBotUtils")
4-
local config = base.require("DCSServerBotConfig")
54

65
local slotblock = slotblock or {}
76

@@ -193,4 +192,15 @@ function slotblock.onPlayerTryChangeSlot(playerID, side, slotID)
193192
end
194193
end
195194

195+
function slotblock.onPlayerChangeSlot(id)
196+
local side = net.get_player_info(id, 'side')
197+
local slot = net.get_player_info(id, 'slot')
198+
local _, _slot, _ = utils.getMulticrewAllParameters(id)
199+
200+
-- workaround for non-working onPlayerTryChangeSlot calls on dynamic spawns
201+
if _slot > 1000000 and slotblock.onPlayerTryChangeSlot(id, side, slot) == false then
202+
net.force_player_slot(id, side, 1)
203+
end
204+
end
205+
196206
DCS.setUserCallbacks(slotblock)

0 commit comments

Comments
 (0)