@jtff/miztemplate-lib 3.5.6 → 3.5.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -66,6 +66,16 @@ AAMAxRange = {
|
|
|
66
66
|
RANDOM_RANGE = 4,
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
+
if (pcall(
|
|
70
|
+
function ()
|
|
71
|
+
dofile(lfs.writedir() .. 'Scripts/net/DCSServerBot/DCSServerBot.lua')
|
|
72
|
+
end)) then
|
|
73
|
+
jtff_log.debug(string.format("DCSServerBot present on server ! Including NetLibrary..."), "Initialization")
|
|
74
|
+
else
|
|
75
|
+
jtff_log.error(string.format("DCSServerBot NOT present on server ! Preventing use of it..."), "Initialization")
|
|
76
|
+
dcsbot = nil
|
|
77
|
+
end
|
|
78
|
+
|
|
69
79
|
function switchGroupImmortalStatus(group)
|
|
70
80
|
status = not BASE:GetState(group, "isImmortal")
|
|
71
81
|
jtff_log.info(string.format("switch group %s to immortal status %s", group:GetName(), tostring(status)), "GENERAL")
|
|
@@ -171,8 +181,7 @@ function tankerStatusMessage(tanker, PlayerUnit, PlayerGroup)
|
|
|
171
181
|
MESSAGE:NewType(message, MESSAGE.Type.Overview):ToGroup(PlayerGroup)
|
|
172
182
|
end
|
|
173
183
|
|
|
174
|
-
function
|
|
175
|
-
|
|
184
|
+
function getNearestTankerfromPlayerUnit(PlayerUnit, Radius)
|
|
176
185
|
Radius=UTILS.NMToMeters(Radius or 50)
|
|
177
186
|
|
|
178
187
|
local isrefuelable, playerrefuelsystem=PlayerUnit:IsRefuelable()
|
|
@@ -199,10 +208,16 @@ function findNearestTanker(PlayerUnit, PlayerGroup, Radius)
|
|
|
199
208
|
end
|
|
200
209
|
end
|
|
201
210
|
end
|
|
211
|
+
return tanker
|
|
212
|
+
end
|
|
213
|
+
return nil
|
|
214
|
+
end
|
|
202
215
|
|
|
216
|
+
function findNearestTanker(PlayerUnit, PlayerGroup, Radius)
|
|
217
|
+
local tanker = getNearestTankerfromPlayerUnit(PlayerUnit)
|
|
218
|
+
if (type(tanker) ~= "nil") then
|
|
203
219
|
tankerStatusMessage(tanker, PlayerUnit, PlayerGroup)
|
|
204
220
|
end
|
|
205
|
-
return nil
|
|
206
221
|
end
|
|
207
222
|
|
|
208
223
|
function findAllTanker(PlayerUnit, PlayerGroup, Radius)
|
|
@@ -726,11 +741,11 @@ function SpawnRangesDelay(param)
|
|
|
726
741
|
local delay = param[4] or spawnStandardDelay
|
|
727
742
|
local myfunc = param[5]
|
|
728
743
|
local sound_warning = true
|
|
729
|
-
if (type(param[6]) ~= nil) then
|
|
744
|
+
if (type(param[6]) ~= "nil") then
|
|
730
745
|
sound_warning = param[6]
|
|
731
746
|
end
|
|
732
747
|
local message_warning = true
|
|
733
|
-
if (type(param[7]) ~= nil) then
|
|
748
|
+
if (type(param[7]) ~= "nil") then
|
|
734
749
|
message_warning = param[7]
|
|
735
750
|
end
|
|
736
751
|
if ( sound_warning ) then
|
|
@@ -755,11 +770,11 @@ function SpawnWholeRangesDelay(param)
|
|
|
755
770
|
local delay = param[3] or spawnStandardDelay
|
|
756
771
|
local myfunc = param[4]
|
|
757
772
|
local sound_warning = true
|
|
758
|
-
if (type(param[5]) ~= nil) then
|
|
773
|
+
if (type(param[5]) ~= "nil") then
|
|
759
774
|
sound_warning = param[5]
|
|
760
775
|
end
|
|
761
776
|
local message_warning = true
|
|
762
|
-
if (type(param[6]) ~= nil) then
|
|
777
|
+
if (type(param[6]) ~= "nil") then
|
|
763
778
|
message_warning = param[6]
|
|
764
779
|
end
|
|
765
780
|
parentRangeMenu:RemoveSubMenus()
|
|
@@ -30,28 +30,54 @@ function Set_CLIENT:OnEventPlayerEnterAircraft(EventData)
|
|
|
30
30
|
MENU_GROUP_COMMAND:New( EventData.IniGroup, "Nearest Tanker Info", MenuCoalitionTankerRed, NearestTankerInfo, { EventData.IniUnit, EventData.IniGroup} )
|
|
31
31
|
MENU_GROUP_COMMAND:New( EventData.IniGroup, "All Tankers Info", MenuCoalitionTankerRed, AllTankersInfo, {EventData.IniUnit,EventData.IniGroup} )
|
|
32
32
|
end
|
|
33
|
-
local GroupMenu = MENU_GROUP:New( EventData.IniGroup, "My settings" )
|
|
33
|
+
local GroupMenu = MENU_GROUP:New( EventData.IniGroup, "My Group settings" )
|
|
34
34
|
jtff_log.debug(string.format("Add Immortal Menu for group [%s], player name [%s]",EventData.IniGroupName , EventData.IniPlayerName),"GENERAL")
|
|
35
35
|
BASE:SetState( EventData.IniGroup, "isImmortal", false )
|
|
36
36
|
MENU_GROUP_COMMAND:New( EventData.IniGroup, "Switch immortal status", GroupMenu, switchGroupImmortalStatus, EventData.IniGroup )
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
if #AIRBOSSArray > 0 then
|
|
38
|
+
MENU_GROUP_COMMAND:New( EventData.IniGroup, "Switch Airboss subtitles", GroupMenu, switchGroupAirbossSubtitlesStatus, EventData.IniGroup )
|
|
39
|
+
end
|
|
40
40
|
end
|
|
41
41
|
end
|
|
42
42
|
function Set_CLIENT:OnEventRefueling(EventData)
|
|
43
|
-
if (EventData.
|
|
44
|
-
local client = CLIENT:Find(EventData.
|
|
45
|
-
local
|
|
46
|
-
|
|
43
|
+
if (EventData.initiator) then
|
|
44
|
+
local client = CLIENT:Find(EventData.initiator)
|
|
45
|
+
local clientUnit = UNIT:Find(EventData.initiator)
|
|
46
|
+
local clientFuel = clientUnit:GetFuel() * clientUnit:GetDesc().fuelMassMax
|
|
47
|
+
local tankerUnit = getNearestTankerfromPlayerUnit(clientUnit)
|
|
48
|
+
local tankerUnitName = 'unknown'
|
|
49
|
+
if (type(tankerUnit) ~= 'nil') then
|
|
50
|
+
tankerUnitName = tankerUnit:GetName()
|
|
51
|
+
end
|
|
52
|
+
jtff_log.trace(string.format("[%s] Start to refuel at the tanker [%s], current fuel : %.0f Lbs",client:GetPlayer() , tankerUnitName, UTILS.kg2lbs(clientFuel)),"TANKER")
|
|
47
53
|
BASE:SetState( client, "Fuel", clientFuel )
|
|
48
54
|
end
|
|
49
55
|
end
|
|
50
56
|
function Set_CLIENT:OnEventRefuelingStop(EventData)
|
|
51
|
-
if (EventData.
|
|
52
|
-
local client = CLIENT:Find(EventData.
|
|
53
|
-
local
|
|
54
|
-
|
|
57
|
+
if (EventData.initiator) then
|
|
58
|
+
local client = CLIENT:Find(EventData.initiator)
|
|
59
|
+
local clientUnit = UNIT:Find(EventData.initiator)
|
|
60
|
+
local clientFuel = clientUnit:GetFuel() * clientUnit:GetDesc().fuelMassMax
|
|
61
|
+
local tankerUnit = getNearestTankerfromPlayerUnit(clientUnit)
|
|
62
|
+
local tankerUnitName = 'unknown'
|
|
63
|
+
if (type(tankerUnit) ~= 'nil') then
|
|
64
|
+
tankerUnitName = tankerUnit:GetName()
|
|
65
|
+
end
|
|
66
|
+
local clientFuelTaken = clientFuel - BASE:GetState(client,"Fuel")
|
|
67
|
+
BASE:SetState( client, "Fuel", clientFuel )
|
|
68
|
+
jtff_log.trace(string.format("[%s] Stop to refuel at the tanker [%s], taken %.0f Lbs",client:GetPlayer() , tankerUnitName, UTILS.kg2lbs(clientFuelTaken)),"TANKER")
|
|
69
|
+
if (type(dcsbot) ~= 'nil') then
|
|
70
|
+
local title = string.format('End of Air refuel !')
|
|
71
|
+
local description = string.format("[%s] Stop to refuel at the tanker [%s], taken %.0f Lbs",client:GetPlayer() , tankerUnitName, UTILS.kg2lbs(clientFuelTaken))
|
|
72
|
+
local img = 'https://cdn10.picryl.com/photo/2004/10/03/a-us-navy-usn-f-14b-tomcat-aircraft-assigned-to-fighter-squadron-one-zero-three-f5f749-1024.jpg'
|
|
73
|
+
local fields = {
|
|
74
|
+
['Pilot'] = client:GetPlayer(),
|
|
75
|
+
['Tanker'] = tankerUnitName,
|
|
76
|
+
['RefuelQty'] = UTILS.kg2lbs(clientFuelTaken)
|
|
77
|
+
}
|
|
78
|
+
local footer = 'Sorry, tomcats took it all again...'
|
|
79
|
+
dcsbot.sendEmbed(title, description, img, fields, footer)
|
|
80
|
+
end
|
|
55
81
|
end
|
|
56
82
|
end
|
|
57
83
|
|