Ejemplo n.º 1
0
        static public Task TackleHandler(string serializedArguments)
        {
            TackleEvent arguments = Helpers.MsgPack.Deserialize <TackleEvent>(serializedArguments);

            //Log.ToChat($"In tackle event handler {playerList[arguments.SourceId].Character.Position.DistanceToSquared(CitizenFX.Core.Game.PlayerPed.Position).ToString()}");
            if (playerList[arguments.SourceId].Character.Position.DistanceToSquared(Game.PlayerPed.Position) < Math.Pow(lagCompensationFactor * AoeRadius, 2))
            {
                Function.Call(Hash.SET_PED_TO_RAGDOLL, Game.PlayerPed.Handle, ragdollTimeTarget, 2 * ragdollTimeTarget, 0, true, true, true);

                if (arguments.IsSourcePoliceDog)
                {
                    BaseScript.Delay(1000);
                    Game.PlayerPed.Kill();
                }
            }
            return(Task.FromResult(0));
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Request tackle of specified players
 /// </summary>
 public Task Tackle([FromSource] Player source, string serializedArguments)
 {
     try
     {
         //Log.Debug("In tackle routine!");
         TackleEvent arguments = Helpers.MsgPack.Deserialize <TackleEvent>(serializedArguments);
         arguments.SourceId = Int32.Parse(source.Handle);
         string reserializedArguments = Helpers.MsgPack.Serialize(arguments);
         arguments.Targets.ForEach(t =>
         {
             Player target = this.playerList[t];
             TriggerClientEvent(target, "Police.Tackle", Helpers.MsgPack.Serialize(arguments));
         });
         //Log.Debug($"{source.Name} (#{source.Handle}) has tackled player(s) {String.Join(", ", arguments.Targets.ConvertAll(p => playerList[p].Name))}");
     }
     catch (Exception ex)
     {
         Log.Error($"Tackle (server) error: {ex.Message}");
     }
     return(Task.CompletedTask);
 }