Esempio n. 1
0
    private void SublimeWeaponComponentMenu(MenuButton buttonSender, WeaponHash weaponHash)
    {
        List<IMenuItem> componentButtons = new List<IMenuItem>();

        foreach (KeyValuePair<string, string> weaponComponent in weaponComponentItems)
        {
            int weaponComponentHash = Function.Call<int>(Hash.GET_HASH_KEY, weaponComponent.Key);
            bool canWeaponHaveComponent = Function.Call<bool>(Hash._CAN_WEAPON_HAVE_COMPONENT, (int) weaponHash, weaponComponentHash);
            if (canWeaponHaveComponent)
            {
                var componentActivateButton = new MenuButton(weaponComponent.Value);
                componentActivateButton.Activated += (sender, args) => WeaponFunctions.ChangeWeaponComponent(weaponHash, weaponComponent);
                componentButtons.Add(componentActivateButton);
            }
        }

        foreach (KeyValuePair<string, int> tintIndex in weaponTintIndexDict)
        {
            var tintActivateButton = new MenuButton(tintIndex.Key);
            tintActivateButton.Activated += (sender, args) => WeaponFunctions.ChangeWeaponTint(weaponHash, tintIndex.Value);
            componentButtons.Add(tintActivateButton);
        }

        WeaponComponentsMenu = new GTA.Menu(buttonSender.Caption, componentButtons.ToArray());
        DrawMenu(WeaponComponentsMenu);
    }
Esempio n. 2
0
 public WeaponDefinition(string name, WeaponHash hash, string description, int pointstounlock, int leveltounlock)
 {
     WeaponName = name;
     WeaponHash = hash;
     Description = description;
     PointsToUnlock = pointstounlock;
     LevelToUnlock = leveltounlock;
 }
Esempio n. 3
0
 public Node(string reference, WeaponHash wepHash, GTASprite sprite, NodeType type, TreeDirection direction = TreeDirection.Auto)
 {
     Ref = reference;
     Direction = direction;
     Type = type;
     Sprite = sprite;
     WepHash = wepHash;
 }
Esempio n. 4
0
        public static ItemModel GetEquippedWeaponItemModelByHash(int playerId, WeaponHash weapon)
        {
            ItemModel item = null;

            foreach (ItemModel itemModel in Globals.itemList)
            {
                if (itemModel.ownerIdentifier == playerId && (itemModel.ownerEntity == Constants.ITEM_ENTITY_WHEEL || itemModel.ownerEntity == Constants.ITEM_ENTITY_RIGHT_HAND) && weapon.ToString() == itemModel.hash)
                {
                    item = itemModel;
                    break;
                }
            }
            return(item);
        }
Esempio n. 5
0
        public static bool DoesPlayerHaveWeapon(Client player, WeaponHash weapon)
        {
            Character character = player.GetCharacter();

            foreach (Weapon i in InventoryManager.DoesInventoryHaveItem <Weapon>(character))
            {
                if (i.WeaponHash == weapon)
                {
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 6
0
    // Weapon Component Related
    internal static void ChangeWeaponComponent(WeaponHash weaponHash, KeyValuePair<string, string> weaponComponent)
    {
        int weaponComponentHash = Function.Call<int>(Hash.GET_HASH_KEY, weaponComponent.Key);
        bool hasWeaponGotComponent = Function.Call<bool>(Hash.HAS_PED_GOT_WEAPON_COMPONENT, Game.Player.Character, (int) weaponHash, weaponComponentHash);

        if (!hasWeaponGotComponent)
        {
            Function.Call(Hash.GIVE_WEAPON_COMPONENT_TO_PED, Game.Player.Character, (int) weaponHash, weaponComponentHash);
        }
        else
        {
            Function.Call(Hash.REMOVE_WEAPON_COMPONENT_FROM_PED, Game.Player.Character, (int) weaponHash, weaponComponentHash);
        }
    }
        public static int GetGunAmmunitionCapacity(WeaponHash weapon)
        {
            int amount = 0;

            foreach (GunModel gun in Constants.GUN_LIST)
            {
                if (weapon == gun.weapon)
                {
                    amount = gun.capacity;
                    break;
                }
            }
            return(amount);
        }
Esempio n. 8
0
        public 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;
            }

            GrandTheftMultiplayer.Server.Elements.Object temp_handle = API.createObject(API.getHashKey(WeaponData[weapon].Model), player.position, new Vector3());
            temp_handle.attachTo(player.handle, bone, offset, rotation);

            player.setData(WeaponKeys[(int)WeaponData[weapon].Type], temp_handle);
        }
        public static String GetGunAmmunitionType(WeaponHash weapon)
        {
            String type = String.Empty;

            foreach (GunModel gun in Constants.GUN_LIST)
            {
                if (weapon == gun.weapon)
                {
                    type = gun.ammunition;
                    break;
                }
            }
            return(type);
        }
Esempio n. 10
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);
        }
