public static void OnPlayerDisconnected(Client player, DisconnectionType type, string reason)
 {
     if (player.HasData(EntityData.PLAYER_HANDCUFFED) == true)
     {
         // Remove player's cuffs
         GTANetworkAPI.Object cuff = player.GetData(EntityData.PLAYER_HANDCUFFED);
         cuff.Detach();
         cuff.Delete();
     }
 }
Beispiel #2
0
        void CancelScuba(Client player)
        {
            var character = player.GetCharacter();

            //Cancel timer.
            Timer timer = NAPI.Data.GetEntityData(player, "SCUBA_TIMER");

            if (timer != null)
            {
                timer.Dispose();
                NAPI.Data.ResetEntityData(player, "SCUBA_TIMER");
            }

            //Remove clothes
            GTANetworkAPI.Object head = NAPI.Data.GetEntityData(player, "SCUBA_HEAD");
            GTANetworkAPI.Object tank = NAPI.Data.GetEntityData(player, "SCUBA_TANK");
            if (head != null && API.DoesEntityExist(head))
            {
                head.Detach();
                head.Delete();
                NAPI.Data.ResetEntityData(player, "SCUBA_HEAD");
            }
            if (tank != null && API.DoesEntityExist(tank))
            {
                tank.Detach();
                tank.Delete();
                NAPI.Data.ResetEntityData(player, "SCUBA_TANK");
            }

            //Set scuba state
            API.SendNativeToPlayer(player, Hash.SET_ENABLE_SCUBA, player.Handle, false);

            //Remove exygen
            NAPI.ClientEvent.TriggerClientEvent(player, "UPDATE_SCUBA_PERCENTAGE", "none");

            //Set the variable.
            character.IsScubaDiving = false;

            //Set normal clothes
            character.update_ped();

            //Set normal underwater time.
            API.SendNativeToPlayer(player, Hash.SET_PED_MAX_TIME_UNDERWATER, player.Handle, 60.0f);
        }
        public void HandcuffCommand(Client player, string targetString)
        {
            if (player.GetData(EntityData.PLAYER_KILLED) != 0)
            {
                player.SendChatMessage(Constants.COLOR_ERROR + Messages.ERR_PLAYER_IS_DEAD);
            }
            else if (player.GetData(EntityData.PLAYER_ON_DUTY) == 0)
            {
                player.SendChatMessage(Constants.COLOR_ERROR + Messages.ERR_PLAYER_NOT_ON_DUTY);
            }
            else if (player.GetData(EntityData.PLAYER_FACTION) != Constants.FACTION_POLICE)
            {
                player.SendChatMessage(Constants.COLOR_ERROR + Messages.ERR_PLAYER_NOT_POLICE_FACTION);
            }
            else
            {
                Client target = int.TryParse(targetString, out int targetId) ? Globals.GetPlayerById(targetId) : NAPI.Player.GetPlayerFromName(targetString);

                if (target != null)
                {
                    if (player.Position.DistanceTo(target.Position) > 1.5f)
                    {
                        player.SendChatMessage(Constants.COLOR_ERROR + Messages.ERR_PLAYER_TOO_FAR);
                    }
                    else if (target == player)
                    {
                        player.SendChatMessage(Constants.COLOR_ERROR + Messages.ERR_PLAYER_HANDCUFFED_HIMSELF);
                    }
                    else if (target.HasData(EntityData.PLAYER_HANDCUFFED) == false)
                    {
                        string playerMessage      = string.Format(Messages.INF_CUFFED, target.Name);
                        string targetMessage      = string.Format(Messages.INF_CUFFED_BY, player.Name);
                        GTANetworkAPI.Object cuff = NAPI.Object.CreateObject(-1281059971, new Vector3(0.0f, 0.0f, 0.0f), new Vector3(0.0f, 0.0f, 0.0f));
                        cuff.AttachTo(target, "IK_R_Hand", new Vector3(0.0f, 0.0f, 0.0f), new Vector3(0.0f, 0.0f, 0.0f));
                        target.PlayAnimation("mp_arresting", "idle", (int)(Constants.AnimationFlags.Loop | Constants.AnimationFlags.OnlyAnimateUpperBody | Constants.AnimationFlags.AllowPlayerControl));
                        player.SetData(EntityData.PLAYER_ANIMATION, true);
                        target.SetData(EntityData.PLAYER_HANDCUFFED, cuff);
                        player.SendChatMessage(Constants.COLOR_INFO + playerMessage);
                        target.SendChatMessage(Constants.COLOR_INFO + targetMessage);

                        // Disable some player movements
                        player.TriggerEvent("toggleHandcuffed", true);
                    }
                    else
                    {
                        GTANetworkAPI.Object cuff = target.GetData(EntityData.PLAYER_HANDCUFFED);

                        cuff.Detach();
                        cuff.Delete();

                        target.StopAnimation();
                        player.ResetData(EntityData.PLAYER_ANIMATION);
                        target.ResetData(EntityData.PLAYER_HANDCUFFED);

                        string playerMessage = string.Format(Messages.INF_UNCUFFED, target.Name);
                        string targetMessage = string.Format(Messages.INF_UNCUFFED_BY, player.Name);
                        player.SendChatMessage(Constants.COLOR_INFO + playerMessage);
                        target.SendChatMessage(Constants.COLOR_INFO + targetMessage);

                        // Enable previously disabled player movements
                        player.TriggerEvent("toggleHandcuffed", false);
                    }
                }
                else
                {
                    player.SendChatMessage(Constants.COLOR_ERROR + Messages.ERR_PLAYER_NOT_FOUND);
                }
            }
        }