diff --git a/ReallifeGamemode.Client/admin/aspeed.ts b/ReallifeGamemode.Client/admin/aspeed.ts new file mode 100644 index 00000000..242d5951 --- /dev/null +++ b/ReallifeGamemode.Client/admin/aspeed.ts @@ -0,0 +1,8 @@ +export default function () { + mp.events.addDataHandler("vehicleAdminSpeed", (entity, newValue) => { + mp.gui.chat.push("datahandler event"); + if (!entity.isAVehicle()) return; + mp.gui.chat.push("newValue = " + newValue.toString()) + entity.setEnginePowerMultiplier(newValue); + }); +} \ No newline at end of file diff --git a/ReallifeGamemode.Client/index.ts b/ReallifeGamemode.Client/index.ts index d4337cf4..31048b1e 100644 --- a/ReallifeGamemode.Client/index.ts +++ b/ReallifeGamemode.Client/index.ts @@ -12,6 +12,9 @@ let globalData: GlobalData = { LoggedIn: false }; +import adminSpeed from './admin/aspeed'; +adminSpeed(); + import voice from './Voice/main'; voice(globalData); diff --git a/ReallifeGamemode.Server/Commands/AdminCommands.cs b/ReallifeGamemode.Server/Commands/AdminCommands.cs index cbda2d19..1f947c32 100644 --- a/ReallifeGamemode.Server/Commands/AdminCommands.cs +++ b/ReallifeGamemode.Server/Commands/AdminCommands.cs @@ -2037,7 +2037,7 @@ namespace ReallifeGamemode.Server.Commands } [Command("aspeed", "~m~Benutzung: ~s~/aspeed [Modifier]")] //TODO: Überarbeiten ?? SetPlayerVelocity ?? - public void CmdAdminAspeed(Client player, float modifier) + public void CmdAdminAspeed(Client player, int modifier) { if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) { @@ -2051,7 +2051,7 @@ namespace ReallifeGamemode.Server.Commands return; } - player.Vehicle.EnginePowerMultiplier = modifier; + player.Vehicle.SetSharedData("vehicleAdminSpeed", modifier); } [Command("setmoney", "~m~Benutzung: ~s~/setmoney [Name] [Menge]")] diff --git a/ReallifeGamemode.Server/Managers/VehicleManager.cs b/ReallifeGamemode.Server/Managers/VehicleManager.cs index 57b7b138..a7694bf0 100644 --- a/ReallifeGamemode.Server/Managers/VehicleManager.cs +++ b/ReallifeGamemode.Server/Managers/VehicleManager.cs @@ -83,7 +83,7 @@ namespace ReallifeGamemode.Server.Managers Vector3 lastPosition = v.Position; if (lastPositions.ContainsKey(v.Handle)) lastPosition = lastPositions[v.Handle]; - double distanceDriven = v.HasSharedData("drivenDistance") ? v.GetSharedData("drivenDistance") : 0D; + double distanceDriven = v.HasSharedData("drivenDistance") ? (double)v.GetSharedData("drivenDistance") : 0D; distanceDriven += (lastPosition.DistanceTo(v.Position) / 1000.0);