Esempio n. 11
0
        /// <summary>
        /// Gets the type of weapon based on the Hash.
        /// </summary>
        /// <param name="weapon">The <see cref="WeaponHash"/> to check.</param>
        /// <returns>The <see cref="WeaponType"/> of the weapon.</returns>
        public static WeaponType GetWeaponType(WeaponHash weapon)
        {
            // First, check the hash of the weapon itself
            switch (weapon)
            {
            // Invalid Weapons (aka no use for the GGO Mod)
            case WeaponHash.Unarmed:
                return(WeaponType.Invalid);

            // Primary Weapons (here because they have the wrong group)
            case WeaponHash.Musket:
                return(WeaponType.Primary);

            // Secondary Weapons (also with invalid group)
            case WeaponHash.MicroSMG:
            case WeaponHash.MachinePistol:
            case WeaponHash.MiniSMG:
            case WeaponHash.CompactGrenadeLauncher:
            case WeaponHash.SawnOffShotgun:
            case WeaponHash.DoubleBarrelShotgun:
            case WeaponHash.SweeperShotgun:
            case WeaponHash.StunGun:
                return(WeaponType.Secondary);
            }

            // Then, check the group
            switch (Function.Call <WeaponGroup>(Hash.GET_WEAPONTYPE_GROUP, weapon))
            {
            case WeaponGroup.AssaultRifle:
            case WeaponGroup.MG:
            case WeaponGroup.SMG:
            case WeaponGroup.Heavy:
            case WeaponGroup.Shotgun:
            case WeaponGroup.Sniper:
                return(WeaponType.Primary);

            case WeaponGroup.Pistol:
                return(WeaponType.Secondary);

            case WeaponGroup.Melee:
                return(WeaponType.Melee);

            case WeaponGroup.Thrown:
                return(WeaponType.Gear);
            }

            // If we got here, we don't know what type of weapon it is
            return(WeaponType.Unknown);
        }
Esempio n. 12
0
        public void authorized(Client player)
        {
            player.SetData("authorized", true);
            player.Position = new Vector3(-519.337f, 5341.695f, 74.10365f);
            Random rnd = new Random();

            Int32[] skins = { -1920001264, -1275859404 };
            int     index = rnd.Next(skins.Length);

            player.SetSkin((PedHash)skins[index]);
            WeaponHash weapHash = NAPI.Util.WeaponNameToModel("carbinerifle");

            NAPI.Player.GivePlayerWeapon(player, weapHash, 10);
            NAPI.ClientEvent.TriggerClientEvent(player, "cl_mainMenuCamera");
        }
Esempio n. 13
0
        public static void GivePlayerWeaponItems(Client player)
        {
            int itemId   = 0;
            int playerId = player.GetData(EntityData.PLAYER_SQL_ID);

            foreach (ItemModel item in Globals.itemList)
            {
                if (!int.TryParse(item.hash, out itemId) && item.ownerIdentifier == playerId && item.ownerEntity == Constants.ITEM_ENTITY_WHEEL)
                {
                    WeaponHash weaponHash = NAPI.Util.WeaponNameToModel(item.hash);
                    player.GiveWeapon(weaponHash, 0);
                    player.SetWeaponAmmo(weaponHash, item.amount);
                }
            }
        }
Esempio n. 14
0
        public static float BaseDamage(this WeaponHash weapon)
        {
            switch (weapon)
            {
            case WeaponHash.Unarmed: return(5.3f);

            case WeaponHash.StunGun:
            case WeaponHash.BZGas:
            case WeaponHash.FireExtinguisher:
            case WeaponHash.PetrolCan:
                return(0f);

            default: return(10f);
            }
        }
