diff --git a/ReallifeGamemode.Client/util/animationSync.ts b/ReallifeGamemode.Client/util/animationSync.ts index a2f604c8..d86a13d5 100644 --- a/ReallifeGamemode.Client/util/animationSync.ts +++ b/ReallifeGamemode.Client/util/animationSync.ts @@ -50,9 +50,14 @@ setInterval(() => { if (mp.players.local.getVariable("AnimationData")) { - blockInput = true; - } else { - blockInput = false; + let index = mp.game.joaat(mp.players.local.getVariable("AnimationData")); + let currentAnim = animationSyncData.animations[index]; + let { id, name, animDict, animName, duration, loop, flag } = currentAnim; + if (loop) { + blockInput = true; + } else { + blockInput = false; + } } mp.players.forEachInStreamRange( @@ -69,13 +74,6 @@ loadAnimDict(animDict, function () { mp.players.exists(player) && 0 !== player.handle && player.taskPlayAnim(animDict, animName, 1, 0, duration, parseInt(flag), 0, !1, !1, !1) }); - } else if (!loop) { - let a = setInterval(function () { - if (player == mp.players.local) { - mp.events.callRemote("CLIENT:ClearAnimationData", player); - } - clearInterval(a); - }, duration); } }); }, 100); diff --git a/ReallifeGamemode.Client/util/attachmentMngr.ts b/ReallifeGamemode.Client/util/attachmentMngr.ts index b3f0a1d9..c1a3dcc2 100644 --- a/ReallifeGamemode.Client/util/attachmentMngr.ts +++ b/ReallifeGamemode.Client/util/attachmentMngr.ts @@ -1,6 +1,5 @@ import { IGame, IEntity } from "../game"; - export default function attachmentManager(game: IGame) { mp.events.add("SERVER:LoadAttachments", () => { attachmentMngr.register("char_creator_1", "prop_beggers_sign_04", 28422, new mp.Vector3(0, 0, 0), new mp.Vector3(0, 0, 0)); @@ -11,9 +10,7 @@ export default function attachmentManager(game: IGame) { attachmentMngr.register("weapondeal2", "w_sg_pumpshotgun", "chassis_dummy", new mp.Vector3(0.4, 1.6, 0.62), new mp.Vector3(90, 0, 180)); }); - - - const attachmentMngr = + const attachmentMngr = { attachments: {}, @@ -26,7 +23,7 @@ export default function attachmentManager(game: IGame) { let attInfo = this.attachments[id]; let object = mp.objects.new(attInfo.model, entity.position); - + object.__attMgrData = { targetEntity: entity.handle, bone: (typeof (attInfo.boneName) === 'string') ? entity.getBoneIndexByName(attInfo.boneName) : entity.getBoneIndex(attInfo.boneName), @@ -157,6 +154,17 @@ export default function attachmentManager(game: IGame) { } }); + mp.events.addDataHandler("attachToPlayer", (player: PlayerMp, attachedPlayer: PlayerMp) => { + if (!attachedPlayer) + return; + + let handle = player.handle; + if (player == mp.players.local) + handle = mp.players.local.handle; + + attachedPlayer.attachTo(handle, 0, 0, 1, 0, 0, 0, 0, false, true, false, true, 2, true); + }); + mp.events.addDataHandler("attachmentsData", (entity, data) => { let newAttachments = (data.length > 0) ? data.split('|').map(att => parseInt(att, 36)) : []; diff --git a/ReallifeGamemode.Client/util/weapondamage.ts b/ReallifeGamemode.Client/util/weapondamage.ts index 1635c09b..9f192070 100644 --- a/ReallifeGamemode.Client/util/weapondamage.ts +++ b/ReallifeGamemode.Client/util/weapondamage.ts @@ -1,4 +1,5 @@ export default function weapondamageUtil() { + let blockInput = false; mp.players.local.setSuffersCriticalHits(false); @@ -6,6 +7,13 @@ player.setSuffersCriticalHits(false); }); + mp.events.add("render", () => { + if (blockInput) { + mp.game.controls.disableControlAction(32, 142, true); + mp.game.controls.disableControlAction(32, 263, true); + } + }); + mp.events.add('SERVER:WeaponModifier', (player) => { //mp.gui.chat.push("Modifier steht jetzt auf" + modifier); //mp.players.local.setWeaponDamageModifier(modifier); @@ -16,65 +24,83 @@ case 0x1B06D571: //Pistol modifier = 0.4; meelemodifier = 1; - //mp.gui.chat.push("PistolModifier: " + modifier); + blockInput = true; break; case 0xBFE256D4: //Pistol_MK2 modifier = 0.4; meelemodifier = 1; + blockInput = true; break; case 0x5EF9FEC4: //Combatpistol modifier = 0.5; meelemodifier = 1; + blockInput = true; break; case 0x99AEEB3B: //Pistol50 modifier = 0.35; meelemodifier = 1; + blockInput = true; break; case 0x2BE6766B: //SMG modifier = 0.25; meelemodifier = 1; + blockInput = true; break; case 0x1D073A89: //Pumpshotgun modifier = 0.2; meelemodifier = 1; + blockInput = true; break; case 0x83BF0278: //Cabinerifle modifier = 0.2; meelemodifier = 1; + blockInput = true; break; case 0x624FE830: //Compactrifle modifier = 0.2; meelemodifier = 0.1; + blockInput = true; break; case 0x05FC3C11: //Sniperrifle modifier = 0.5; meelemodifier = 1; + blockInput = true; break; case 0xA2719263: //Meele Umarmed Fist meelemodifier = 0.1; modifier = 1; + blockInput = false; //mp.gui.chat.push("FistModifier: " + meelemodifier); break; case 0x958A4A8F: //Meele Baseball Bat meelemodifier = 0.15; modifier = 1; + blockInput = false; break; case 0x8BB05FD7: //Meele Flashlight meelemodifier = 0.1; modifier = 1; + blockInput = false; + break; case 0xD8DF3C3C: //Meele Knuckle meelemodifier = 0.1; modifier = 1; + blockInput = false; + //mp.gui.chat.push("KnuckleModifier: " + meelemodifier); break; case 0x678B81B1: //Meele Nightstick meelemodifier = 0.1; modifier = 1; + blockInput = false; + break; default: modifier = 1; meelemodifier = 1; + blockInput = false; + break; } mp.game.invoke("0xCE07B9F7817AADA3", player, modifier); @@ -95,7 +121,6 @@ } }); - /*mp.events.add('playerWeaponShot', (targetPosition, targetEntity) => { for (var x in this.weaponAmmo) { if (this.weaponAmmo[x].id != this.currentWeapon) { diff --git a/ReallifeGamemode.Server/Commands/AdminCommands.cs b/ReallifeGamemode.Server/Commands/AdminCommands.cs index 652b72a3..6323b86a 100644 --- a/ReallifeGamemode.Server/Commands/AdminCommands.cs +++ b/ReallifeGamemode.Server/Commands/AdminCommands.cs @@ -47,7 +47,6 @@ namespace ReallifeGamemode.Server.Commands return; //target.SetInFrontOf(player); //target.Heading = player.Heading; - player.TriggerEvent("attach to Player", target); } [Command("cuff", "~m~Benutzung: ~s~/cuff [ID]")] diff --git a/ReallifeGamemode.Server/Util/AttachmentSync.cs b/ReallifeGamemode.Server/Util/AttachmentSync.cs index 822a5c76..51f02de9 100644 --- a/ReallifeGamemode.Server/Util/AttachmentSync.cs +++ b/ReallifeGamemode.Server/Util/AttachmentSync.cs @@ -1,5 +1,4 @@ - -using System; +using System; using System.Collections.Generic; using System.Linq; using GTANetworkAPI; @@ -12,7 +11,7 @@ public static class AttachmentSync /// The entity to attach the object to /// The attachment, should be in string or long type /// Pass true to remove the specified attachment, false otherwise. - + public static void AddAttachment(this Entity entity, dynamic attachment, bool remove) { if (!entity.HasData("Attachments")) @@ -109,6 +108,29 @@ public static class AttachmentSync { return string.Join('|', attachments.Select(a => Base36Extensions.ToBase36(a)).ToArray()); } + + public static void AttachPlayer(this Player player, Player attachTo) + { + attachTo.DetachPlayer(); + + if (!attachTo.HasData("attachedPlayer")) + attachTo.SetData("attachedPlayer", null); + + if (attachTo.GetData("attachedPlayer") == player) + return; + + attachTo.SetData("attachedPlayer", attachTo); + attachTo.SetSharedData("attachToPlayer", player); + } + + public static void DetachPlayer(this Player player) + { + if (!player.HasData("attachedPlayer")) + return; + + player.ResetData("attachedPlayer"); + player.ResetSharedData("attachToPlayer"); + } } public class AttachmentSyncExample : Script @@ -154,7 +176,4 @@ public class AttachmentSyncExample : Script player.ClearAttachments(); } } - - } -