653 {
654 if (player)
655 {
657 {
659 {
660 if (!
g_Game.IsMultiplayer())
661 player.DropItem(player.GetItemInHands());
662 else
663 player.ServerDropEntity(player.GetItemInHands());
664
666
667 return null;
668 }
669
670
671 #ifdef DEVELOPER
672 if (
g_Game.IsKindOf(item_name,
"Transport"))
673 {
675 auto debugParams = DebugSpawnParams.WithPlayer(player);
676 vehicle.OnDebugSpawnEx(debugParams);
677
678 if (
g_Game.IsMultiplayer())
679 {
680 DayZPlayerSyncJunctures.SendGetInVehicle(player, vehicle);
681 }
682 else
683 {
684 player.SetGetInVehicleDebug(vehicle);
685 }
686
687 return vehicle;
688 }
689 #endif
690
691 InventoryLocation il = new InventoryLocation;
692 if (player.GetInventory() && player.GetInventory().FindFirstFreeLocationForNewEntity(item_name, locationType, il))
693 {
694 Weapon_Base wpn = Weapon_Base.Cast(il.
GetParent());
695 bool is_mag = il.
GetSlot() == InventorySlots.MAGAZINE || il.
GetSlot() == InventorySlots.MAGAZINE2 || il.
GetSlot() == InventorySlots.MAGAZINE3;
696 if (wpn && is_mag)
697 {
698 vector pos = player.GetPosition();
700 Magazine mag_gnd = Magazine.Cast(eai_gnd);
701 if (mag_gnd && player.GetWeaponManager().CanAttachMagazine(wpn, mag_gnd))
702 {
703 player.GetWeaponManager().AttachMagazine(mag_gnd);
704 }
705 return eai_gnd;
706 }
707 else
708 {
710 if ( eai && eai.IsInherited(
ItemBase) )
711 {
712 if ( health < 0 )
713 {
714 health = eai.GetMaxHealth();
715 }
718 if ( special )
719 {
720 auto debugParams2 = DebugSpawnParams.WithPlayer(player);
721 eai.OnDebugSpawnEx(debugParams2);
722 }
723 }
724 return eai;
725 }
726 }
727 else
729 return NULL;
730 }
731 else
732 {
733
735 player.RPCSingleParam(
ERPCs.DEV_RPC_SPAWN_ITEM_IN_INVENTORY, params,
true);
736 }
737 }
738 return NULL;
739 }
proto native void SpawnEntity(string sClassName, vector vPos, float fRange, int iCount)
Spawn an entity through CE.
const int ECE_IN_INVENTORY
class GP5GasMask extends MaskBase ItemBase
FindInventoryLocationType
flags for searching locations in inventory
void SetupSpawnedItem(ItemBase item, float health, float quantity)
Param7 DevSpawnItemParams
proto native EntityAI GetParent()
returns parent of current inventory location
proto native int GetSlot()
returns slot id if current type is Attachment
void OnSpawnErrorReport(string name)
EntityAI SpawnEntityInPlayerInventory(PlayerBase player, string item_name, float health, float quantity, bool special=false, string presetName="", FindInventoryLocationType locationType=FindInventoryLocationType.ANY)
EntityAI SpawnEntityOnGroundPos(PlayerBase player, string object_name, vector pos)