Esempio n. 15
0
        private static void API_onPlayerWeaponAmmoChange(Client player, WeaponHash weapon, int oldValue)
        {
            var p       = Player.PlayerData[player];
            var weapons = p.Weapons;

            foreach (var weap in weapons)
            {
                var ammo = API.shared.getPlayerWeaponAmmo(player, weap.Model);
                if (weap.Ammo != ammo)
                {
                    weap.Ammo = ammo;
                    API.shared.triggerClientEvent(player, "validatePlayerAimingAt");
                }
            }
        }
        private async Task OnTick()
        {
            await Delay(100);

            if (Game.Player.WantedLevel > 0)
            {
                foreach (Ped ped in World.GetAllPeds().Where(ped => !ped.IsPlayer))
                {
                    int pedType = API.GetPedType(ped.Handle);
                    if (pedType == 6 || pedType == 27 || pedType == 29)
                    {
                        ped.FiringPattern = FiringPattern.FullAuto;
                        ped.ShootRate     = 1;

                        if (!ped._HasDecor(Decors.COP_WEAPONIZED))
                        {
                            if (API.GetRandomIntInRange(0, 101) < 50)
                            {
                                WeaponHash[] possibleWeapons;
                                if (pedType == 6)
                                {
                                    possibleWeapons = new WeaponHash[] { WeaponHash.PistolMk2, WeaponHash.Pistol50, WeaponHash.CombatPistol, WeaponHash.HeavyPistol,
                                                                         WeaponHash.VintagePistol, WeaponHash.APPistol, WeaponHash.StunGun, WeaponHash.BullpupShotgun, WeaponHash.SMG, WeaponHash.SMGMk2,
                                                                         WeaponHash.AssaultSMG, WeaponHash.CombatPDW }
                                }
                                ;
                                else if (pedType == 27)
                                {
                                    possibleWeapons = new WeaponHash[] { WeaponHash.APPistol, WeaponHash.SMGMk2, WeaponHash.CarbineRifleMk2, WeaponHash.SpecialCarbine,
                                                                         WeaponHash.PumpShotgun, WeaponHash.BullpupRifle, WeaponHash.AdvancedRifle, WeaponHash.MarksmanRifle, WeaponHash.AssaultShotgun,
                                                                         WeaponHash.HeavyShotgun, WeaponHash.SniperRifle, WeaponHash.HeavySniper, WeaponHash.HeavySniperMk2 }
                                }
                                ;
                                else
                                {
                                    possibleWeapons = new WeaponHash[] { WeaponHash.PumpShotgun, WeaponHash.AssaultShotgun, WeaponHash.HeavyShotgun, WeaponHash.CombatPDW,
                                                                         WeaponHash.AssaultRifle, WeaponHash.AssaultRifleMk2, WeaponHash.CarbineRifleMk2, WeaponHash.SpecialCarbine, WeaponHash.AdvancedRifle,
                                                                         WeaponHash.MG, WeaponHash.CombatMG, WeaponHash.CombatMGMk2, WeaponHash.Minigun, WeaponHash.RPG }
                                };
                                ped.Weapons.Give(possibleWeapons[API.GetRandomIntInRange(0, possibleWeapons.Count())], int.MaxValue, false, true);
                            }
                            ped._SetDecor(Decors.COP_WEAPONIZED, true);
                        }
                    }
                }
            }
        }
    }
Esempio n. 17
0
        private void OnPlayerWeaponSwitch(Client player, WeaponHash oldWeapon, WeaponHash newWeapon)
        {
            if (NAPI.Data.HasEntityData(player, EntityData.PLAYER_PLAYING) == true)
            {
                // Obtenemos el identificador del jugador
                int playerId = NAPI.Data.GetEntityData(player, EntityData.PLAYER_SQL_ID);

                if (NAPI.Data.HasEntityData(player, EntityData.PLAYER_RIGHT_HAND) == true)
                {
                    int       itemId = NAPI.Data.GetEntityData(player, EntityData.PLAYER_RIGHT_HAND);
                    ItemModel item   = Globals.GetItemModelFromId(itemId);
                    if (Int32.TryParse(item.hash, out int itemHash) == true)
                    {
                        ItemModel weaponItem = GetEquippedWeaponItemModelByHash(playerId, newWeapon);
                        NAPI.Player.GivePlayerWeapon(player, WeaponHash.Unarmed, 1);
                        return;
                    }
                }

                // Obtenemos los modelos de armas antiguo y nuevos
                ItemModel oldWeaponModel     = GetEquippedWeaponItemModelByHash(playerId, oldWeapon);
                ItemModel currentWeaponModel = GetEquippedWeaponItemModelByHash(playerId, newWeapon);

                if (oldWeaponModel != null)
                {
                    // Desequipamos el arma antigua
                    oldWeaponModel.ownerEntity = Constants.ITEM_ENTITY_WHEEL;
                    Database.UpdateItem(oldWeaponModel);
                }

                if (currentWeaponModel != null)
                {
                    // Equipamos el arma nueva
                    currentWeaponModel.ownerEntity = Constants.ITEM_ENTITY_RIGHT_HAND;
                    Database.UpdateItem(currentWeaponModel);
                }

                // Miramos si es un arma o el puño
                if (newWeapon == WeaponHash.Unarmed)
                {
                    NAPI.Data.ResetEntityData(player, EntityData.PLAYER_RIGHT_HAND);
                }
                else
                {
                    NAPI.Data.SetEntityData(player, EntityData.PLAYER_RIGHT_HAND, currentWeaponModel.id);
                }
            }
        }
