604 {
605 if (player)
606 {
608 {
610 {
611 if (!
g_Game.IsMultiplayer())
612 player.DropItem(player.GetItemInHands());
613 else
614 player.ServerDropEntity(player.GetItemInHands());
615
617
618 return null;
619 }
620
621
622 #ifdef DEVELOPER
623 if (
g_Game.IsKindOf(item_name,
"Transport"))
624 {
626 auto debugParams = DebugSpawnParams.WithPlayer(player);
627 vehicle.OnDebugSpawnEx(debugParams);
628
629 if (
g_Game.IsMultiplayer())
630 {
631 DayZPlayerSyncJunctures.SendGetInVehicle(player, vehicle);
632 }
633 else
634 {
635 player.SetGetInVehicleDebug(vehicle);
636 }
637
638 return vehicle;
639 }
640 #endif
641
642 InventoryLocation il = new InventoryLocation;
643 if (player.GetInventory() && player.GetInventory().FindFirstFreeLocationForNewEntity(item_name, locationType, il))
644 {
645 Weapon_Base wpn = Weapon_Base.Cast(il.
GetParent());
646 bool is_mag = il.
GetSlot() == InventorySlots.MAGAZINE || il.
GetSlot() == InventorySlots.MAGAZINE2 || il.
GetSlot() == InventorySlots.MAGAZINE3;
647 if (wpn && is_mag)
648 {
649 vector pos = player.GetPosition();
651 Magazine mag_gnd = Magazine.Cast(eai_gnd);
652 if (mag_gnd && player.GetWeaponManager().CanAttachMagazine(wpn, mag_gnd))
653 {
654 player.GetWeaponManager().AttachMagazine(mag_gnd);
655 }
656 return eai_gnd;
657 }
658 else
659 {
661 if ( eai && eai.IsInherited(
ItemBase) )
662 {
663 if ( health < 0 )
664 {
665 health = eai.GetMaxHealth();
666 }
669 if ( special )
670 {
671 auto debugParams2 = DebugSpawnParams.WithPlayer(player);
672 eai.OnDebugSpawnEx(debugParams2);
673 }
674 }
675 return eai;
676 }
677 }
678 else
680 return NULL;
681 }
682 else
683 {
684
686 player.RPCSingleParam(
ERPCs.DEV_RPC_SPAWN_ITEM_IN_INVENTORY, params,
true);
687 }
688 }
689 return NULL;
690 }
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< EntityAI, string, float, float, bool, string, FindInventoryLocationType > 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)