diff --git a/Client/Gui/deathscreen.js b/Client/Gui/deathscreen.js index 639403b9..682dcb4f 100644 --- a/Client/Gui/deathscreen.js +++ b/Client/Gui/deathscreen.js @@ -68,7 +68,13 @@ mp.events.add("render", () => { var medicString; if (dutyMedics > 0) { - medicString = "Derzeit sind ~g~" + dutyMedics + " Medics ~s~im Dienst ~c~und versuchen dich wiederzubeleben..."; + medicString = "Derzeit "; + if (dutyMedics === 1) { + medicString += "ist ~g~" + dutyMedics + " Medic"; + } else { + medicString = "sind ~g~" + dutyMedics + " Medics"; + } + medicString += " ~s~im Dienst ~c~und versuchen dich wiederzubeleben..."; } else { medicString = "Derzeit sind ~r~keine Medics ~s~im Dienst."; } @@ -76,6 +82,7 @@ mp.events.add("render", () => { deathSeconds = respawnTime - Math.floor(currentDate.getTime() / 1000); var alpha = fade + Math.floor(currentDate.getTime() / 1000 - deathDate.getTime() / 1000); if (deathSeconds >= 0) { + mp.game.graphics.set2dLayer(2); mp.game.graphics.drawSprite("Mptattoos", "clearout", 0.625, 0.52, 0.1, 0.1, 0, 255, 255, 255, 236); mp.game.graphics.drawText("Respawn in: ~y~" + deathSeconds, [0.5, 0.5], { @@ -91,6 +98,7 @@ mp.events.add("render", () => { scale: [0.4, 0.4], outline: true }); + mp.game.graphics.set2dLayer(1); mp.game.graphics.drawRect(0.5, 0.5, 1, 1, 0, 0, 0, alpha); } else { diff --git a/Client/Player/freecam.js b/Client/Player/freecam.js new file mode 100644 index 00000000..a31d2521 --- /dev/null +++ b/Client/Player/freecam.js @@ -0,0 +1,124 @@ +const controlsIds = { + F5: 327, + W: 32, // 232 + S: 33, // 31, 219, 233, 268, 269 + A: 34, // 234 + D: 35, // 30, 218, 235, 266, 267 + Space: 321, + LCtrl: 326, +}; + +global.fly = { + flying: false, f: 2.0, w: 2.0, h: 2.0, point_distance: 1000, +}; +global.gameplayCam = mp.cameras.new('gameplay'); + +mp.game.graphics.notify('~r~Fly script loaded!'); +mp.game.graphics.notify('~r~F5~w~ - enable/disable\n~r~F5+Space~w~ - disable without warping to ground\n~r~W/A/S/D/Space/LCtrl~w~ - move'); +mp.game.graphics.notify('~r~/savecam~w~ - save Camera position.'); + +let direction = null; +let coords = null; + +function pointingAt(distance) { + const farAway = new mp.Vector3((direction.x * distance) + (coords.x), (direction.y * distance) + (coords.y), (direction.z * distance) + (coords.z)); + + const result = mp.raycasting.testPointToPoint(coords, farAway, [1, 16]); + if (result === undefined) { + return 'undefined'; + } + return result; +} + +mp.events.add('render', () => { + const controls = mp.game.controls; + const fly = global.fly; + direction = global.gameplayCam.getDirection(); + coords = global.gameplayCam.getCoord(); + + mp.game.graphics.drawText(`Coords: ${JSON.stringify(coords)}`, [0.5, 0.005], { + font: 0, + color: [255, 255, 255, 185], + scale: [0.3, 0.3], + outline: true, + }); + mp.game.graphics.drawText(`pointAtCoord: ${JSON.stringify(pointingAt(fly.point_distance).position)}`, [0.5, 0.025], { + font: 0, + color: [255, 255, 255, 185], + scale: [0.3, 0.3], + outline: true, + }); + + if (controls.isControlJustPressed(0, controlsIds.F5)) { + fly.flying = !fly.flying; + + const player = mp.players.local; + + player.setInvincible(fly.flying); + player.freezePosition(fly.flying); + player.setAlpha(fly.flying ? 0 : 255); + + if (!fly.flying && !controls.isControlPressed(0, controlsIds.Space)) { + const position = mp.players.local.position; + position.z = mp.game.gameplay.getGroundZFor3dCoord(position.x, position.y, position.z, 0.0, false); + mp.players.local.setCoordsNoOffset(position.x, position.y, position.z, false, false, false); + } + + mp.game.graphics.notify(fly.flying ? 'Fly: ~g~Enabled' : 'Fly: ~r~Disabled'); + } else if (fly.flying) { + let updated = false; + const position = mp.players.local.position; + + if (controls.isControlPressed(0, controlsIds.W)) { + if (fly.f < 8.0) { fly.f *= 1.025; } + + position.x += direction.x * fly.f; + position.y += direction.y * fly.f; + position.z += direction.z * fly.f; + updated = true; + } else if (controls.isControlPressed(0, controlsIds.S)) { + if (fly.f < 8.0) { fly.f *= 1.025; } + + position.x -= direction.x * fly.f; + position.y -= direction.y * fly.f; + position.z -= direction.z * fly.f; + updated = true; + } else { + fly.f = 2.0; + } + + if (controls.isControlPressed(0, controlsIds.A)) { + if (fly.l < 8.0) { fly.l *= 1.025; } + + position.x += (-direction.y) * fly.l; + position.y += direction.x * fly.l; + updated = true; + } else if (controls.isControlPressed(0, controlsIds.D)) { + if (fly.l < 8.0) { fly.l *= 1.05; } + + position.x -= (-direction.y) * fly.l; + position.y -= direction.x * fly.l; + updated = true; + } else { + fly.l = 2.0; + } + + if (controls.isControlPressed(0, controlsIds.Space)) { + if (fly.h < 8.0) { fly.h *= 1.025; } + + position.z += fly.h; + updated = true; + } else if (controls.isControlPressed(0, controlsIds.LCtrl)) { + if (fly.h < 8.0) { fly.h *= 1.05; } + + position.z -= fly.h; + updated = true; + } else { + fly.h = 2.0; + } + + if (updated) { + mp.players.local.setCoordsNoOffset(position.x, position.y, position.z, false, false, false); + } + } +}); \ No newline at end of file diff --git a/Client/index.js b/Client/index.js index 39cecf52..cf5f0946 100644 --- a/Client/index.js +++ b/Client/index.js @@ -9,6 +9,8 @@ let globalData = { HideGui: false }; +mp.game.gameplay.enableMpDlcMaps(true); + require('./CharCreator/index.js'); require('./FactionManagement/main.js'); @@ -24,6 +26,8 @@ require('./Login/main.js'); require('./Player/dutycloth.js'); require('./Player/keys.js'); +require('./Player/quit.js'); +require('./Player/freecam.js'); require('./Save/main.js'); diff --git a/Server/Commands/Admin.cs b/Server/Commands/Admin.cs index d9acdfdf..e4595b99 100644 --- a/Server/Commands/Admin.cs +++ b/Server/Commands/Admin.cs @@ -800,23 +800,15 @@ namespace reallife_gamemode.Server.Commands return; } - hash = hash.ToUpper(); + uint uHash = NAPI.Util.GetHashKey(hash); - if (!uint.TryParse(hash, out uint vehHash)) + if(!VehicleManager.IsValidHash(uHash)) { - if (!Enum.TryParse(hash, true, out VehicleHash realHash)) - { - player.SendChatMessage("~r~[FEHLER]~s~ Dieses Fahrzeug existiert nicht."); - return; - } - else - { - vehHash = (uint)realHash; - } + player.SendChatMessage("~r~[FEHLER]~s~ Dieses Fahrzeug existiert nicht."); + return; } - Vehicle v = NAPI.Vehicle.CreateVehicle(vehHash, player.Position, player.Rotation.Z, color1, color2); - + Vehicle v = NAPI.Vehicle.CreateVehicle(uHash, player.Position, player.Rotation.Z, color1, color2); player.SetIntoVehicle(v.Handle, -1); } diff --git a/Server/Managers/VehicleManager.cs b/Server/Managers/VehicleManager.cs index d449561e..d03ae2eb 100644 --- a/Server/Managers/VehicleManager.cs +++ b/Server/Managers/VehicleManager.cs @@ -9,6 +9,11 @@ namespace reallife_gamemode.Server.Managers { public class VehicleManager { + private static readonly List _enabledMods = new List() + { + + }; + private static Dictionary _serverVehicles = new Dictionary(); public static void AddVehicle(ServerVehicle serverVehicle, Vehicle vehicle) @@ -71,5 +76,20 @@ namespace reallife_gamemode.Server.Managers return null; } + + public static bool IsValidHash(uint hash) + { + foreach(VehicleHash vh in Enum.GetValues(typeof(VehicleHash))) + { + if ((uint)vh == hash) return true; + } + + foreach(string mod in _enabledMods) + { + if (NAPI.Util.GetHashKey(mod) == hash) return true; + } + + return false; + } } } diff --git a/reallife-gamemode.csproj b/reallife-gamemode.csproj index 8019dc4d..c1c40cc7 100644 --- a/reallife-gamemode.csproj +++ b/reallife-gamemode.csproj @@ -26,6 +26,6 @@ - + \ No newline at end of file