Version 2.1.0

Shared Persistence, Stop Gap
This commit is contained in:
Christian Franz
2024-03-07 09:04:15 +01:00
parent a44f145218
commit 6088c4cfa1
15 changed files with 341 additions and 74 deletions

View File

@@ -1,5 +1,5 @@
stopGap = {}
stopGap.version = "1.0.9 STANDALONE"
stopGap.version = "1.1.0 STANDALONE"
stopGap.verbose = false
stopGap.ssbEnabled = true
stopGap.ignoreMe = "-sg"
@@ -7,6 +7,7 @@ stopGap.spIgnore = "-sp" -- only single-player ignored
stopGap.isMP = false
stopGap.running = true
stopGap.refreshInterval = -1 -- seconds to refresh all statics. -1 = never, 3600 = once every hour
stopGap.kickTheDead = true -- kick players to spectators on death to prevent re-entry issues
--[[--
Written and (c) 2023 by Christian Franz
@@ -34,6 +35,8 @@ stopGap.refreshInterval = -1 -- seconds to refresh all statics. -1 = never, 3600
1.0.7 - (DML-only internal cool stuff)
1.0.8 - added refreshInterval option as requested
1.0.9 - optimization when turning on stopgap
1.1.0 - kickTheDead option
--]]--
stopGap.standInGroups ={}
@@ -253,11 +256,11 @@ function stopGap:onEvent(event)
if not event.id then return end
if not event.initiator then return end
local theUnit = event.initiator
if event.id == 15 then
if (not theUnit.getPlayerName) or (not theUnit:getPlayerName()) then
return
end -- no player unit.
if (not theUnit.getPlayerName) or (not theUnit:getPlayerName()) then
return
end -- no player unit.
local id = event.id
if id == 15 then
local uName = theUnit:getName()
local theGroup = theUnit:getGroup()
local gName = theGroup:getName()
@@ -269,13 +272,31 @@ function stopGap:onEvent(event)
stopGap.removeStaticGapGroupNamed(gName)
end
end
-- erase stopGapGUI flag, no longer required, unit
-- is now slotted into
trigger.action.setUserFlag("SG"..gName, 0)
end
if (id == 9) or (id == 30) or (id == 5) then -- dead, lost, crash
local pName = theUnit:getPlayerName()
timer.scheduleFunction(stopGap.kickplayer, pName, timer.getTime() + 1)
end
end
stopGap.kicks = {}
function stopGap.kickplayer(args)
if not stopGap.kickTheDead then return end
local pName = args
for i,slot in pairs(net.get_player_list()) do
local nn = net.get_name(slot)
if nn == pName then
if stopGap.kicks[nn] then
if timer.getTime() < stopGap.kicks[nn] then return end
end
net.force_player_slot(slot, 0, '')
stopGap.kicks[nn] = timer.getTime() + 5 -- avoid too many kicks in 5 seconds
end
end
end
--
-- update
--