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:
55
resources/[system]/sessionmanager/client/hostservice.lua
Normal file
55
resources/[system]/sessionmanager/client/hostservice.lua
Normal file
@@ -0,0 +1,55 @@
|
||||
-- serving the duties of the office of the host
|
||||
|
||||
-- two functions from GTA script; they do 'something lock-ish'
|
||||
local function acquireHostLock()
|
||||
if IsThisMachineTheServer() then
|
||||
SetThisMachineRunningServerScript(true)
|
||||
return true
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
local function releaseHostLock()
|
||||
SetThisMachineRunningServerScript(false)
|
||||
end
|
||||
|
||||
-- handle msgGetReadyToStartPlaying sending
|
||||
function serviceHostStuff()
|
||||
-- acquire the host lock
|
||||
if acquireHostLock() then
|
||||
-- check if players want to join
|
||||
for i = 0, 31 do
|
||||
-- does this index?
|
||||
if PlayerWantsToJoinNetworkGame(i) then
|
||||
-- well, get ready to start playing!
|
||||
TellNetPlayerToStartPlaying(i, 0)
|
||||
|
||||
TriggerServerEvent('playerJoining', i)
|
||||
end
|
||||
end
|
||||
|
||||
-- release the host lock
|
||||
releaseHostLock()
|
||||
end
|
||||
end
|
||||
|
||||
-- host service loop
|
||||
CreateThread(function()
|
||||
NetworkSetScriptLobbyState(false)
|
||||
SwitchArrowAboveBlippedPickups(true)
|
||||
UsePlayerColourInsteadOfTeamColour(true)
|
||||
LoadAllPathNodes(true)
|
||||
SetSyncWeatherAndGameTime(true)
|
||||
|
||||
while true do
|
||||
Wait(0)
|
||||
|
||||
serviceHostStuff()
|
||||
|
||||
-- launch the local player, for the initial host scenario
|
||||
if LocalPlayerIsReadyToStartPlaying() then
|
||||
LaunchLocalPlayerInNetworkGame()
|
||||
end
|
||||
end
|
||||
end)
|
||||
Reference in New Issue
Block a user