DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
ActionPullOutPlug.c
Go to the documentation of this file.
2{
4 {
5 m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_INTERACTONCE;
6 m_Text = "#pull_out_plug";
7 }
8
9 override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
10 {
11 Object targetObject = target.GetObject();
12 EntityAI target_EAI = EntityAI.Cast( target.GetObject() );
13
14 if ( target_EAI.HasEnergyManager() )
15 {
16 string selection = targetObject.GetActionComponentName(target.GetComponentIndex());
17
18
19 if ( GetGame().IsServer() )
20 {
21 EntityAI device = target_EAI.GetCompEM().GetPlugOwner(selection);
22
23 if ( device )
24 {
25 return true;
26 }
27 }
28 else
29 {
30 return target_EAI.GetCompEM().IsSelectionAPlug(selection);
31 }
32 }
33
34 return false;
35 }
36
37 override void OnExecuteServer( ActionData action_data )
38 {
39 Object targetObject = action_data.m_Target.GetObject();
40 if ( targetObject )
41 {
42 EntityAI target_EAI = EntityAI.Cast( targetObject );
43 string selection = targetObject.GetActionComponentName(action_data.m_Target.GetComponentIndex());
44
45 EntityAI device = EntityAI.Cast( target_EAI.GetCompEM().GetPlugOwner(selection) );
46 if ( device )
47 {
48 device.GetCompEM().UnplugThis();
49 }
50
51 // Disable Advanced Placement
52 if ( action_data.m_Player.IsPlacingServer() )
53 {
54 action_data.m_Player.PlacingCancelServer();
55 }
56 }
57 }
58};
protected string m_Text
Definition ActionBase.c:49
class ActionTargets ActionTarget
PlayerBase m_Player
Definition ActionBase.c:33
ref ActionTarget m_Target
Definition ActionBase.c:32
override void OnExecuteServer(ActionData action_data)
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:602
proto native CGame GetGame()