Skip to content

Commit

Permalink
Mood cycles
Browse files Browse the repository at this point in the history
  • Loading branch information
aaron1a12 committed Mar 1, 2021
1 parent b037d55 commit 91c0a28
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 18 deletions.
3 changes: 2 additions & 1 deletion client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ AddEventHandler("factions:cl_onRoundEnd", function(timeLeft, cbId)
end)
RegisterNetEvent("factions:cl_onRoundEnd")

AddEventHandler("factions:cl_onResetRound", function(timeLeft, cbId)
AddEventHandler("factions:cl_onResetRound", function(RoundInfo)
respawnPed()
SetPlayerControl(PlayerId(), true)
SendNUIMessage({name = 'onResetRound'})
end)
Expand Down
17 changes: 16 additions & 1 deletion config.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
Config = {}

Config.Round = {
["DefaultTime"] = 10, --60 * 4,
["DefaultTime"] = 60 * 4, --60 * 4,
}

Config.Moods = {
{
['Hour'] = 12,
['Look'] = 'int_Lost_small',
['Intensity'] = 0.9,
['Weather'] = 'FOGGY'
},
{
['Hour'] = 0,
['Look'] = 'lab_none_exit_OVR',
['Intensity'] = 0.95,
['Weather'] = 'FOGGY'
}
}
34 changes: 21 additions & 13 deletions mood.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

local weatherType = "FOGGY"

local currentMood = nil

-- Disable normal peds

Citizen.CreateThread(function()
Expand All @@ -24,7 +26,7 @@ end)

Citizen.CreateThread(function()
while true do
Citizen.Wait(1000)
Citizen.Wait(100)

-- Disable ambient sounds
StartAudioScene("CHARACTER_CHANGE_IN_SKY_SCENE")
Expand All @@ -35,20 +37,26 @@ Citizen.CreateThread(function()
-- No power
SetBlackout(true)

ClearOverrideWeather()
ClearWeatherTypePersist()
SetWeatherTypePersist(weatherType)
SetWeatherTypeNow(weatherType)
SetWeatherTypeNowPersist(weatherType)

NetworkOverrideClockTime(12, 0, 0)

-- Hide the radar
DisplayRadar(true)
DisplayRadar(false)

if currentMood ~= nil then
ClearOverrideWeather()
ClearWeatherTypePersist()
SetWeatherTypePersist(currentMood.Weather)
SetWeatherTypeNow(currentMood.Weather)
SetWeatherTypeNowPersist(currentMood.Weather)

NetworkOverrideClockTime(currentMood.Hour, 0, 0)
SetTimecycleModifier(currentMood.Look)
SetTimecycleModifierStrength(currentMood.Intensity)
end
end
end)


SetTimecycleModifier("int_Lost_small")
SetTimecycleModifierStrength(0.9)

AddEventHandler("factions:cl_onResetRound", function(RoundInfo)
print("Setting New Mood")
currentMood = RoundInfo.CurrentMood
end)
RegisterNetEvent("factions:cl_onResetRound")
6 changes: 4 additions & 2 deletions respawn.lua
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,13 @@ local bPlayerHasDied = false
function respawnPed()
local newSpawnPoint = spawnPoints[ math.random( #spawnPoints ) ]
NetworkResurrectLocalPlayer(newSpawnPoint.x, newSpawnPoint.y, newSpawnPoint.z, newSpawnPoint.h, true, false)



local playerPed = GetPlayerPed(-1)

-- Enable pvp
NetworkSetFriendlyFireOption(true)
SetCanAttackFriendly(playerPed, true, true)

-- Give weapon set
GiveWeaponToPed(playerPed, GetHashKey("WEAPON_REVOLVER"), 22, false, false)
GiveWeaponToPed(playerPed, GetHashKey("WEAPON_PISTOL"), 22, false, false)
Expand Down
3 changes: 2 additions & 1 deletion server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ local Round = {}

function ResetRound()
Round.TimeLeft = Config.Round.DefaultTime
Round.CurrentMood = Config.Moods[ math.random( #Config.Moods ) ]

TriggerClientEvent('factions:cl_onResetRound', -1)
TriggerClientEvent('factions:cl_onResetRound', -1, Round)
end ResetRound()

function OnRoundEnd()
Expand Down

0 comments on commit 91c0a28

Please sign in to comment.