Ready for testing

This commit is contained in:
Ciaran Fisher
2016-03-28 22:38:18 +01:00
parent 9abe238197
commit 1310cf02a6
2 changed files with 62 additions and 52 deletions

View File

@@ -157,7 +157,7 @@ csar.enableForRED = true -- enable for red side
csar.enableForBLUE = true -- enable for blue side csar.enableForBLUE = true -- enable for blue side
csar.enableSlotBlocking = false -- if set to true, you need to put the csarSlotBlockGameGUI.lua csar.enableSlotBlocking = true -- 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 -- 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, the CSAR flags will NOT interfere with your mission :) -- For missions using FLAGS and this script, the CSAR flags will NOT interfere with your mission :)
@@ -381,9 +381,9 @@ function csar.eventHandler:onEvent(_event)
-- env.info("Rescued by Landing") -- env.info("Rescued by Landing")
else else
-- env.info("Cant Rescue ") env.info("Cant Rescue ")
-- env.info(string.format("airfield %d, unit %d",_place:getCoalition(),_unit:getCoalition())) env.info(string.format("airfield %d, unit %d",_place:getCoalition(),_unit:getCoalition()))
end end
end end
@@ -422,7 +422,7 @@ function csar.handleEjectOrCrash(_unit,_crashed)
-- disable aircraft -- disable aircraft
trigger.action.setUserFlag("CSAR_AIRCRAFT..".._unit:getID(),100) trigger.action.setUserFlag("CSAR_AIRCRAFT".._unit:getID(),100)
env.info("Unit Disabled: ".._unit:getName().." ID:".._unit:getID()) env.info("Unit Disabled: ".._unit:getName().." ID:".._unit:getID())
@@ -500,7 +500,7 @@ function csar.enableAircraft(_name,_playerName)
csar.currentlyDisabled[_name] = nil -- {timeout = (csar.disableTimeoutTime*60) + timer.getTime(),desc="",noPilot = _crashed,unitId=_unit:getID() } csar.currentlyDisabled[_name] = nil -- {timeout = (csar.disableTimeoutTime*60) + timer.getTime(),desc="",noPilot = _crashed,unitId=_unit:getID() }
--use flag to reenable --use flag to reenable
trigger.action.setUserFlag("CSAR_AIRCRAFT..".._details.unitId,0) trigger.action.setUserFlag("CSAR_AIRCRAFT".._details.unitId,0)
end end
elseif csar.csarMode == 2 and _playerName ~= nil then -- enable aircraft for pilot elseif csar.csarMode == 2 and _playerName ~= nil then -- enable aircraft for pilot
@@ -513,7 +513,7 @@ function csar.enableAircraft(_name,_playerName)
trigger.action.setUserFlag("CSAR_AIRCRAFT".._playerName:gsub('%W','').."_".._details.unitId,0) trigger.action.setUserFlag("CSAR_AIRCRAFT".._playerName:gsub('%W','').."_".._details.unitId,0)
end end
elseif csar.csarMode == 3 then -- No Disable - Just reduce player lives elseif csar.csarMode == 3 and _playerName ~= nil then -- No Disable - Just reduce player lives
-- give back life -- give back life
@@ -527,7 +527,7 @@ function csar.enableAircraft(_name,_playerName)
csar.pilotLives[_playerName] = _lives csar.pilotLives[_playerName] = _lives
trigger.action.setUserFlag("CSAR_PILOT".._unit:getPlayerName():gsub('%W',''),_lives) trigger.action.setUserFlag("CSAR_PILOT".._playerName:gsub('%W',''),_lives)
end end
end end
@@ -617,8 +617,6 @@ function csar.checkDisabledAircraftStatus(_name)
local _details = csar.pilotDisabled[_unit:getPlayerName().."_".._unit:getName()] local _details = csar.pilotDisabled[_unit:getPlayerName().."_".._unit:getName()]
local _details = csar.currentlyDisabled[_unit:getName()]
if _details ~= nil then if _details ~= nil then
local _time = _details.timeout - timer.getTime() local _time = _details.timeout - timer.getTime()

View File

