User = {}
User.Active = false

AddEventHandler("playerSpawned", function()
	DoScreenFadeOut(1)
	TriggerServerEvent("spyoo_base:spawned")
end)

RegisterNetEvent("spyoo_base:playerSpawned")
AddEventHandler("spyoo_base:playerSpawned", function(coords)
	SetEntityCoordsNoOffset(GetPlayerPed(-1), coords.x, coords.y, coords.z+1.0, false, false, false)
	SetEntityHealth(GetPlayerPed(-1), 200)
	DoScreenFadeIn(1000)
	User.Active = true
	TriggerServerEvent("spyoo_base:hasSpawn")
end)

Citizen.CreateThread(function()
	while true do
		Wait(500)
		if User.Active then
			TriggerServerEvent("spyoo_base:updateCoords", pCoords)
		end
	end
end)