This commit is contained in:
VegaZ
2021-04-07 22:05:14 +02:00
10 changed files with 84 additions and 60 deletions

View File

@@ -202,7 +202,7 @@ export default function (globalData: IGlobalData): void {
centre: false centre: false
}) })
mp.game.graphics.drawText(dateString + "\n" + timeString, [0.938, 0.381], mp.game.graphics.drawText(timeString + "\n" + dateString, [0.938, 0.381],
{ {
font: 4, font: 4,
color: [255, 255, 255, 255], color: [255, 255, 255, 255],
@@ -219,7 +219,7 @@ export default function (globalData: IGlobalData): void {
outline: true, outline: true,
centre: false centre: false
}) })
mp.game.graphics.drawText("~r~Datum: ", [0.89, 0.381], mp.game.graphics.drawText("~r~Datum: ", [0.891, 0.411],
{ {
font: 4, font: 4,
color: [255, 255, 255, 255], color: [255, 255, 255, 255],
@@ -227,7 +227,7 @@ export default function (globalData: IGlobalData): void {
outline: true, outline: true,
centre: false centre: false
}) })
mp.game.graphics.drawText("~r~Uhrzeit: ", [0.891, 0.411], mp.game.graphics.drawText("~r~Uhrzeit: ", [0.89, 0.381],
{ {
font: 4, font: 4,
color: [255, 255, 255, 255], color: [255, 255, 255, 255],

View File

@@ -1,15 +1,17 @@
export default function animationSync() { import { debug } from "util";
export default function animationSync() {
let blockInput = false; let blockInput = false;
let animationBreakTimer; let animationBreakTimer;
mp.events.add("SERVER:LoadAnimations", () => { mp.events.add("SERVER:LoadAnimations", () => {
animationSyncData.register("Cuffed", "mp_arresting", "idle", -1, true, 50); animationSyncData.register("Cuffed", "mp_arresting", "idle", -1, true, 50, false);
animationSyncData.register("doArrest", "mp_arrest_paired", "cop_p2_back_right", 3760, false, 0); animationSyncData.register("doArrest", "mp_arrest_paired", "cop_p2_back_right", 3760, false, 0, false);
animationSyncData.register("getArrest", "mp_arrest_paired", "crook_p2_back_right", 3760, false, 0); animationSyncData.register("getArrest", "mp_arrest_paired", "crook_p2_back_right", 3760, false, 0, false);
animationSyncData.register("doUncuff", "mp_arresting", "a_uncuff", 5500, false, 0); animationSyncData.register("doUncuff", "mp_arresting", "a_uncuff", 5500, false, 0, false);
animationSyncData.register("getUncuff", "mp_arresting", "b_uncuff", 5500, false, 0); animationSyncData.register("getUncuff", "mp_arresting", "b_uncuff", 5500, false, 0, false);
animationSyncData.register("hup", "mp_am_hold_up", "handsup_base", -1, true, 50); animationSyncData.register("hup", "mp_am_hold_up", "handsup_base", -1, true, 50, true);
animationSyncData.register("carryBox", "anim@heists@box_carry@", "idle", -1, true, 50); animationSyncData.register("carryBox", "anim@heists@box_carry@", "idle", -1, true, 50, true);
}); });
const animationBreakMessage = [ const animationBreakMessage = [
@@ -20,7 +22,7 @@
{ {
animations: [], animations: [],
register: function (name, animDict, animName, duration, loop, flag) { register: function (name, animDict, animName, duration, loop, flag, endless) {
let id = mp.game.joaat(name); let id = mp.game.joaat(name);
if (!this.animations.hasOwnProperty(id)) { if (!this.animations.hasOwnProperty(id)) {
@@ -32,7 +34,8 @@
animName: animName, animName: animName,
duration: duration, duration: duration,
loop: loop, loop: loop,
flag: flag flag: flag,
endless: endless
}; };
} else { } else {
mp.game.graphics.notify("Animation Sync Error: ~r~Duplicate Entry"); mp.game.graphics.notify("Animation Sync Error: ~r~Duplicate Entry");
@@ -73,7 +76,7 @@
let currentAnim = animationSyncData.animations[index]; let currentAnim = animationSyncData.animations[index];
let { id, name, animDict, animName, duration, loop, flag } = currentAnim; let { id, name, animDict, animName, duration, loop, flag } = currentAnim;
if (loop && !player.isPlayingAnim(animDict, animName, 3)) { if (loop == true && !player.isPlayingAnim(animDict, animName, 3)) {
loadAnimDict(animDict, function () { loadAnimDict(animDict, function () {
mp.players.exists(player) && 0 !== player.handle && player.taskPlayAnim(animDict, animName, 1, 0, duration, parseInt(flag), 0, !1, !1, !1) mp.players.exists(player) && 0 !== player.handle && player.taskPlayAnim(animDict, animName, 1, 0, duration, parseInt(flag), 0, !1, !1, !1)
}); });
@@ -98,35 +101,35 @@
let animData = animationSyncData.animations[index]; let animData = animationSyncData.animations[index];
let { id, name, animDict, animName, duration, loop, flag } = animData; let { id, name, animDict, animName, duration, loop, flag, endless } = animData;
loadAnimDict(animDict, function () { loadAnimDict(animDict, function () {
mp.players.exists(entity) && 0 !== entity.handle && entity.taskPlayAnim(animDict, animName, 1, 0, duration, parseInt(flag), 0, !1, !1, !1) mp.players.exists(entity) && 0 !== entity.handle && entity.taskPlayAnim(animDict, animName, 1, 0, duration, parseInt(flag), 0, !1, !1, !1)
}); });
if (!endless) {
if (mp.players.local == entity && loop) { animationBreakTimer = setInterval(() => breakAnimation(name), 120000);
animationBreakTimer = setInterval(() => breakAnimation(entity, id), 120000);
} }
if (!loop) { if (mp.players.local == entity) {
let a = setInterval(function () { if (!loop) {
mp.events.callRemote("CLIENT:ClearAnimationData", entity); let a = setInterval(function () {
mp.events.callRemote("CLIENT:AnimPairTransition"); mp.events.callRemote("CLIENT:ClearAnimationData", true);
clearInterval(a); clearInterval(a);
}, duration); }, duration);
}
} }
}); });
function breakAnimation(entity, id) { function breakAnimation(name) {
mp.events.callRemote("CLIENT:ClearAnimationData", entity); let { animName, msg } = animationBreakMessage.find(c => c.animName == name)
let { animName, msg } = animationBreakMessage.find(c => mp.game.joaat(c.animName) == id)
if (msg) if (msg)
mp.events.call("renderTextOnScreen", msg); mp.events.call("renderTextOnScreen", msg);
clearInterval(animationBreakTimer); clearInterval(animationBreakTimer);
animationBreakTimer = null; animationBreakTimer = null;
mp.events.callRemote("CLIENT:ClearAnimationData", false);
} }
mp.events.add("render", () => { mp.events.add("render", () => {

View File

@@ -106,11 +106,7 @@ namespace ReallifeGamemode.Server.Commands
[Command("hup")] [Command("hup")]
public void CmdAnim(Player player) public void CmdAnim(Player player)
{ {
if (player.HasAnimation("hup")) { player.ClearAnimation(); return; } player.ToggleSurrender();
if (player.HasAnimation())
return;
player.SyncAnimation("hup");
} }
[Command("event", "~m~Benutzung: ~s~/event [Nachricht]", GreedyArg = true)] [Command("event", "~m~Benutzung: ~s~/event [Nachricht]", GreedyArg = true)]

View File

@@ -15,17 +15,15 @@ namespace ReallifeGamemode.Server.Events
public class EnterVehicleAttempt : Script public class EnterVehicleAttempt : Script
{ {
public static GTANetworkAPI.Vehicle Roller; public static GTANetworkAPI.Vehicle Roller;
[ServerEvent(Event.PlayerEnterVehicleAttempt)] [ServerEvent(Event.PlayerEnterVehicleAttempt)]
public void OnPlayerEnterVehicleAttempt(Player player, GTANetworkAPI.Vehicle vehicle, sbyte seat) public void OnPlayerEnterVehicleAttempt(Player player, GTANetworkAPI.Vehicle vehicle, sbyte seat)
{ {
if ((VehicleHash)vehicle.Model == VehicleHash.Dune3)
{
if (seat == 1) seat = 0;
else if (seat == 0) seat = 1;
}
if (seat != 0) return; if (seat != 0) return;
if (player.HasAnimation())
player.StopAnimation();
User u = player.GetUser(); User u = player.GetUser();
if (vehicle.GetServerVehicle() is FactionVehicle veh) if (vehicle.GetServerVehicle() is FactionVehicle veh)
@@ -84,7 +82,6 @@ namespace ReallifeGamemode.Server.Events
return; return;
} }
} }
} }
if (vehicle.GetServerVehicle() is SchoolVehicle sVeh) if (vehicle.GetServerVehicle() is SchoolVehicle sVeh)
{ {

View File

@@ -974,19 +974,7 @@ namespace ReallifeGamemode.Server.Events
[RemoteEvent("keyPress:ControllH")] [RemoteEvent("keyPress:ControllH")]
public void KeyPressControllH(Player player) public void KeyPressControllH(Player player)
{ {
if (player.HasAnimation("hup")) player.ToggleSurrender();
{
PositionManager.cuffPoints.Remove(player);
player.ClearAnimation();
return;
}
if (player.HasAnimation())
return;
player.SyncAnimation("hup");
if (player.GetUser().Wanteds > 0)
PositionManager.cuffPoints.Add(player);
} }
#endregion User Key #endregion User Key

View File

@@ -20,11 +20,18 @@ namespace ReallifeGamemode.Server.Events
string username = player.Name; string username = player.Name;
using (var dbContext = new DatabaseContext()) using (var dbContext = new DatabaseContext())
{ {
if (password.Length < 6)
{
player.TriggerEvent("SERVER:Login_Error", "Das Passwort muss aus mindestens 6 Zeichen bestehen.");
return;
}
if (dbContext.Users.Where(u => u.SocialClubName == player.SocialClubName).Count() >= 3) if (dbContext.Users.Where(u => u.SocialClubName == player.SocialClubName).Count() >= 3)
{ {
player.TriggerEvent("SERVER:Login_Error", "Es sind schon 3 Konten mit dieser Socialclub-ID registriert."); player.TriggerEvent("SERVER:Login_Error", "Es sind schon 3 Konten mit dieser Socialclub-ID registriert.");
return;
} }
else if (!dbContext.Users.Any(u => u.Name.ToLower() == username.ToLower().Trim()))
if (!dbContext.Users.Any(u => u.Name.ToLower() == username.ToLower().Trim()))
{ {
var user = new User var user = new User
{ {

View File

@@ -6,6 +6,7 @@ using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json; using Newtonsoft.Json;
using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Entities;
using ReallifeGamemode.Database.Models; using ReallifeGamemode.Database.Models;
using ReallifeGamemode.Server.Managers;
using ReallifeGamemode.Server.Services; using ReallifeGamemode.Server.Services;
using ReallifeGamemode.Server.Types; using ReallifeGamemode.Server.Types;
using ReallifeGamemode.Server.Util; using ReallifeGamemode.Server.Util;
@@ -340,7 +341,25 @@ namespace ReallifeGamemode.Server.Extensions
nearestCuffPlayer.AddAttachment("handcuffs", true); nearestCuffPlayer.AddAttachment("handcuffs", true);
player.SyncAnimation("doUncuff"); player.SyncAnimation("doUncuff");
nearestCuffPlayer.SyncAnimation("getUncuff"); nearestCuffPlayer.SyncAnimation("getUncuff");
PositionManager.cuffPoints.Remove(nearestCuffPlayer);
} }
} }
public static void ToggleSurrender(this Player player)
{
if (player.HasAnimation("hup"))
{
PositionManager.cuffPoints.Remove(player);
player.ClearAnimation();
return;
}
if (player.HasAnimation())
return;
player.SyncAnimation("hup");
if (player.GetUser().Wanteds > 0)
PositionManager.cuffPoints.Add(player);
}
} }
} }

View File

@@ -809,7 +809,7 @@ namespace ReallifeGamemode.Server.Managers
[RemoteEvent("CLIENT:InteractionMenu_CallService_Sani")] [RemoteEvent("CLIENT:InteractionMenu_CallService_Sani")]
public void CallServiceSani(Player player) public void CallServiceSani(Player player)
{ {
if (player.GetUser().FactionId == 2) if (player.GetUser().FactionId == 2 && player.IsDuty())
{ {
player.SendNotification("~r~[Fehler] ~w~Du kannst keinen Sanitäter rufen."); player.SendNotification("~r~[Fehler] ~w~Du kannst keinen Sanitäter rufen.");
return; return;

View File

@@ -74,7 +74,7 @@ namespace ReallifeGamemode.Server.Managers
{ {
if (player.IsInVehicle) if (player.IsInVehicle)
{ {
player.TriggerEvent("Error", "Du kannst dein Kofferraum nicht betätigen."); player.TriggerEvent("Error", "Du kannst deinen Kofferraum gerade nicht öffnen.");
} }
Vehicle veh = NAPI.Pools.GetAllVehicles().ToList().Where(v => v.Position.DistanceTo(player.Position) <= 2).FirstOrDefault(); Vehicle veh = NAPI.Pools.GetAllVehicles().ToList().Where(v => v.Position.DistanceTo(player.Position) <= 2).FirstOrDefault();
if (veh == null) if (veh == null)

View File

@@ -13,6 +13,9 @@ namespace ReallifeGamemode.Server.Util
public static void SyncAnimation(this Player player, dynamic animationName) public static void SyncAnimation(this Player player, dynamic animationName)
{ {
if (player.IsInVehicle)
return;
if (!player.HasData("Animation")) if (!player.HasData("Animation"))
player.SetData("Animation", String.Empty); player.SetData("Animation", String.Empty);
@@ -35,11 +38,17 @@ namespace ReallifeGamemode.Server.Util
List<string> nextAnimations = animations.Skip(1).ToList(); List<string> nextAnimations = animations.Skip(1).ToList();
player.SyncAnimation(animationName); player.SyncAnimation(animationName);
if (nextAnimations.Count != 0) if (nextAnimations.Count is 0)
{ {
player.TriggerEvent("SERVER:QueueAnimation", animationName); animationPair.Remove(player);
animationPair.Add(player, nextAnimations); return;
} }
player.TriggerEvent("SERVER:QueueAnimation", animationName);
if (animationPair.ContainsKey(player))
animationPair[player] = nextAnimations;
else
animationPair.Add(player, nextAnimations);
} }
/// <summary>Check if Player has any Animation playing. /// <summary>Check if Player has any Animation playing.
@@ -55,6 +64,8 @@ namespace ReallifeGamemode.Server.Util
/// <param name="animationName">Name of requested animation</param> /// <param name="animationName">Name of requested animation</param>
public static bool HasAnimation(this Player player, dynamic animationName) public static bool HasAnimation(this Player player, dynamic animationName)
{ {
string data = player.GetData<string>("Animation");
bool x = player.GetData<string>("Animation") == animationName;
return player.HasData("Animation") && (player.GetData<string>("Animation") == animationName); return player.HasData("Animation") && (player.GetData<string>("Animation") == animationName);
} }
@@ -63,6 +74,7 @@ namespace ReallifeGamemode.Server.Util
if (!player.HasData("Animation")) if (!player.HasData("Animation"))
return; return;
player.ClearAttachments();
player.ResetData("Animation"); player.ResetData("Animation");
player.ResetSharedData("AnimationData"); player.ResetSharedData("AnimationData");
} }
@@ -82,9 +94,11 @@ namespace ReallifeGamemode.Server.Util
} }
[RemoteEvent("CLIENT:ClearAnimationData")] [RemoteEvent("CLIENT:ClearAnimationData")]
public void ClearAnimationData(Player player, Player target) public void ClearAnimationData(Player player, bool checkTransition)
{ {
target.ClearAnimation(); player.ClearAnimation();
if (checkTransition)
AnimPairTransition(player);
} }
[ServerEvent(Event.PlayerWeaponSwitch)] [ServerEvent(Event.PlayerWeaponSwitch)]