diff --git a/ReallifeGamemode.Client/ReallifeGamemode.Client.csproj b/ReallifeGamemode.Client/ReallifeGamemode.Client.csproj index e9e3931d..5126aeaf 100644 --- a/ReallifeGamemode.Client/ReallifeGamemode.Client.csproj +++ b/ReallifeGamemode.Client/ReallifeGamemode.Client.csproj @@ -33,6 +33,7 @@ + diff --git a/ReallifeGamemode.Client/assets/html/sound/index.html b/ReallifeGamemode.Client/assets/html/sound/index.html new file mode 100644 index 00000000..8a8d1b3a --- /dev/null +++ b/ReallifeGamemode.Client/assets/html/sound/index.html @@ -0,0 +1,32 @@ + + + + + + + Sound + + + + + + + \ No newline at end of file diff --git a/ReallifeGamemode.Client/assets/sound/jobs/busfahrer/AbfahrtHaltestelle.mp3 b/ReallifeGamemode.Client/assets/sound/jobs/busfahrer/AbfahrtHaltestelle.mp3 new file mode 100644 index 00000000..de358650 Binary files /dev/null and b/ReallifeGamemode.Client/assets/sound/jobs/busfahrer/AbfahrtHaltestelle.mp3 differ diff --git a/ReallifeGamemode.Client/assets/sound/jobs/busfahrer/AnfahrtHaltestelle.wav b/ReallifeGamemode.Client/assets/sound/jobs/busfahrer/AnfahrtHaltestelle.wav new file mode 100644 index 00000000..43809632 Binary files /dev/null and b/ReallifeGamemode.Client/assets/sound/jobs/busfahrer/AnfahrtHaltestelle.wav differ diff --git a/ReallifeGamemode.Client/assets/sound/jobs/busfahrer/FahrplanAbfahrt.wav b/ReallifeGamemode.Client/assets/sound/jobs/busfahrer/FahrplanAbfahrt.wav new file mode 100644 index 00000000..21b9c8e4 Binary files /dev/null and b/ReallifeGamemode.Client/assets/sound/jobs/busfahrer/FahrplanAbfahrt.wav differ diff --git a/ReallifeGamemode.Client/assets/sound/jobs/busfahrer/StartJob.wav b/ReallifeGamemode.Client/assets/sound/jobs/busfahrer/StartJob.wav new file mode 100644 index 00000000..bd3f94cb Binary files /dev/null and b/ReallifeGamemode.Client/assets/sound/jobs/busfahrer/StartJob.wav differ diff --git a/ReallifeGamemode.Client/assets/sound/music/mukke.mp3 b/ReallifeGamemode.Client/assets/sound/music/mukke.mp3 new file mode 100644 index 00000000..2664d830 Binary files /dev/null and b/ReallifeGamemode.Client/assets/sound/music/mukke.mp3 differ diff --git a/ReallifeGamemode.Client/index.ts b/ReallifeGamemode.Client/index.ts index ad9d1d4a..30471741 100644 --- a/ReallifeGamemode.Client/index.ts +++ b/ReallifeGamemode.Client/index.ts @@ -197,6 +197,9 @@ gangwarHandle(globalData); import weapondamageUtil from './util/weapondamage'; weapondamageUtil(); +import soundUtil from './util/sound'; +soundUtil(); + import clotheShopList from './Interaction/clothes/ClotheShop'; clotheShopList(globalData); diff --git a/ReallifeGamemode.Client/util/checkpoint.ts b/ReallifeGamemode.Client/util/checkpoint.ts index 334d0ffa..c7e9b540 100644 --- a/ReallifeGamemode.Client/util/checkpoint.ts +++ b/ReallifeGamemode.Client/util/checkpoint.ts @@ -76,6 +76,7 @@ export default function checkpointHandle(globalData: IGlobalData) { textTime = setInterval(ClearText, delay) } mp.game.audio.playSoundFrontend(1, "Beep_Red", "DLC_HEIST_HACKING_SNAKE_SOUNDS", true); + mp.events.callRemote("playerWaitsInCheckpoint"); } inCheckpoint = true; diff --git a/ReallifeGamemode.Client/util/sound.ts b/ReallifeGamemode.Client/util/sound.ts new file mode 100644 index 00000000..36794e12 --- /dev/null +++ b/ReallifeGamemode.Client/util/sound.ts @@ -0,0 +1,33 @@ +var soundBrowser; + +export default function weapondamageUtil() { + mp.events.add('CLIENT:PlaySound', (sound, typ, volume) => { + //mp.gui.chat.push("Debugstart1"); + mp.events.call('sound:cancel'); + mp.events.call('sound:play', sound, typ, volume/100); + //mp.gui.chat.push("Debugstart2"); + }); + mp.events.add('CLIENT:StopSound', () => { + //mp.gui.chat.push("Debugstop1"); + mp.events.call('sound:cancel'); + //mp.gui.chat.push("Debugstop2"); + }); + mp.events.add({ + 'sound:play': (name, typ, volume) => { + if (soundBrowser == null) { + soundBrowser = mp.browsers.new("package://assets/html/sound/index.html"); + //mp.gui.chat.push("Debugstart3"); + soundBrowser.execute(`playSound("${name}", "${typ}", "${volume}")`); + //mp.gui.chat.push("Debugstart4"); + } + }, + 'sound:cancel': () => { + if (soundBrowser != null) { + //mp.gui.chat.push("Debugstop3"); + soundBrowser.destroy(); + //mp.gui.chat.push("Debugstop4"); + soundBrowser = null; + } + } + }) +} \ No newline at end of file diff --git a/ReallifeGamemode.Server/Commands/AdminCommands.cs b/ReallifeGamemode.Server/Commands/AdminCommands.cs index 5034b917..e2a3527d 100644 --- a/ReallifeGamemode.Server/Commands/AdminCommands.cs +++ b/ReallifeGamemode.Server/Commands/AdminCommands.cs @@ -2598,7 +2598,26 @@ namespace ReallifeGamemode.Server.Commands player.TriggerEvent("manageFactionRanks", json); } } - + [Command("aplaysound", "~m~Benutzung: ~s~/aplaysound [Dateiname] [mp3/wav] [volume 0.0 - 1.0]", Alias ="aps")] + public void CmdAdminPlaySound(Player player, string sound, string typ, double volume = 100) + { + if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) + { + ChatService.NotAuthorized(player); + return; + } + player.TriggerEvent("CLIENT:PlaySound", sound, typ, volume); + } + [Command("astopsound", "~m~Benutzung: ~s~/astopsound", Alias="ass")] + public void CmdAdminStopSound(Player player) + { + if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) + { + ChatService.NotAuthorized(player); + return; + } + player.TriggerEvent("CLIENT:StopSound"); + } [Command("aspeed", "~m~Benutzung: ~s~/aspeed [Modifier]")] //TODO: Überarbeiten ?? SetPlayerVelocity ?? public void CmdAdminAspeed(Player player, int modifier) { diff --git a/ReallifeGamemode.Server/Job/BusDriverJob.cs b/ReallifeGamemode.Server/Job/BusDriverJob.cs index ed54d183..bfec2710 100644 --- a/ReallifeGamemode.Server/Job/BusDriverJob.cs +++ b/ReallifeGamemode.Server/Job/BusDriverJob.cs @@ -156,6 +156,7 @@ namespace ReallifeGamemode.Server.Job { CheckPointHandle.StartCheckPointRoute(player, RouteVeryLong, 3000, 1, 7, 5, "busDriverJob"); } + player.TriggerEvent("CLIENT:PlaySound", "jobs/busfahrer/StartJob", "wav", 50); } } diff --git a/ReallifeGamemode.Server/Util/CheckPointHandle.cs b/ReallifeGamemode.Server/Util/CheckPointHandle.cs index ccb57c51..f4727bfb 100644 --- a/ReallifeGamemode.Server/Util/CheckPointHandle.cs +++ b/ReallifeGamemode.Server/Util/CheckPointHandle.cs @@ -45,6 +45,15 @@ namespace ReallifeGamemode.Server.Util } } + [RemoteEvent("playerWaitsInCheckpoint")] + public void PlayerWaitsInCheckpoint(Player user) + { + if (user.GetUser().JobId == 4) + { + user.TriggerEvent("CLIENT:PlaySound", "jobs/busfahrer/AnfahrtHaltestelle", "wav", 50); + } + } + [RemoteEvent("playerInCheckpoint")] public void PlayerInCheckpoint(Player user) { @@ -66,6 +75,7 @@ namespace ReallifeGamemode.Server.Util if (user.GetUser().JobId == 4) { BusDriverJob.payWage(user, 100); + user.TriggerEvent("CLIENT:PlaySound", "jobs/busfahrer/AbfahrtHaltestelle", "mp3", 50); } } else