Esempio n. 18
0
        public static void SetPedWeaponFlag(Ped ped, WeaponHash weapon)
        {
            if (WeaponHashToFlag.ContainsKey(weapon))
            {
                int  WhichFlagInt = (int)Math.Ceiling(WeaponHashToFlag[weapon] / 32f) - 1;
                uint currentFlag  = 0;
                if (Function.Call <bool>(Hash.DECOR_EXIST_ON, ped.Handle, $"DamagedByWeaponFlags{WhichFlagInt}"))
                {
                    currentFlag = (uint)Function.Call <int>(Hash.DECOR_GET_INT, ped.Handle, $"DamagedByWeaponFlags{WhichFlagInt}");
                    Log.ToChat($"Fetched current weapon flag {currentFlag}");
                }

                Log.ToChat($"Setting flag value {(uint)1 << WeaponHashToFlag[weapon]}");
                Function.Call(Hash.DECOR_SET_INT, ped.Handle, $"DamagedByWeaponFlags{WhichFlagInt}", (int)(currentFlag | ((uint)1 << WeaponHashToFlag[weapon])));
            }
        }
    private void Loop(object sender, EventArgs e)
    {
        foreach (Ped ped in World.GetAllPeds())
        {
            WeaponHash currentWeapon = ped.Weapons.Current.Hash;
            if (!ped.IsPlayer && ped.IsHuman && ped.IsAlive && ped.Exists() && (Array.IndexOf(allowedWeapons, currentWeapon) < 0 || currentWeapon == unarmed))
            {
                int        allowedWeaponsIndex = random.Next(allowedWeapons.Length);
                WeaponHash newWeapon           = allowedWeapons[allowedWeaponsIndex];

                ped.Weapons.RemoveAll();
                bool equip = (currentWeapon != unarmed);
                ped.Weapons.Give(newWeapon, 0, equip, true);
            }
        }
    }
Esempio n. 20
0
        public static Weapon GetCurrentWeapon(Client player)
        {
            Character character = player.GetCharacter();

            WeaponHash currentWeapon = API.Shared.GetPlayerCurrentWeapon(player);

            Weapon[] weapon =
                InventoryManager.DoesInventoryHaveItem <Weapon>(character, x => x.WeaponHash == currentWeapon);

            if (weapon.Length > 0)
            {
                return(weapon[0]);
            }

            return(new Weapon(WeaponHash.Unarmed, WeaponTint.Normal, true, false, false, Group.None));
        }
Esempio n. 21
0
        public static void FIBDuty(Client c)
        {
            if (!c.HasData("character_id"))
            {
                return;
            }

            if (c.HasData("onduty"))
            {
                OffDuty(c);
                return;
            }

            if (c.GetData("isMale") == true)
            {
                c.SetClothes(9, 1, 1);
                c.SetClothes(7, 125, 0);
            }
            else
            {
                c.SetClothes(9, 1, 1);
                c.SetClothes(7, 95, 0);
            }


            c.RemoveAllWeapons();

            WeaponHash hash1 = NAPI.Util.WeaponNameToModel("pistol");

            c.GiveWeapon(hash1, 999);

            WeaponHash hash2 = NAPI.Util.WeaponNameToModel("smg");

            c.GiveWeapon(hash2, 999);

            WeaponHash hash3 = NAPI.Util.WeaponNameToModel("flashlight");

            c.GiveWeapon(hash3, 1);

            WeaponHash hash4 = NAPI.Util.WeaponNameToModel("nightstick");

            c.GiveWeapon(hash4, 1);


            c.SendNotification("Du bist nun im Dienst!");
            c.SetData("onduty", 1);
        }
