Improved postbuild events, added freecam (F5), add check if vehicle hash is valid, improved deathscreen
This commit is contained in:
@@ -68,7 +68,13 @@ mp.events.add("render", () => {
|
|||||||
|
|
||||||
var medicString;
|
var medicString;
|
||||||
if (dutyMedics > 0) {
|
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 {
|
} else {
|
||||||
medicString = "Derzeit sind ~r~keine Medics ~s~im Dienst.";
|
medicString = "Derzeit sind ~r~keine Medics ~s~im Dienst.";
|
||||||
}
|
}
|
||||||
@@ -76,6 +82,7 @@ mp.events.add("render", () => {
|
|||||||
deathSeconds = respawnTime - Math.floor(currentDate.getTime() / 1000);
|
deathSeconds = respawnTime - Math.floor(currentDate.getTime() / 1000);
|
||||||
var alpha = fade + Math.floor(currentDate.getTime() / 1000 - deathDate.getTime() / 1000);
|
var alpha = fade + Math.floor(currentDate.getTime() / 1000 - deathDate.getTime() / 1000);
|
||||||
if (deathSeconds >= 0) {
|
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.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],
|
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],
|
scale: [0.4, 0.4],
|
||||||
outline: true
|
outline: true
|
||||||
});
|
});
|
||||||
|
mp.game.graphics.set2dLayer(1);
|
||||||
mp.game.graphics.drawRect(0.5, 0.5, 1, 1, 0, 0, 0, alpha);
|
mp.game.graphics.drawRect(0.5, 0.5, 1, 1, 0, 0, 0, alpha);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
124
Client/Player/freecam.js
Normal file
124
Client/Player/freecam.js
Normal file
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
@@ -9,6 +9,8 @@ let globalData = {
|
|||||||
HideGui: false
|
HideGui: false
|
||||||
};
|
};
|
||||||
|
|
||||||
|
mp.game.gameplay.enableMpDlcMaps(true);
|
||||||
|
|
||||||
require('./CharCreator/index.js');
|
require('./CharCreator/index.js');
|
||||||
|
|
||||||
require('./FactionManagement/main.js');
|
require('./FactionManagement/main.js');
|
||||||
@@ -24,6 +26,8 @@ require('./Login/main.js');
|
|||||||
|
|
||||||
require('./Player/dutycloth.js');
|
require('./Player/dutycloth.js');
|
||||||
require('./Player/keys.js');
|
require('./Player/keys.js');
|
||||||
|
require('./Player/quit.js');
|
||||||
|
require('./Player/freecam.js');
|
||||||
|
|
||||||
require('./Save/main.js');
|
require('./Save/main.js');
|
||||||
|
|
||||||
|
|||||||
@@ -800,23 +800,15 @@ namespace reallife_gamemode.Server.Commands
|
|||||||
return;
|
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.");
|
player.SendChatMessage("~r~[FEHLER]~s~ Dieses Fahrzeug existiert nicht.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
vehHash = (uint)realHash;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
player.SetIntoVehicle(v.Handle, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,11 @@ namespace reallife_gamemode.Server.Managers
|
|||||||
{
|
{
|
||||||
public class VehicleManager
|
public class VehicleManager
|
||||||
{
|
{
|
||||||
|
private static readonly List<string> _enabledMods = new List<string>()
|
||||||
|
{
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
private static Dictionary<int, NetHandle> _serverVehicles = new Dictionary<int, NetHandle>();
|
private static Dictionary<int, NetHandle> _serverVehicles = new Dictionary<int, NetHandle>();
|
||||||
|
|
||||||
public static void AddVehicle(ServerVehicle serverVehicle, Vehicle vehicle)
|
public static void AddVehicle(ServerVehicle serverVehicle, Vehicle vehicle)
|
||||||
@@ -71,5 +76,20 @@ namespace reallife_gamemode.Server.Managers
|
|||||||
|
|
||||||
return null;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,6 @@
|
|||||||
<Folder Include="Migrations\" />
|
<Folder Include="Migrations\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(ConfigurationName)' == 'Debug'">
|
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(ConfigurationName)' == 'Debug'">
|
||||||
<Exec Command="del "..\..\client_packages\*" /Q /S
xcopy "$(OutDir)*" "..\..\bridge\resources\reallife-gamemode" /Y /Q
del "..\..\client_packages\*.*" /Q
xcopy "..\..\reallife-gamemode\reallife-gamemode\Client\*" "..\..\client_packages\" /S /Q /Y
" />
|
<Exec Command="del "..\..\bridge\resources\reallife-gamemode\*.*" /Q /S
xcopy "$(OutDir)*" "..\..\bridge\resources\reallife-gamemode" /Y /Q
del "..\..\client_packages\*.*" /Q /S
xcopy "..\..\reallife-gamemode\reallife-gamemode\Client\*" "..\..\client_packages\" /S /Q /Y
" />
|
||||||
</Target>
|
</Target>
|
||||||
</Project>
|
</Project>
|
||||||
Reference in New Issue
Block a user