예제 #1
0
        public static void CreateWeaponProp(Client player, WeaponHash weapon)
        {
            if (!WeaponData.ContainsKey(weapon))
            {
                return;
            }
            RemoveWeaponProp(player, WeaponData[weapon].Type);

            // make sure player has the weapon
            if (Array.IndexOf(player.Weapons, weapon) == -1)
            {
                return;
            }

            string  bone     = "";
            Vector3 offset   = new Vector3(0.0, 0.0, 0.0);
            Vector3 rotation = new Vector3(0.0, 0.0, 0.0);

            switch (WeaponData[weapon].Type)
            {
            case WeaponAttachmentType.RightLeg:
                bone     = "SKEL_R_Thigh";
                offset   = new Vector3(0.02, 0.06, 0.1);
                rotation = new Vector3(-100.0, 0.0, 0.0);
                break;

            case WeaponAttachmentType.LeftLeg:
                bone     = "SKEL_L_Thigh";
                offset   = new Vector3(0.08, 0.03, -0.1);
                rotation = new Vector3(-80.77, 0.0, 0.0);
                break;

            case WeaponAttachmentType.RightBack:
                bone     = "SKEL_Spine3";
                offset   = new Vector3(-0.1, -0.15, -0.13);
                rotation = new Vector3(0.0, 0.0, 3.5);
                break;

            case WeaponAttachmentType.LeftBack:
                bone     = "SKEL_Spine3";
                offset   = new Vector3(-0.1, -0.15, 0.11);
                rotation = new Vector3(-180.0, 0.0, 0.0);
                break;
            }

            GTANetworkAPI.Object temp_handle = NAPI.Object.CreateObject(NAPI.Util.GetHashKey(WeaponData[weapon].Model), player.Position, player.Rotation, 255, 0);
            temp_handle.AttachTo(player.Handle, bone, offset, rotation);

            NAPI.Data.SetEntityData(player.Handle, WeaponKeys[(int)WeaponData[weapon].Type], temp_handle);
        }
예제 #2
0
        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);
                }
            }
        }