forked from arturf1/GTA5-Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMeasureType.cs
More file actions
84 lines (72 loc) · 2.61 KB
/
Copy pathMeasureType.cs
File metadata and controls
84 lines (72 loc) · 2.61 KB
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
/*
Authors: Artur Filipowicz
Version: 0.9
Copyright: 2016
MIT License
*/
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
using GTA;
using GTA.Native;
using GTA.Math;
public class MeasureType : Script
{
bool pointToggle;
bool enabled;
bool measure;
Vector3 startPoint;
Vector3 endPoint;
public MeasureType()
{
UI.Notify("Loaded MeasureType.cs");
startPoint = Game.Player.Character.Position;
endPoint = Game.Player.Character.Position;
// attach time methods
Tick += OnTick;
KeyUp += onKeyUp;
}
private void onKeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.NumPad3)
{
enabled = !enabled;
}
if (e.KeyCode == Keys.NumPad9)
{
pointToggle = !pointToggle;
}
if (e.KeyCode == Keys.M)
{
measure = !measure;
}
}
void OnTick(object sender, EventArgs e)
{
if (enabled)
{
if(measure)
{
World.DrawMarker(MarkerType.DebugSphere, startPoint, new Vector3(0,0,0), new Vector3(0,0,0), new Vector3(.3f,.3f,.3f), Color.Green);
World.DrawMarker(MarkerType.DebugSphere, endPoint, new Vector3(0,0,0), new Vector3(0,0,0), new Vector3(.3f,.3f,.3f), Color.Black);
UI.ShowSubtitle("Distance " + startPoint.DistanceTo(endPoint).ToString());
}
else
{
if(pointToggle)
{
World.DrawMarker(MarkerType.DebugSphere, Game.Player.Character.Position + 5f*GameplayCamera.Direction, new Vector3(0,0,0), new Vector3(0,0,0), new Vector3(.3f,.3f,.3f), Color.Green);
startPoint = Game.Player.Character.Position + 5f*GameplayCamera.Direction;
World.DrawMarker(MarkerType.DebugSphere, endPoint, new Vector3(0,0,0), new Vector3(0,0,0), new Vector3(.3f,.3f,.3f), Color.Black);
}
else
{
World.DrawMarker(MarkerType.DebugSphere, Game.Player.Character.Position + 5f*GameplayCamera.Direction, new Vector3(0,0,0), new Vector3(0,0,0), new Vector3(.3f,.3f,.3f), Color.Black);
endPoint = Game.Player.Character.Position + 5f*GameplayCamera.Direction;
World.DrawMarker(MarkerType.DebugSphere, startPoint, new Vector3(0,0,0), new Vector3(0,0,0), new Vector3(.3f,.3f,.3f), Color.Green);
}
}
}
}
}