mirror of
https://github.com/citizenfx/cfx-server-data.git
synced 2025-12-12 14:24:02 +01:00
initial
This commit is contained in:
31
resources/[system]/sessionmanager/client/leavehandler.lua
Normal file
31
resources/[system]/sessionmanager/client/leavehandler.lua
Normal file
@@ -0,0 +1,31 @@
|
||||
-- handles the script end of the flag the 'leave game' option in the pause menu sets
|
||||
CreateThread(function()
|
||||
while true do
|
||||
Wait(0)
|
||||
|
||||
-- if the flag is set
|
||||
if DoesGameCodeWantToLeaveNetworkSession() then
|
||||
-- if we're part of a started session; end it first (FIXME: will this break others when we're host?)
|
||||
if NetworkIsSessionStarted() then
|
||||
NetworkEndSession()
|
||||
|
||||
-- wait for the session to be ended
|
||||
while NetworkEndSessionPending() do
|
||||
Wait(0)
|
||||
end
|
||||
end
|
||||
|
||||
-- attempt to leave the game
|
||||
NetworkLeaveGame()
|
||||
|
||||
-- while we're waiting to leave...
|
||||
while NetworkLeaveGamePending() do
|
||||
Wait(0)
|
||||
end
|
||||
|
||||
-- reinitialize the game as a network game (TODO: call into citigame for UI/NetLibrary leaving)
|
||||
--ShutdownAndLaunchNetworkGame(0) -- episode id is arg
|
||||
ShutdownNetworkCit('Left');
|
||||
end
|
||||
end
|
||||
end)
|
||||
Reference in New Issue
Block a user