Esempio n. 22
0
        public void OnPlayerWeaponSwitch(Client player, WeaponHash oldWeapon, WeaponHash newWeapon)
        {
            if (NAPI.Data.HasEntityData(player, EntityData.PLAYER_PLAYING) == true)
            {
                int playerId = NAPI.Data.GetEntityData(player, EntityData.PLAYER_SQL_ID);

                if (NAPI.Data.HasEntityData(player, EntityData.PLAYER_RIGHT_HAND) == true)
                {
                    int       itemId = NAPI.Data.GetEntityData(player, EntityData.PLAYER_RIGHT_HAND);
                    ItemModel item   = Globals.GetItemModelFromId(itemId);
                    if (Int32.TryParse(item.hash, out int itemHash) == true)
                    {
                        ItemModel weaponItem = GetEquippedWeaponItemModelByHash(playerId, newWeapon);
                        NAPI.Player.GivePlayerWeapon(player, WeaponHash.Unarmed, 1);
                        return;
                    }
                }

                // Get previous and new weapon models
                ItemModel oldWeaponModel     = GetEquippedWeaponItemModelByHash(playerId, oldWeapon);
                ItemModel currentWeaponModel = GetEquippedWeaponItemModelByHash(playerId, newWeapon);

                if (oldWeaponModel != null)
                {
                    // Unequip previous weapon
                    oldWeaponModel.ownerEntity = Constants.ITEM_ENTITY_WHEEL;
                    Database.UpdateItem(oldWeaponModel);
                }

                if (currentWeaponModel != null)
                {
                    // Equip new weapon
                    currentWeaponModel.ownerEntity = Constants.ITEM_ENTITY_RIGHT_HAND;
                    Database.UpdateItem(currentWeaponModel);
                }

                // Check if it's armed
                if (newWeapon == WeaponHash.Unarmed)
                {
                    NAPI.Data.ResetEntityData(player, EntityData.PLAYER_RIGHT_HAND);
                }
                else
                {
                    NAPI.Data.SetEntityData(player, EntityData.PLAYER_RIGHT_HAND, currentWeaponModel.id);
                }
            }
        }
Esempio n. 23
0
        public static void UnequipWeapon(Client client)
        {
            if (client.CurrentWeapon == WeaponHash.Unarmed)
            {
                return;
            }

            WeaponHash currentWeapon     = client.CurrentWeapon;
            bool       wasItemUnequipped = AccountUtil.RemovePlayerWeapon(client, currentWeapon);

            if (!wasItemUnequipped)
            {
                return;
            }

            InventoryHandler.AddItemToInventory(client, currentWeapon.ToString(), 1);
        }
Esempio n. 24
0
        /// <summary>
        ///     Transition to prone state
        /// </summary>
        private async Task TransitionToProneState()
        {
            try
            {
                var playerPed = Game.PlayerPed;
                State           = StanceStates.Prone;
                _proneAimActive = false;
                _proneState     = ProneStates.OnFront;
                _prevProneState = ProneStates.OnFront;
                _prevWeapon     = Game.PlayerPed.Weapons.Current.Hash;
                if (playerPed.IsRunning || playerPed.IsSprinting)
                {
                    playerPed.Task.ClearAll();
                    _diveActive = true;
                    await playerPed.Task.PlayAnimation("move_jump", "dive_start_run", 8f, -8f, -1,
                                                       AnimationFlags.RagdollOnCollision, 0);

                    //This is the ideal delay to make animation look good.  Do not change.
                    await BaseScript.Delay(1100);

                    _diveActive = false;
                }
                if (playerPed.IsRagdoll)
                {
                    State = StanceStates.Idle;
                }
                else
                {
                    if (API.IsPedArmed(playerPed.Handle, 4))
                    {
                        API.TaskAimGunScripted(playerPed.Handle,
                                               (uint)API.GetHashKey("SCRIPTED_GUN_TASK_PLANE_WING"), true, true);
                    }
                    else
                    {
                        await playerPed.Task.PlayAnimation("move_crawl", "onfront_fwd", 8f, -8f, -1,
                                                           (AnimationFlags)2, 0);
                    }
                }
                await Task.FromResult(0);
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }
        }
