mirror of
https://github.com/ciribob/DCS-CSAR.git
synced 2025-10-29 16:56:07 +00:00
Release 1.8.3
Adds ability to block a slot using optional other script Extra fix for rescue to FARP to work around DCS Bug
This commit is contained in:
167
CSAR.lua
167
CSAR.lua
@@ -1,11 +1,11 @@
|
|||||||
-- CSAR Script for DCS Ciribob - 2015
|
-- CSAR Script for DCS Ciribob - 2015
|
||||||
-- Version 1.8.2 - 31/12/2015
|
-- Version 1.8.3 - 17/01/2016
|
||||||
-- DCS 1.5 Compatible - Needs Mist 4.0.55 or higher!
|
-- DCS 1.5 Compatible - Needs Mist 4.0.55 or higher!
|
||||||
|
|
||||||
csar = {}
|
csar = {}
|
||||||
|
|
||||||
-- SETTINGS FOR MISSION DESIGNER vvvvvvvvvvvvvvvvvv
|
-- SETTINGS FOR MISSION DESIGNER vvvvvvvvvvvvvvvvvv
|
||||||
csar.csarUnits = {
|
csar.csarUnits = {
|
||||||
"helicargo1",
|
"helicargo1",
|
||||||
"helicargo2",
|
"helicargo2",
|
||||||
"helicargo3",
|
"helicargo3",
|
||||||
@@ -98,30 +98,30 @@ csar.csarUnits = {
|
|||||||
|
|
||||||
} -- List of all the MEDEVAC _UNIT NAMES_ (the line where it says "Pilot" in the ME)!
|
} -- List of all the MEDEVAC _UNIT NAMES_ (the line where it says "Pilot" in the ME)!
|
||||||
|
|
||||||
csar.bluemash = {
|
csar.bluemash = {
|
||||||
"BlueMASH #1",
|
"BlueMASH #1",
|
||||||
"BlueMASH #2",
|
"BlueMASH #2",
|
||||||
"BlueMASH #3",
|
"BlueMASH #3",
|
||||||
"BlueMASH #4",
|
"BlueMASH #4",
|
||||||
"BlueMASH #5",
|
"BlueMASH #5",
|
||||||
"BlueMASH #6",
|
"BlueMASH #6",
|
||||||
"BlueMASH #7",
|
"BlueMASH #7",
|
||||||
"BlueMASH #8",
|
"BlueMASH #8",
|
||||||
"BlueMASH #9",
|
"BlueMASH #9",
|
||||||
"BlueMASH #10"
|
"BlueMASH #10"
|
||||||
} -- The unit that serves as MASH for the blue side
|
} -- The unit that serves as MASH for the blue side
|
||||||
|
|
||||||
csar.redmash = {
|
csar.redmash = {
|
||||||
"RedMASH #1",
|
"RedMASH #1",
|
||||||
"RedMASH #2",
|
"RedMASH #2",
|
||||||
"RedMASH #3",
|
"RedMASH #3",
|
||||||
"RedMASH #4",
|
"RedMASH #4",
|
||||||
"RedMASH #5",
|
"RedMASH #5",
|
||||||
"RedMASH #6",
|
"RedMASH #6",
|
||||||
"RedMASH #7",
|
"RedMASH #7",
|
||||||
"RedMASH #8",
|
"RedMASH #8",
|
||||||
"RedMASH #9",
|
"RedMASH #9",
|
||||||
"RedMASH #10"
|
"RedMASH #10"
|
||||||
} -- The unit that serves as MASH for the red side
|
} -- The unit that serves as MASH for the red side
|
||||||
|
|
||||||
csar.disableAircraft = true -- DISABLE player aircraft until the pilot is rescued?
|
csar.disableAircraft = true -- DISABLE player aircraft until the pilot is rescued?
|
||||||
@@ -139,6 +139,11 @@ csar.disableCSARAircraft = false -- if set to TRUE then if a CSAR heli crashes o
|
|||||||
|
|
||||||
csar.enableForAI = false -- set to false to disable AI units from being rescued.
|
csar.enableForAI = false -- set to false to disable AI units from being rescued.
|
||||||
|
|
||||||
|
csar.enableSlotBlocking = false -- if set to true, you need to put the csarSlotBlockGameGUI.lua
|
||||||
|
-- in C:/Users/<YOUR USERNAME>/DCS/Scripts for 1.5 or C:/Users/<YOUR USERNAME>/DCS.openalpha/Scripts for 2.0
|
||||||
|
-- For missions using FLAGS and this script, make sure that all mission value numbers are higher than 1000 to ensure
|
||||||
|
-- the scripts dont conflict
|
||||||
|
|
||||||
csar.bluesmokecolor = 4 -- Color of smokemarker for blue side, 0 is green, 1 is red, 2 is white, 3 is orange and 4 is blue
|
csar.bluesmokecolor = 4 -- Color of smokemarker for blue side, 0 is green, 1 is red, 2 is white, 3 is orange and 4 is blue
|
||||||
csar.redsmokecolor = 1 -- Color of smokemarker for red side, 0 is green, 1 is red, 2 is white, 3 is orange and 4 is blue
|
csar.redsmokecolor = 1 -- Color of smokemarker for red side, 0 is green, 1 is red, 2 is white, 3 is orange and 4 is blue
|
||||||
|
|
||||||
@@ -162,7 +167,7 @@ csar.allowFARPRescue = true --allows pilot to be rescued by landing at a FARP or
|
|||||||
-- SETTINGS FOR MISSION DESIGNER ^^^^^^^^^^^^^^^^^^^*
|
-- SETTINGS FOR MISSION DESIGNER ^^^^^^^^^^^^^^^^^^^*
|
||||||
|
|
||||||
-- Sanity checks of mission designer
|
-- Sanity checks of mission designer
|
||||||
assert(mist ~= nil, "\n\n** HEY MISSION-DESIGNER! **\n\nMiST has not been loaded!\n\nMake sure MiST 3.7 or higher is running\n*before* running this script!\n")
|
assert(mist ~= nil, "\n\n** HEY MISSION-DESIGNER! **\n\nMiST has not been loaded!\n\nMake sure MiST 4.0.57 or higher is running\n*before* running this script!\n")
|
||||||
|
|
||||||
csar.addedTo = {}
|
csar.addedTo = {}
|
||||||
|
|
||||||
@@ -182,12 +187,14 @@ csar.heliCloseMessage = {} -- tracks heli close message ie heli < 500m distance
|
|||||||
|
|
||||||
csar.radioBeacons = {} -- all current beacons
|
csar.radioBeacons = {} -- all current beacons
|
||||||
|
|
||||||
csar.max_units = 5 --number of pilots that can be carried
|
csar.max_units = 6 --number of pilots that can be carried
|
||||||
|
|
||||||
csar.currentlyDisabled = {} --stored disabled aircraft
|
csar.currentlyDisabled = {} --stored disabled aircraft
|
||||||
|
|
||||||
csar.hoverStatus = {} -- tracks status of a helis hover above a downed pilot
|
csar.hoverStatus = {} -- tracks status of a helis hover above a downed pilot
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function csar.tableLength(T)
|
function csar.tableLength(T)
|
||||||
|
|
||||||
if T == nil then
|
if T == nil then
|
||||||
@@ -220,31 +227,31 @@ function csar.eventHandler:onEvent(_event)
|
|||||||
|
|
||||||
elseif _event.id == 15 then --player entered unit
|
elseif _event.id == 15 then --player entered unit
|
||||||
|
|
||||||
-- if its a sar heli, re-add check status script
|
-- if its a sar heli, re-add check status script
|
||||||
for _, _heliName in pairs(csar.csarUnits) do
|
for _, _heliName in pairs(csar.csarUnits) do
|
||||||
|
|
||||||
if _heliName == _event.initiator:getName() then
|
if _heliName == _event.initiator:getName() then
|
||||||
-- add back the status script
|
-- add back the status script
|
||||||
for _woundedName, _groupInfo in pairs(csar.woundedGroups) do
|
for _woundedName, _groupInfo in pairs(csar.woundedGroups) do
|
||||||
|
|
||||||
if _groupInfo.side == _event.initiator:getCoalition() then
|
if _groupInfo.side == _event.initiator:getCoalition() then
|
||||||
|
|
||||||
--env.info(string.format("Schedule Respawn %s %s",_heliName,_woundedName))
|
--env.info(string.format("Schedule Respawn %s %s",_heliName,_woundedName))
|
||||||
-- queue up script
|
-- queue up script
|
||||||
-- Schedule timer to check when to pop smoke
|
-- Schedule timer to check when to pop smoke
|
||||||
timer.scheduleFunction(csar.checkWoundedGroupStatus, { _heliName, _woundedName }, timer.getTime() + 5)
|
timer.scheduleFunction(csar.checkWoundedGroupStatus, { _heliName, _woundedName }, timer.getTime() + 5)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
if _event.initiator:getName() then
|
if _event.initiator:getName() then
|
||||||
|
|
||||||
env.info("Checking Unit - ".._event.initiator:getName())
|
env.info("Checking Unit - ".._event.initiator:getName())
|
||||||
csar.checkDisabledAircraftStatus( _event.initiator:getName())
|
csar.checkDisabledAircraftStatus( _event.initiator:getName())
|
||||||
end
|
end
|
||||||
|
|
||||||
return true
|
return true
|
||||||
elseif (_event.id == 9) then
|
elseif (_event.id == 9) then
|
||||||
-- Pilot dead
|
-- Pilot dead
|
||||||
|
|
||||||
@@ -275,7 +282,15 @@ function csar.eventHandler:onEvent(_event)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
csar.currentlyDisabled[_unit:getName()] = {timeout = (csar.disableTimeoutTime*60) + timer.getTime(),desc="",noPilot = true}
|
csar.currentlyDisabled[_unit:getName()] = {timeout = (csar.disableTimeoutTime*60) + timer.getTime(),desc="",noPilot = true,unitId=_unit:getID() }
|
||||||
|
|
||||||
|
-- disable aircraft
|
||||||
|
if csar.enableSlotBlocking then
|
||||||
|
|
||||||
|
trigger.action.setUserFlag(_unit:getID(),100)
|
||||||
|
|
||||||
|
env.info("Unit Disabled: ".._unit:getName().." ID:".._unit:getID())
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return
|
return
|
||||||
@@ -332,8 +347,15 @@ function csar.eventHandler:onEvent(_event)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if _disable then
|
if _disable then
|
||||||
csar.currentlyDisabled[_unit:getName()] = {timeout = (csar.disableTimeoutTime*60) + timer.getTime(),desc=_text, noPilot = false}
|
csar.currentlyDisabled[_unit:getName()] = {timeout = (csar.disableTimeoutTime*60) + timer.getTime(),desc=_text, noPilot = false,unitId=_unit:getID()}
|
||||||
-- timer.scheduleFunction(csar.checkDisabledAircraftStatus, _unit:getName(), timer.getTime() + 1)
|
-- timer.scheduleFunction(csar.checkDisabledAircraftStatus, _unit:getName(), timer.getTime() + 1)
|
||||||
|
-- disable aircraft
|
||||||
|
if csar.enableSlotBlocking then
|
||||||
|
|
||||||
|
trigger.action.setUserFlag(_unit:getID(),100)
|
||||||
|
|
||||||
|
env.info("Unit Disabled: ".._unit:getName().." ID:".._unit:getID())
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -347,21 +369,31 @@ function csar.eventHandler:onEvent(_event)
|
|||||||
|
|
||||||
if csar.allowFARPRescue then
|
if csar.allowFARPRescue then
|
||||||
|
|
||||||
|
-- env.info("Landing")
|
||||||
|
|
||||||
local _unit = _event.initiator
|
local _unit = _event.initiator
|
||||||
|
|
||||||
if _unit == nil then
|
if _unit == nil then
|
||||||
|
-- env.info("Unit Nil on Landing")
|
||||||
return -- error!
|
return -- error!
|
||||||
end
|
end
|
||||||
|
|
||||||
local _place = _event.place
|
local _place = _event.place
|
||||||
|
|
||||||
if _place == nil then
|
if _place == nil then
|
||||||
|
-- env.info("Landing Place Nil")
|
||||||
return -- error!
|
return -- error!
|
||||||
end
|
end
|
||||||
|
-- Coalition == 3 seems to be a bug... unless it means contested?!
|
||||||
if _place:getCoalition() == _unit:getCoalition() or _place:getCoalition() == 0 then
|
if _place:getCoalition() == _unit:getCoalition() or _place:getCoalition() == 0 or _place:getCoalition() == 3 then
|
||||||
csar.rescuePilots(_unit)
|
csar.rescuePilots(_unit)
|
||||||
--env.info("Rescued")
|
--env.info("Rescued")
|
||||||
|
-- env.info("Rescued by Landing")
|
||||||
|
|
||||||
|
else
|
||||||
|
-- env.info("Cant Rescue ")
|
||||||
|
|
||||||
|
-- env.info(string.format("airfield %d, unit %d",_place:getCoalition(),_unit:getCoalition()))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -374,6 +406,18 @@ function csar.eventHandler:onEvent(_event)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function csar.enableAircraft(_name)
|
||||||
|
--remove from disabled
|
||||||
|
local _disabledAircraft = csar.currentlyDisabled[_name]
|
||||||
|
|
||||||
|
if _disabledAircraft ~= nil and csar.enableSlotBlocking then
|
||||||
|
trigger.action.setUserFlag(_disabledAircraft.unitId,0)
|
||||||
|
env.info("Unit Enable: ".._name.." ID:".._disabledAircraft.unitId)
|
||||||
|
end
|
||||||
|
|
||||||
|
csar.currentlyDisabled[_name] = nil
|
||||||
|
end
|
||||||
|
|
||||||
function csar.checkDisabledAircraftStatus(_name)
|
function csar.checkDisabledAircraftStatus(_name)
|
||||||
|
|
||||||
local _details = csar.currentlyDisabled[_name]
|
local _details = csar.currentlyDisabled[_name]
|
||||||
@@ -382,8 +426,7 @@ function csar.checkDisabledAircraftStatus(_name)
|
|||||||
|
|
||||||
if csar.disableAircraftTimeout and timer.getTime() >= _details.timeout then
|
if csar.disableAircraftTimeout and timer.getTime() >= _details.timeout then
|
||||||
|
|
||||||
--remove from disabled
|
csar.enableAircraft(_name)
|
||||||
csar.currentlyDisabled[_name] = nil
|
|
||||||
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@@ -433,14 +476,14 @@ function csar.destroyUnit(_unit)
|
|||||||
-- if a new player got in it'll be destroyed in a bit anyways
|
-- if a new player got in it'll be destroyed in a bit anyways
|
||||||
if _unit ~= nil and _unit:getPlayerName() ~= nil then
|
if _unit ~= nil and _unit:getPlayerName() ~= nil then
|
||||||
|
|
||||||
if csar.heightDiff(_unit) > csar.destructionHeight then
|
if csar.heightDiff(_unit) > csar.destructionHeight then
|
||||||
|
|
||||||
csar.displayMessageToSAR(_unit, "Aircraft Destroyed as the pilot needs to be rescued!", 10,true)
|
csar.displayMessageToSAR(_unit, "Aircraft Destroyed as the pilot needs to be rescued!", 10,true)
|
||||||
--if we're off the ground then explode
|
--if we're off the ground then explode
|
||||||
trigger.action.explosion(_unit:getPoint(),100);
|
trigger.action.explosion(_unit:getPoint(),100);
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
--_unit:destroy() destroy doesnt work for playes who arent the host in multiplayer
|
--_unit:destroy() destroy doesnt work for playes who arent the host in multiplayer
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -885,7 +928,8 @@ function csar.scheduledSARFlight(_args)
|
|||||||
|
|
||||||
-- enable pilots again
|
-- enable pilots again
|
||||||
for _, _rescueGroup in pairs(_rescuedGroups) do
|
for _, _rescueGroup in pairs(_rescuedGroups) do
|
||||||
csar.currentlyDisabled[_rescueGroup.originalUnit] = nil
|
|
||||||
|
csar.enableAircraft(_rescueGroup.originalUnit)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -904,11 +948,11 @@ function csar.scheduledSARFlight(_args)
|
|||||||
local _dist = csar.getClosetMASH(_heliUnit)
|
local _dist = csar.getClosetMASH(_heliUnit)
|
||||||
|
|
||||||
if _dist == -1 then
|
if _dist == -1 then
|
||||||
-- Can now rescue to FARP
|
-- Can now rescue to FARP
|
||||||
-- Mash Dead
|
-- Mash Dead
|
||||||
-- csar.inTransitGroups[_heliUnit:getName()][_woundedGroupName] = nil
|
-- csar.inTransitGroups[_heliUnit:getName()][_woundedGroupName] = nil
|
||||||
|
|
||||||
-- csar.displayMessageToSAR(_heliUnit, string.format("%s: NO MASH! The pilot died of despair!", _heliUnit:getName()), 10)
|
-- csar.displayMessageToSAR(_heliUnit, string.format("%s: NO MASH! The pilot died of despair!", _heliUnit:getName()), 10)
|
||||||
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@@ -948,12 +992,13 @@ function csar.rescuePilots(_heliUnit)
|
|||||||
|
|
||||||
-- enable pilots again
|
-- enable pilots again
|
||||||
for _, _rescueGroup in pairs(_rescuedGroups) do
|
for _, _rescueGroup in pairs(_rescuedGroups) do
|
||||||
csar.currentlyDisabled[_rescueGroup.originalUnit] = nil
|
|
||||||
|
csar.enableAircraft(_rescueGroup.originalUnit)
|
||||||
end
|
end
|
||||||
|
|
||||||
csar.displayMessageToSAR(_heliUnit, _txt, 10)
|
csar.displayMessageToSAR(_heliUnit, _txt, 10)
|
||||||
|
|
||||||
env.info("Rescued")
|
-- env.info("Rescued")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
BIN
csar-test.miz
BIN
csar-test.miz
Binary file not shown.
152
csarSlotBlockGameGUI.lua
Normal file
152
csarSlotBlockGameGUI.lua
Normal file
@@ -0,0 +1,152 @@
|
|||||||
|
local csarSlotBlock = {} -- DONT REMOVE!!!
|
||||||
|
--[[
|
||||||
|
|
||||||
|
CSAR Slot Blocking - V1.8.3
|
||||||
|
|
||||||
|
Put this file in C:/Users/<YOUR USERNAME>/DCS/Scripts for 1.5 or C:/Users/<YOUR USERNAME>/DCS.openalpha/Scripts for 2.0
|
||||||
|
|
||||||
|
This script will use flags to disable and enable slots when a pilot is shot down and ejects.
|
||||||
|
|
||||||
|
*** NOTE: if you're using FLAGS in your mission, pick high values, above 1000 for flag numbers so this script doesn't interfere
|
||||||
|
with your mission flags ***
|
||||||
|
|
||||||
|
]]
|
||||||
|
|
||||||
|
csarSlotBlock.showEnabledMessage = true -- if set to true, the player will be told that the slot is enabled when switching to it
|
||||||
|
csarSlotBlock.version = "1.8.3"
|
||||||
|
|
||||||
|
-- Logic for determining if player is allowed in a slot
|
||||||
|
function csarSlotBlock.shouldAllowSlot(_playerID, _slotID) -- _slotID == Unit ID unless its multi aircraft in which case slotID is unitId_seatID
|
||||||
|
|
||||||
|
|
||||||
|
local _unitId = csarSlotBlock.getUnitId(_slotID);
|
||||||
|
|
||||||
|
local _status,_error = net.dostring_in('server', " return trigger.misc.getUserFlag(".._unitId.."); ")
|
||||||
|
|
||||||
|
if not _status and _error then
|
||||||
|
net.log("error getting flag: ".._error)
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
-- net.log("flag value ".._unitId.." value: ".._status)
|
||||||
|
|
||||||
|
--disabled
|
||||||
|
if tonumber(_status) == 100 then
|
||||||
|
return false
|
||||||
|
else
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
-- _slotID == Unit ID unless its multi aircraft in which case slotID is unitId_seatID
|
||||||
|
function csarSlotBlock.getUnitId(_slotID)
|
||||||
|
local _unitId = tostring(_slotID)
|
||||||
|
if string.find(tostring(_unitId),"_",1,true) then
|
||||||
|
--extract substring
|
||||||
|
_unitId = string.sub(_unitId,1,string.find(_unitId,"_",1,true))
|
||||||
|
net.log("Unit ID Substr ".._unitId)
|
||||||
|
end
|
||||||
|
|
||||||
|
return tonumber(_unitId)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--DOC
|
||||||
|
-- onGameEvent(eventName,arg1,arg2,arg3,arg4)
|
||||||
|
--"friendly_fire", playerID, weaponName, victimPlayerID
|
||||||
|
--"mission_end", winner, msg
|
||||||
|
--"kill", killerPlayerID, killerUnitType, killerSide, victimPlayerID, victimUnitType, victimSide, weaponName
|
||||||
|
--"self_kill", playerID
|
||||||
|
--"change_slot", playerID, slotID, prevSide
|
||||||
|
--"connect", id, name
|
||||||
|
--"disconnect", ID_, name, playerSide
|
||||||
|
--"crash", playerID, unit_missionID
|
||||||
|
--"eject", playerID, unit_missionID
|
||||||
|
--"takeoff", playerID, unit_missionID, airdromeName
|
||||||
|
--"landing", playerID, unit_missionID, airdromeName
|
||||||
|
--"pilot_death", playerID, unit_missionID
|
||||||
|
--
|
||||||
|
csarSlotBlock.onGameEvent = function(eventName,playerID,arg2,arg3,arg4) -- This stops the user flying again after crashing or other events
|
||||||
|
|
||||||
|
if DCS.isServer() and DCS.isMultiplayer() then
|
||||||
|
if DCS.getModelTime() > 1 then -- must check this to prevent a possible CTD by using a_do_script before the game is ready to use a_do_script. -- Source GRIMES :)
|
||||||
|
|
||||||
|
if eventName ~= "connect"
|
||||||
|
and eventName ~= "disconnect"
|
||||||
|
and eventName ~= "mission_end"
|
||||||
|
and eventName ~= "change_slot" then
|
||||||
|
|
||||||
|
-- is player in a slot and valid?
|
||||||
|
local _playerDetails = net.get_player_info(playerID)
|
||||||
|
|
||||||
|
if _playerDetails ~=nil and _playerDetails.side ~= 0 and _playerDetails.slot ~= "" and _playerDetails.slot ~= nil then
|
||||||
|
|
||||||
|
local _allow = csarSlotBlock.shouldAllowSlot(playerID, _playerDetails.slot)
|
||||||
|
|
||||||
|
if not _allow then
|
||||||
|
csarSlotBlock.rejectPlayer(playerID)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
csarSlotBlock.onPlayerTryChangeSlot = function(playerID, side, slotID)
|
||||||
|
|
||||||
|
if DCS.isServer() and DCS.isMultiplayer() then
|
||||||
|
if (side ~=0 and slotID ~='' and slotID ~= nil) then
|
||||||
|
|
||||||
|
local _allow = csarSlotBlock.shouldAllowSlot(playerID,slotID)
|
||||||
|
|
||||||
|
if not _allow then
|
||||||
|
csarSlotBlock.rejectPlayer(playerID)
|
||||||
|
|
||||||
|
return false
|
||||||
|
else
|
||||||
|
|
||||||
|
local _playerName = net.get_player_info(playerID, 'name')
|
||||||
|
|
||||||
|
if _playerName ~= nil and csarSlotBlock.showEnabledMessage then
|
||||||
|
--Disable chat message to user
|
||||||
|
local _chatMessage = string.format("*** %s - Aircraft Enabled! If you eject you will need to be rescued by CSAR. Protect the Helis! ***",_playerName)
|
||||||
|
net.send_chat_to(_chatMessage, playerID)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
net.log("CSAR - allowing - playerid: "..playerID.." side:"..side.." slot: "..slotID)
|
||||||
|
end
|
||||||
|
|
||||||
|
return true
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
csarSlotBlock.rejectPlayer = function(playerID)
|
||||||
|
net.log("Reject Slot - force spectators - "..playerID)
|
||||||
|
|
||||||
|
-- put to spectators
|
||||||
|
net.force_player_slot(playerID, 0, '')
|
||||||
|
|
||||||
|
local _playerName = net.get_player_info(playerID, 'name')
|
||||||
|
|
||||||
|
if _playerName ~= nil then
|
||||||
|
--Disable chat message to user
|
||||||
|
local _chatMessage = string.format("*** Sorry %s - Slot DISABLED, Pilot has been shot down and needs to be rescued by CSAR ***",_playerName)
|
||||||
|
net.send_chat_to(_chatMessage, playerID)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
csarSlotBlock.trimStr = function(_str)
|
||||||
|
|
||||||
|
return string.format( "%s", _str:match( "^%s*(.-)%s*$" ) )
|
||||||
|
end
|
||||||
|
|
||||||
|
DCS.setUserCallbacks(csarSlotBlock)
|
||||||
|
|
||||||
|
net.log("Loaded - CSAR SLOT BLOCK k v"..csarSlotBlock.version.. " by Ciribob")
|
||||||
Reference in New Issue
Block a user