@@ -19,49 +19,61 @@ csarSlotBlock.version = "1.9.0"
-- Logic for determining if player is allowed in a slot -- 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 function csarSlotBlock.shouldAllowSlot(_playerID, _slotID) -- _slotID == Unit ID unless its multi aircraft in which case slotID is unitId_seatID
if csarSlotBlock.csarSlotBlockEnabled() then if csarSlotBlock.csarSlotBlockEnabled() then
local _unitId = csarSlotBlock.getUnitId(_slotID); local _unitId = csarSlotBlock.getUnitId(_slotID);
local _mode = csarSlotBlock.csarMode() local _mode = csarSlotBlock.csarMode()
if _mode == 1 then if _mode == 1 then
-- disable aircraft for ALL pilots -- disable aircraft for ALL pilots
local _flag = csarSlotBlock.getFlagValue("CSAR_AIRCRAFT".._unitId) local _flag = csarSlotBlock.getFlagValue("CSAR_AIRCRAFT".._unitId)
if _flag == 100 then
return false
end
return true
elseif _mode == 2 then elseif _mode == 2 then
-- disable aircraft for a certain player -- disable aircraft for a certain player
local _playerName = net.get_player_info(_playerID, 'name') local _playerName = net.get_player_info(_playerID, 'name')
if _playerName == nil then if _playerName == nil then
return true return true
end end
local _flag = csarSlotBlock.getFlagValue("CSAR_AIRCRAFT".._playerName:gsub('%W','').."_".._unitId) local _flag = csarSlotBlock.getFlagValue("CSAR_AIRCRAFT".._playerName:gsub('%W','').."_".._unitId)
elseif _mode == 3 then if _flag == 100 then
-- global lives limit return false
end
local _playerName = net.get_player_info(_playerID, 'name') return true
if _playerName == nil then elseif _mode == 3 then
return true -- global lives limit
end
local _flag = csarSlotBlock.getFlagValue("CSAR_PILOT".._playerName:gsub('%W','')) local _playerName = net.get_player_info(_playerID, 'name')
if _flag == 1 then if _playerName == nil then
return false return true
else end
return true
end
local _flag = csarSlotBlock.getFlagValue("CSAR_PILOT".._playerName:gsub('%W',''))
if _flag == 1 then
return false
else
return true
end end
end end
end
return true
end end
@@ -111,29 +123,29 @@ end
-- --
csarSlotBlock.onGameEvent = function(eventName,playerID,arg2,arg3,arg4) -- This stops the user flying again after crashing or other events 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.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 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" if eventName == "self_kill"
and eventName ~= "disconnect" or eventName == "crash"
and eventName ~= "mission_end" or eventName == "eject"
and eventName ~= "change_slot" then or eventName == "pilot_death" then
-- is player in a slot and valid? -- is player in a slot and valid?
local _playerDetails = net.get_player_info(playerID) local _playerDetails = net.get_player_info(playerID)
if _playerDetails ~=nil and _playerDetails.side ~= 0 and _playerDetails.slot ~= "" and _playerDetails.slot ~= nil then if _playerDetails ~=nil and _playerDetails.side ~= 0 and _playerDetails.slot ~= "" and _playerDetails.slot ~= nil then
local _allow = csarSlotBlock.shouldAllowSlot(playerID, _playerDetails.slot) local _allow = csarSlotBlock.shouldAllowSlot(playerID, _playerDetails.slot)
if not _allow then if not _allow then
csarSlotBlock.rejectPlayer(playerID) csarSlotBlock.rejectPlayer(playerID)
end
end
end end
end end
end end
end
end
end end
csarSlotBlock.onPlayerTryChangeSlot = function(playerID, side, slotID) csarSlotBlock.onPlayerTryChangeSlot = function(playerID, side, slotID)
@@ -152,7 +164,7 @@ csarSlotBlock.onPlayerTryChangeSlot = function(playerID, side, slotID)
local _playerName = net.get_player_info(playerID, 'name') local _playerName = net.get_player_info(playerID, 'name')
if _playerName ~= nil and csarSlotBlock.showEnabledMessage and if _playerName ~= nil and csarSlotBlock.showEnabledMessage and
csarSlotBlock.csarSlotBlockEnabled() then csarSlotBlock.csarSlotBlockEnabled() and csarSlotBlock.csarMode() > 0 then
--Disable chat message to user --Disable chat message to user
local _chatMessage = string.format("*** %s - Aircraft Enabled! If you will need to be rescued by CSAR. Make sure you eject and Protect the Helis! ***",_playerName) local _chatMessage = string.format("*** %s - Aircraft Enabled! If you will need to be rescued by CSAR. Make sure you eject and Protect the Helis! ***",_playerName)
net.send_chat_to(_chatMessage, playerID) net.send_chat_to(_chatMessage, playerID)
@@ -160,9 +172,9 @@ csarSlotBlock.onPlayerTryChangeSlot = function(playerID, side, slotID)
end end
end net.log("CSAR - allowing - playerid: "..playerID.." side:"..side.." slot: "..slotID)
net.log("CSAR - allowing - playerid: "..playerID.." side:"..side.." slot: "..slotID) end
end end
return true return true