540 {
541 if (player)
542 {
544 {
546 {
547 if (!
GetGame().IsMultiplayer())
548 player.DropItem(player.GetItemInHands());
549 else
550 player.ServerDropEntity(player.GetItemInHands());
551
553
554 return null;
555 }
556
557
558 #ifdef DEVELOPER
559 if (
GetGame().IsKindOf(item_name,
"Transport"))
560 {
562 auto debugParams = DebugSpawnParams.WithPlayer(player);
563 vehicle.OnDebugSpawnEx(debugParams);
564
566 {
567 DayZPlayerSyncJunctures.SendGetInVehicle(player, vehicle);
568 }
569 else
570 {
571 player.SetGetInVehicleDebug(vehicle);
572 }
573
574 return vehicle;
575 }
576 #endif
577
578 InventoryLocation il = new InventoryLocation;
579 if (player.GetInventory() && player.GetInventory().FindFirstFreeLocationForNewEntity(item_name, locationType, il))
580 {
581 Weapon_Base wpn = Weapon_Base.Cast(il.
GetParent());
582 bool is_mag = il.
GetSlot() == InventorySlots.MAGAZINE || il.
GetSlot() == InventorySlots.MAGAZINE2 || il.
GetSlot() == InventorySlots.MAGAZINE3;
583 if (wpn && is_mag)
584 {
585 vector pos = player.GetPosition();
587 Magazine mag_gnd = Magazine.Cast(eai_gnd);
588 if (mag_gnd && player.GetWeaponManager().CanAttachMagazine(wpn, mag_gnd))
589 {
590 player.GetWeaponManager().AttachMagazine(mag_gnd);
591 }
592 return eai_gnd;
593 }
594 else
595 {
597 if ( eai && eai.IsInherited(
ItemBase) )
598 {
599 if ( health < 0 )
600 {
601 health = eai.GetMaxHealth();
602 }
605 if ( special )
606 {
607 auto debugParams2 = DebugSpawnParams.WithPlayer(player);
608 eai.OnDebugSpawnEx(debugParams2);
609 }
610 }
611 return eai;
612 }
613 }
614 else
616 return NULL;
617 }
618 else
619 {
620
622 player.RPCSingleParam(
ERPCs.DEV_RPC_SPAWN_ITEM_IN_INVENTORY, params,
true);
623 }
624 }
625 return NULL;
626 }
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
override ScriptCallQueue GetCallQueue(int call_category)
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 item_name, float health, float quantity, vector pos, bool special=false, bool withPhysics=false)
spawns entity on exact position
proto void CallLater(func fn, int delay=0, bool repeat=false, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
adds call into the queue with given parameters and arguments (arguments are held in memory until the ...
proto native CGame GetGame()