Esempio n. 25
0
        private void FactionWeaponSwitch(Client player, WeaponHash oldValue)
        {
            // Player doesn't have a faction, just remove the weapon for now.
            if (!player.hasData("Faction"))
            {
                API.removePlayerWeapon(player, player.currentWeapon);
                return;
            }


            FactionInfo info = player.getData("Faction");

            if (!Modules.isValidArmsForFaction(player, info))
            {
                API.removePlayerWeapon(player, player.currentWeapon);
            }
        }
Esempio n. 26
0
 public static bool IsMelee(WeaponHash hash)
 {
     return(hash == WeaponHash.Unarmed ||
            hash == WeaponHash.Knife ||
            hash == WeaponHash.Nightstick ||
            hash == WeaponHash.Hammer ||
            hash == WeaponHash.Bat ||
            hash == WeaponHash.Crowbar ||
            hash == WeaponHash.GolfClub ||
            hash == WeaponHash.Dagger ||
            hash == WeaponHash.Hatchet ||
            hash == WeaponHash.KnuckleDuster ||
            hash == WeaponHash.Machete ||
            hash == WeaponHash.Flashlight ||
            hash == WeaponHash.SwitchBlade
            );
 }
Esempio n. 27
0
        // Draw Weapon
        private async Task DrawWeapon(string _animType, CharacterInventoryItem _weapon)
        {
            // Animation
            await Game.Player.Character.Task.PlayAnimation(WeaponDrawAnimations[_animType][0], WeaponDrawAnimations[_animType][1], 10f, 10f, 2750, AnimationFlags.None | AnimationFlags.AllowRotation | AnimationFlags.UpperBodyOnly, -10f);

            // Slots
            if (SessionManager.PlayerSession.SpawnedCharacter.Inventory.PrimaryWeaponOne == _weapon)
            {
                if (WeaponSlotOne != null)
                {
                    WeaponSlotOne.Delete();
                    WeaponSlotOne = null;
                }
            }
            else if (SessionManager.PlayerSession.SpawnedCharacter.Inventory.PrimaryWeaponTwo == _weapon)
            {
                if (WeaponSlotTwo != null)
                {
                    WeaponSlotTwo.Delete();
                    WeaponSlotTwo = null;
                }
            }

            // Weapon Mag
            CharacterInventoryItem Magazine = _weapon.Magazine;

            int ammoCount = 0;

            if (Magazine != null)
            {
                ammoCount = Convert.ToInt32(Magazine.Data["AmmoCount"]);
            }
            ammoCount = 1;


            // Weapon Hash
            WeaponHash givenWeapon = (WeaponHash)Game.GenerateHash(_weapon.Data["WeaponModel"].ToString());

            Game.Player.Character.Weapons.Give(givenWeapon, ammoCount, true, ammoCount == 0 ? false : true);
            // Attachments [ NONE ]

            EquippedWeapon = _weapon;
            Utils.WriteLine("WEAPON DRAWING");
            Utils.WriteLine($"Weapon Equipped: {EquippedWeapon.Name}");
        }
Esempio n. 28
0
        private int GiveRandomWeapons()
        {
            int           count            = 0;
            HashSet <int> newProcessedPeds = new HashSet <int>();

            Ped[] allPeds = World.GetAllPeds();
            foreach (Ped ped in allPeds)
            {
                // To make cops have random weapons (they are given weapons after they leave car
                // TODO it seemed that it would reset otherwise, or maybe not? - should test this again
                if (ped.IsInVehicle())
                {
                    continue;
                }

                newProcessedPeds.Add(ped.Handle);

                if (processedPeds.Contains(ped.Handle))
                {
                    continue;
                }
                if (!ped.IsAlive)
                {
                    continue;
                }
                if (ped.IsPlayer)
                {
                    continue;
                }

                // TODO maybe removing weapons should not be done - weapons removed from player?
                ped.Weapons.RemoveAll();
                WeaponHash randomWeaponHash = (WeaponHash)allWeapons[random.Next(allWeapons.Length)];
                ped.Weapons.Give(randomWeaponHash, 500, true, true);
                if (config.tintedWeapons)
                {
                    ped.Weapons.Current.Tint = allWeaponTints[random.Next(allWeaponTints.Length)];
                }

                count++;
            }

            processedPeds = newProcessedPeds;
            return(count);
        }
