Customization
We provide advanced and flexible set of customization options:
Events
To manually enable/disable starting point you can use Global Statebag like this:
-- server.lua
GlobalState['easter-game:startPointEnabled'] = true -- Enable
GlobalState['easter-game:startPointEnabled'] = false -- Disable
To receive match results on your side (for example if you'd like to give additional reward):
-- server.lua
AddEventHandler('easter-game:gameStopped', function(playerResults)
-- Game stopped
for k,v in ipairs(playerResults) do
print(v.playerId, v.name, v.eggs, v.reward)
end
end)
AddEventHandler('easter-game:gameStarted', function()
-- Game started
end)
Example
Controls a game mode with a starting point that activates periodically, notifies players, and handles game start/stop events.
local COOLTIME = 1 * 10 * 1000
local PRE_NOTIFY = 1 * 10 * 1000
local isActivationThreadRunning = false
local isGameStarted = false
AddEventHandler('easter-game:gameStarted', function()
isGameStarted = true
disableStartingPoint()
end)
AddEventHandler('easter-game:gameStopped', function(playerResults)
isGameStarted = false
print('Cooldown 10 seconds')
Wait(COOLTIME)
startPointActivationThread()
end)
local startingPointEnabled = false
function enableStartingPoint()
startingPointEnabled = true
GlobalState['easter-game:startPointEnabled'] = true
end
function disableStartingPoint()
startingPointEnabled = false
GlobalState['easter-game:startPointEnabled'] = false
end
local function notifyAll(text, duration)
print('notify', text)
end
function startPointActivationThread()
if isActivationThreadRunning then return end
isActivationThreadRunning = true
CreateThread(function()
while not startingPointEnabled and not isGameStarted do
if math.random(1, 100) <= 35 then
notifyAll('Easter game will be available in 10 seconds', 10000)
Wait(PRE_NOTIFY + 1000)
notifyAll('Easter game available!', 10000)
TriggerClientEvent('easter-game-addon:client:sendNotifSound', -1)
enableStartingPoint()
end
Wait(1000)
end
isActivationThreadRunning = false
end)
end
if not startingPointEnabled then
startPointActivationThread()
end
Last updated