public static void GivePlayerNewWeapon(Client player, WeaponHash weapon, int bullets, bool licensed) { // Create weapon model ItemModel weaponModel = new ItemModel(); { weaponModel.hash = weapon.ToString(); weaponModel.amount = bullets; weaponModel.ownerEntity = Constants.ITEM_ENTITY_WHEEL; weaponModel.ownerIdentifier = player.GetData(EntityData.PLAYER_SQL_ID); weaponModel.position = new Vector3(0.0f, 0.0f, 0.0f); weaponModel.dimension = 0; } Task.Factory.StartNew(() => { weaponModel.id = Database.AddNewItem(weaponModel); Globals.itemList.Add(weaponModel); }); player.GiveWeapon(weapon, 0); player.SetWeaponAmmo(weapon, bullets); if (licensed) { Task.Factory.StartNew(() => { // We add the weapon as a registered into database Database.AddLicensedWeapon(weaponModel.id, player.Name); }); } }
public void HideReticle() { Weapon w = Game.PlayerPed?.Weapons?.Current; if (w != null) { WeaponHash wHash = w.Hash; if (wHash.ToString() != "SniperRifle") { HideHudComponentThisFrame(14); } } }
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); }
public static void GivePlayerNewWeapon(Client player, WeaponHash weapon, int bullets, bool licensed) { // Create weapon model ItemModel weaponModel = new ItemModel(); { weaponModel.hash = weapon.ToString(); weaponModel.amount = bullets; weaponModel.ownerEntity = Constants.ITEM_ENTITY_PLAYER; weaponModel.ownerIdentifier = player.GetData(EntityData.PLAYER_SQL_ID); weaponModel.position = new Vector3(); weaponModel.dimension = 0; } weaponModel.id = Database.AddNewItem(weaponModel); Globals.itemList.Add(weaponModel); // Give the weapon to the player player.SetWeaponAmmo(weapon, bullets); if (licensed) { Task.Factory.StartNew(() => { NAPI.Task.Run(() => { // We add the weapon as a registered into database Database.AddLicensedWeapon(weaponModel.id, player.Name); }); }); } if (player.GetSharedData(EntityData.PLAYER_RIGHT_HAND) != null) { // Remove the item on the hand NAPI.ClientEvent.TriggerClientEventInDimension(player.Dimension, "dettachItemFromPlayer", player.Value); player.ResetSharedData(EntityData.PLAYER_RIGHT_HAND); } // Add the attachment to the player AttachmentModel attachment = new AttachmentModel(weaponModel.id, "IK_R_Hand", weaponModel.hash, new Vector3(), new Vector3()); player.SetSharedData(EntityData.PLAYER_RIGHT_HAND, NAPI.Util.ToJson(attachment)); }
private async Task ProcessTask() { // gets client's current weapon. Weapon w = Game.PlayerPed?.Weapons?.Current; if (w != null) { WeaponHash wHash = w.Hash; if (!_overrideDisable.Contains(wHash) && API.GetHashKey(wHash.ToString()) != -1783943904) // add MarksmanRifle MKII { // if ace perm "Reticle" is not allowed (cannot have reticle) then.. if (!_reticleAllowed) { // hides reticle (white dot [HUD] when aiming in). API.HideHudComponentThisFrame(14); } } } }
public static void GivePlayerNewWeapon(Client player, WeaponHash weapon, int bullets, bool licensed) { // Creamos el objeto ItemModel weaponModel = new ItemModel(); weaponModel.hash = weapon.ToString(); weaponModel.amount = bullets; weaponModel.ownerEntity = Constants.ITEM_ENTITY_WHEEL; weaponModel.ownerIdentifier = NAPI.Data.GetEntityData(player, EntityData.PLAYER_SQL_ID); weaponModel.position = new Vector3(0.0f, 0.0f, 0.0f); weaponModel.dimension = 0; weaponModel.id = Database.AddNewItem(weaponModel); Globals.itemList.Add(weaponModel); // Damos el arma al jugador NAPI.Player.GivePlayerWeapon(player, weapon, 0); NAPI.Player.SetPlayerWeaponAmmo(player, weapon, bullets); // Miramos si es un arma registrada if (licensed) { Database.AddLicensedWeapon(weaponModel.id, player.Name); } }
public static ItemModel GetEquippedWeaponItemModelByHash(int playerId, WeaponHash weapon) { // Get the equipped weapon's item model return(Globals.itemList.Where(itemModel => itemModel.ownerIdentifier == playerId && (itemModel.ownerEntity == Constants.ITEM_ENTITY_WHEEL || itemModel.ownerEntity == Constants.ITEM_ENTITY_RIGHT_HAND) && weapon.ToString() == itemModel.hash).FirstOrDefault()); }
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); }