Esempio n. 29
0
        public static bool DoesPlayerHaveWeapon(Client client, WeaponHash hash)
        {
            Account account = RetrieveAccount(client);

            if (account.Weapons == "")
            {
                return(false);
            }

            List <WeaponHash> equipment = JsonConvert.DeserializeObject <List <WeaponHash> >(account.Weapons);

            if (!equipment.Contains(hash))
            {
                return(false);
            }

            return(true);
        }
Esempio n. 30
0
 public Weapon this[WeaponHash hash]
 {
     get
     {
         Weapon weapon = null;
         if (!this._weapons.TryGetValue(hash, out weapon))
         {
             InputArgument[] arguments = new InputArgument[] { this._owner.Handle, hash, 0 };
             if (!Function.Call <bool>(Hash.HAS_PED_GOT_WEAPON, arguments))
             {
                 return(null);
             }
             weapon = new Weapon(this._owner, hash);
             this._weapons.Add(hash, weapon);
         }
         return(weapon);
     }
 }
Esempio n. 31
0
 public static bool HasSuppressor(WeaponHash weapon)
 {
     try
     {
         if (Game.Player.Character.Weapons[weapon].Components.GetSuppressorComponent().Active)
         {
             return(true);
         }
         else
         {
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
Esempio n. 32
0
 public static bool HasFlashLight(WeaponHash weapon)
 {
     try
     {
         if (Game.Player.Character.Weapons[weapon].Components.GetFlashLightComponent().Active)
         {
             return(true);
         }
         else
         {
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
Esempio n. 33
0
        public static void LoadDatabaseItems()
        {
            // Create the item list
            Globals.itemList = Database.LoadAllItems();

            // Get the objects on the ground
            List <ItemModel> groundItems = Globals.itemList.Where(it => it.ownerEntity == Constants.ITEM_ENTITY_GROUND).ToList();

            foreach (ItemModel item in groundItems)
            {
                // Get the hash from the object
                WeaponHash weaponHash = NAPI.Util.WeaponNameToModel(item.hash);
                uint       hash       = weaponHash == 0 ? uint.Parse(item.hash) : NAPI.Util.GetHashKey(Constants.WEAPON_ITEM_MODELS[weaponHash]);

                // Create each of the items on the ground
                item.objectHandle = NAPI.Object.CreateObject(hash, item.position, new Vector3(), 255, item.dimension);
            }
        }
Esempio n. 34
0
        public Weapon this[WeaponHash hash]
        {
            get
            {
                if (!weapons.TryGetValue(hash, out Weapon weapon))
                {
                    if (!Function.Call <bool>(Hash.HAS_PED_GOT_WEAPON, owner.Handle, (uint)hash, 0))
                    {
                        return(null);
                    }

                    weapon = new Weapon(owner, hash);
                    weapons.Add(hash, weapon);
                }

                return(weapon);
            }
        }
Esempio n. 35
0
        public static AnimationName GetWeaponAnimation(WeaponHash hash, float pitchToTarget)
        {
            var animation = new AnimationName();
            if (pitchToTarget < -45)
            {
                animation.Name = "fire_low";
            }
            else if (pitchToTarget > 30)
            {
                animation.Name = "fire_high";
            }
            else
            {
                animation.Name = "fire_med";
            }

            animation.Group = "weapons@rifle@hi@";
            //Heavy
            if (hash == WeaponHash.GrenadeLauncher)
            {
                animation.Group = "weapons@heavy@grenade_launcher";
            }
            if (hash == WeaponHash.RPG)
            {
                animation.Group = "weapons@heavy@rpg";
            }
            if (hash == WeaponHash.Minigun)
            {
                animation.Group = "weapons@heavy@minigun";
            }
            if (hash == WeaponHash.Firework)
            {
                animation.Group = "weapons@heavy@rpg";
            }
            if (hash == WeaponHash.Railgun)
            {
                animation.Group = "weapons@rifle@lo@pump";
            }

            //Pistols
            if (hash == WeaponHash.Pistol)
            {
                animation.Group = "weapons@pistol@";
            }
            if (hash == WeaponHash.CombatPistol)
            {
                animation.Group = "weapons@pistol@";
            }
            if (hash == WeaponHash.Pistol50)
            {
                animation.Group = "weapons@pistol@pistol_50";
            }
            if (hash == WeaponHash.SNSPistol)
            {
                animation.Group = "weapons@pistol@";
            }
            if (hash == WeaponHash.HeavyPistol)
            {
                animation.Group = "weapons@pistol@";
            }
            if (hash == WeaponHash.VintagePistol)
            {
                animation.Group = "weapons@pistol@";
            }
            if (hash == WeaponHash.MarksmanPistol)
            {
                animation.Group = "weapons@pistol@";
            }
            if (hash == WeaponHash.Revolver)
            {
                animation.Group = "weapons@pistol@";
            }
            if (hash == WeaponHash.APPistol)
            {
                animation.Group = "weapons@pistol@ap_pistol";
            }
            if (hash == WeaponHash.StunGun)
            {
                animation.Group = "weapons@pistol@";
            }

            //SMG
            if (hash == WeaponHash.MicroSMG)
            {
                animation.Group = "weapons@submg@micro_smg";
            }
            if (hash == WeaponHash.MachinePistol)
            {
                animation.Group = "weapons@rifle@lo@smg";
            }
            if (hash == WeaponHash.SMG)
            {
                animation.Group = "weapons@rifle@lo@smg";
            }
            if (hash == WeaponHash.AssaultSMG)
            {
                animation.Group = "weapons@submg@assault_smg";
            }
            if (hash == WeaponHash.CombatPDW)
            {
                animation.Group = "weapons@rifle@lo@smg";
            }
            if (hash == WeaponHash.MG)
            {
                animation.Group = "weapons@submg@";
            }
            if (hash == WeaponHash.CombatMG)
            {
                animation.Group = "weapons@submg@";
            }
            if (hash == WeaponHash.Gusenberg)
            {
                animation.Group = "weapons@rifle@lo@smg";
            }

            //Shotguns
            if (hash == WeaponHash.PumpShotgun)
            {
                animation.Group = "weapons@rifle@lo@pump";
            }
            if (hash == WeaponHash.SawnOffShotgun)
            {
                animation.Group = "weapons@rifle@lo@pump";
            }
            if (hash == WeaponHash.BullpupShotgun)
            {
                animation.Group = "weapons@rifle@lo@shotgun_bullpup";
            }
            if (hash == WeaponHash.AssaultShotgun)
            {
                animation.Group = "weapons@rifle@lo@shotgun_assault";
            }
            if (hash == WeaponHash.Musket)
            {
                animation.Group = "weapons@rifle@lo@pump";
            }
            if (hash == WeaponHash.HeavyShotgun)
            {
                animation.Group = "weapons@rifle@lo@pump";
            }

            //Rifles
            if (hash == WeaponHash.AssaultRifle)
            {
                animation.Group = "weapons@rifle@hi@";
            }
            if (hash == WeaponHash.CarbineRifle)
            {
                animation.Group = "weapons@rifle@lo@";
            }
            if (hash == WeaponHash.AdvancedRifle)
            {
                animation.Group = "weapons@rifle@hi@";
            }
            if (hash == WeaponHash.SpecialCarbine)
            {
                animation.Group = "weapons@rifle@lo@";
            }
            if (hash == WeaponHash.BullpupRifle)
            {
                animation.Group = "weapons@rifle@hi@";
            }

            //Sniper
            if (hash == WeaponHash.SniperRifle)
            {
                animation.Group = "weapons@rifle@hi@sniper_rifle";
            }
            if (hash == WeaponHash.HeavySniper)
            {
                animation.Group = "weapons@rifle@lo@sniper_heavy";
            }
            if (hash == WeaponHash.MarksmanRifle)
            {
                animation.Group = "weapons@rifle@hi@sniper_rifle";
            }

            return animation;
        }
Esempio n. 36
0
 internal static void ChangeWeaponTint(WeaponHash weaponHash, int tintIndex)
 {
     Function.Call(Hash.SET_PED_WEAPON_TINT_INDEX, Game.Player.Character, (int) weaponHash, tintIndex);
 }
Esempio n. 37
0
 public void ShowWeaponPurchasedMessage(string bigMessage, string weaponName, WeaponHash weapon, int time = 5000)
 {
     Load(true);
     _start = Game.GameTime;
     _sc.CallFunction("SHOW_WEAPON_PURCHASED", bigMessage, weaponName, unchecked((int)weapon), "", 100);
     _timer = time;
 }
Esempio n. 38
0
 public WeaponDefinition GetWeapon(WeaponHash wepHash)
 {
     return Weapons.FirstOrDefault(s => s.WeaponHash == wepHash);
 }
Esempio n. 39
0
 public void GiveWeapon(WeaponHash w)
 {
     ped.Weapons.Give(w, 9999, true, true);
 }