add events

This commit is contained in:
Not
2023-09-15 20:06:30 +02:00
parent ef4c43161d
commit ea01c4db77
2 changed files with 31 additions and 0 deletions

View File

@ -10,6 +10,7 @@ local lbComp = lb_comp
local mapChecksum = lb_map_checksum
local score_t = lb_score_t
local mapnumFromExtended = lb_mapnum_from_extended
local fireEvent = lb_fire_event
-- browser.lua
local InitBrowser = InitBrowser
@ -107,6 +108,9 @@ local scroll_to
local allowJoin
-- Events
local EVENT_FINISH = "Finish"
-- cvars
local cv_teamchange
@ -1157,6 +1161,9 @@ local function saveTime(player)
if checkFlags(player) != Flags then
print("Game mode change detected! Time has been disqualified.")
S_StartSound(nil, 110)
fireEvent(EVENT_FINISH, {
disqualified = true,
})
return
end
@ -1185,6 +1192,7 @@ local function saveTime(player)
FlashRate = 3
FlashVFlags = RedFlash
scroll_to(player)
fireEvent(EVENT_FINISH, {score = newscore})
return
end
end
@ -1206,6 +1214,12 @@ local function saveTime(player)
-- Set the updated ScoreTable
ScoreTable = MapRecords[Flags]
for i, score in ipairs(ScoreTable) do
if score.name != player.name then continue end
fireEvent(EVENT_FINISH, {position = i, score = newscore})
break
end
-- Scroll the gui to the player entry
scroll_to(player)
end