-
Notifications
You must be signed in to change notification settings - Fork 0
/
ForceActionMode.cs
120 lines (105 loc) · 3.05 KB
/
ForceActionMode.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
using System;
using GTA;
using GTA.Native;
using System.Windows.Forms;
namespace ActionMode
{
public class EntryPoint : Script
{
bool TOGGLE = true; // Should mod be toggled on first start?
bool bShowAlert=true; // Show on screen short message for script status
bool bArmedOnly = true; // Only put in action mode when armed, no fists
bool bApplyToGroup = false; // Force your bodyguards to go into action mode
Keys myKey = Keys.T; // Change 'T' to any key you want, see https://msdn.microsoft.com/en-us/library/system.windows.forms.keys(v=vs.110).aspx
Ped playerPed = null;
public EntryPoint()
{
playerPed = Game.Player.Character;
base.Tick += new EventHandler(this.OnTick);
base.Interval = 750;
KeyDown += OnKeyDown;
}
protected override void Dispose(bool A_0)
{
base.Dispose(A_0);
}
bool IsValid(ref Ped ped)
{
return ped != null && ped.Exists() && ped.IsAlive;
}
bool IsPedArmed(ref Ped ped)
{
return ped.Weapons.Current.Hash != WeaponHash.Unarmed;
}
bool IsPedInActionMode(ref Ped ped)
{
return Function.Call<bool>(Hash.IS_PED_USING_ACTION_MODE, ped);
}
void PutPedIntoActionMode(ref Ped ped, bool toggle)
{
Function.Call(Hash.SET_PED_USING_ACTION_MODE, ped, toggle, -1, "DEFAULT_ACTION");
}
void UpdateActionMode(ref Ped ped)
{
if (IsValid(ref ped))
{
if(bArmedOnly)
{
if(!IsPedArmed(ref ped) && IsPedInActionMode(ref ped)) PutPedIntoActionMode(ref ped, false);
else if(IsPedArmed(ref ped) && !IsPedInActionMode(ref ped)) PutPedIntoActionMode(ref ped, true);
}
else
{
PutPedIntoActionMode(ref ped, true);
}
}
}
void UpdatePlayerGroup()
{
int groupCount = Game.Player.Character.CurrentPedGroup.MemberCount;
for(int i = 0; i < groupCount; i++)
{
Ped curPed = Game.Player.Character.CurrentPedGroup.GetMember(i);
UpdateActionMode(ref curPed);
}
}
void UpdatePlayer()
{
UpdateActionMode(ref playerPed);
}
public void OnTick(object sender, EventArgs e)
{
if(TOGGLE)
{
if(Function.Call<bool>(Hash.IS_ENTITY_ON_SCREEN, Game.Player.Character))
{
playerPed = Game.Player.Character;
if (bApplyToGroup)
{
UpdatePlayerGroup();
UpdatePlayer();
}
else
{
UpdatePlayer();
}
}
}
}
private void OnKeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
if(e.KeyCode == myKey)
{
if(TOGGLE){
PutPedIntoActionMode(ref playerPed, false);
TOGGLE=false;
}
else if(!TOGGLE)
{
TOGGLE=true;
}
if(bShowAlert) UI.ShowSubtitle("ForceActionMode : " + (TOGGLE == true ? "~g~true" : "~r~false"), 1000);
}
}
}
}