Skip to content

Commit 3ac65f7

Browse files
authored
📝 adding the codes from version v0.1.0.0. (#1)
1 parent e2ce041 commit 3ac65f7

File tree

6 files changed

+302
-0
lines changed

6 files changed

+302
-0
lines changed

Waypoint-marked-with-laser.sln

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.1.32414.318
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Waypoint-marked-with-laser", "Waypoint-marked-with-laser\Waypoint-marked-with-laser.csproj", "{4A49673F-0E7F-4005-AD98-AD51362D0939}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{4A49673F-0E7F-4005-AD98-AD51362D0939}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{4A49673F-0E7F-4005-AD98-AD51362D0939}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{4A49673F-0E7F-4005-AD98-AD51362D0939}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{4A49673F-0E7F-4005-AD98-AD51362D0939}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {98E3FC99-F218-49D2-B297-1BA71A51AC70}
24+
EndGlobalSection
25+
EndGlobal

Waypoint-marked-with-laser/Main.cs

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
using GTA;
2+
using GTA.Math;
3+
4+
5+
using System;
6+
using System.Drawing;
7+
8+
using Waypoint_marked_with_laser.creative_table;
9+
using Waypoint_marked_with_laser.setup_manager;
10+
11+
namespace Waypoint_marked_with_laser
12+
{
13+
public class Main : Script
14+
{
15+
private Ped player =
16+
Game.Player.Character;
17+
18+
private LaserSource laserSource =
19+
new LaserSource();
20+
21+
private Boolean IsThereLaserOnTheMap =
22+
false;
23+
24+
private Color colorOfTheLaserBeam =
25+
new Color();
26+
27+
private Vector3 waypointPosition =
28+
new Vector3();
29+
private Vector3 currentWaypointPosition =
30+
new Vector3();
31+
32+
33+
public Main()
34+
{
35+
new Settings(GetRelativeFilePath(@"WaypointMarkedWithLaser"));
36+
37+
colorOfTheLaserBeam =
38+
SettingColor.ColorOfTheLaserBeam;
39+
40+
Tick += (o, e) =>
41+
{ Start(); };
42+
43+
Aborted += (o, e) =>
44+
{ Finish(); };
45+
}
46+
47+
48+
49+
private void Start()
50+
{
51+
var waypointBlip =
52+
World.WaypointBlip;
53+
54+
var isItPossibleToGenerateTheStructureThatFiresTheLaser =
55+
(waypointBlip != null && !IsThereLaserOnTheMap);
56+
57+
58+
if (isItPossibleToGenerateTheStructureThatFiresTheLaser)
59+
{
60+
GenerateTheLaserStructure();
61+
62+
currentWaypointPosition = World.WaypointPosition;
63+
}
64+
else if (waypointBlip != null)
65+
{
66+
waypointPosition = World.WaypointPosition;
67+
68+
if (currentWaypointPosition == waypointPosition)
69+
{
70+
LaserBeam();
71+
}
72+
else
73+
{
74+
Finish();
75+
}
76+
}
77+
}
78+
private void Finish()
79+
{
80+
laserSource.DestroyTheLaserStructure();
81+
IsThereLaserOnTheMap = false;
82+
}
83+
84+
void GenerateTheLaserStructure()
85+
{
86+
laserSource.LaserCreator();
87+
IsThereLaserOnTheMap = true;
88+
}
89+
void LaserBeam()
90+
{
91+
var laserBeamHeight = new Vector3(waypointPosition.X, waypointPosition.Y, waypointPosition.Z + 2000f);
92+
93+
World.DrawLine(waypointPosition,
94+
laserBeamHeight,
95+
colorOfTheLaserBeam);
96+
}
97+
}
98+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{4A49673F-0E7F-4005-AD98-AD51362D0939}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>Waypoint_marked_with_laser</RootNamespace>
11+
<AssemblyName>Waypoint-marked-with-laser</AssemblyName>
12+
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
<Deterministic>true</Deterministic>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<DebugSymbols>true</DebugSymbols>
18+
<DebugType>full</DebugType>
19+
<Optimize>false</Optimize>
20+
<OutputPath>bin\Debug\</OutputPath>
21+
<DefineConstants>DEBUG;TRACE</DefineConstants>
22+
<ErrorReport>prompt</ErrorReport>
23+
<WarningLevel>4</WarningLevel>
24+
</PropertyGroup>
25+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26+
<DebugType>pdbonly</DebugType>
27+
<Optimize>true</Optimize>
28+
<OutputPath>bin\Release\</OutputPath>
29+
<DefineConstants>TRACE</DefineConstants>
30+
<ErrorReport>prompt</ErrorReport>
31+
<WarningLevel>4</WarningLevel>
32+
</PropertyGroup>
33+
<ItemGroup>
34+
<Reference Include="ScriptHookVDotNet3">
35+
<HintPath>..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Grand Theft Auto V\ScriptHookVDotNet3.dll</HintPath>
36+
</Reference>
37+
<Reference Include="System" />
38+
<Reference Include="System.Core" />
39+
<Reference Include="System.Drawing" />
40+
<Reference Include="System.Windows.Forms" />
41+
<Reference Include="System.Xml.Linq" />
42+
<Reference Include="System.Data.DataSetExtensions" />
43+
<Reference Include="Microsoft.CSharp" />
44+
<Reference Include="System.Data" />
45+
<Reference Include="System.Net.Http" />
46+
<Reference Include="System.Xml" />
47+
</ItemGroup>
48+
<ItemGroup>
49+
<Compile Include="creative-table\LaserSource.cs" />
50+
<Compile Include="Main.cs" />
51+
<Compile Include="Properties\AssemblyInfo.cs" />
52+
<Compile Include="setup-manager\Settings.cs" />
53+
<Compile Include="setup-manager\SettingColor.cs" />
54+
</ItemGroup>
55+
<ItemGroup />
56+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
57+
<PropertyGroup>
58+
<PostBuildEvent>xcopy "$(ProjectDir)\bin\Debug\Waypoint-marked-with-laser.dll" /y "C:\Program Files (x86)\Steam\steamapps\common\Grand Theft Auto V\scripts"</PostBuildEvent>
59+
</PropertyGroup>
60+
</Project>
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
using GTA;
2+
using GTA.Math;
3+
4+
namespace Waypoint_marked_with_laser.creative_table
5+
{
6+
class LaserSource
7+
{
8+
private readonly Prop[] laserStructures = new Prop[2];
9+
10+
private readonly string[] modelNameLaser =
11+
{
12+
"xs_prop_arena_barrel_01a_sf",
13+
"xs_prop_arena_bollard_side_01a_sf"
14+
};
15+
16+
17+
private Vector3 Position
18+
{ get; set; }
19+
20+
public LaserSource() { }
21+
22+
23+
internal void LaserCreator()
24+
{
25+
Position = World.WaypointPosition;
26+
27+
CreateTheLaserStructure();
28+
}
29+
internal void DestroyTheLaserStructure()
30+
{
31+
foreach (var laserStructure in laserStructures)
32+
{
33+
if (laserStructure != null)
34+
{
35+
laserStructure.Delete();
36+
}
37+
}
38+
}
39+
private void CreateTheLaserStructure()
40+
{
41+
var hasPhysics =
42+
true;
43+
44+
var IsToStayOnTheGround =
45+
false;
46+
47+
var laserHeight =
48+
new Vector3(Position.X, Position.Y, Position.Z + 2000f);
49+
50+
51+
laserStructures[0] = World.CreateProp(modelNameLaser[1], laserHeight, hasPhysics, IsToStayOnTheGround);
52+
laserStructures[1] = World.CreateProp(modelNameLaser[0], laserHeight, hasPhysics, IsToStayOnTheGround);
53+
54+
55+
BasicLaserStructureSettings();
56+
}
57+
private void BasicLaserStructureSettings()
58+
{
59+
var rotation = new Vector3(0.20512519f, 179.459076f, 101.254494f);
60+
var relativeRotation = new Vector3(0f, 2.49999976f, -0.399999976f);
61+
62+
laserStructures[1].Rotation = rotation;
63+
64+
laserStructures[0].AttachTo(entity: laserStructures[1],
65+
position: relativeRotation);
66+
}
67+
}
68+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using System.Drawing;
2+
3+
namespace Waypoint_marked_with_laser.setup_manager
4+
{
5+
struct SettingColor
6+
{
7+
internal static Color ColorOfTheLaserBeam { get; set; }
8+
}
9+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using GTA;
2+
3+
using System.Drawing;
4+
5+
6+
namespace Waypoint_marked_with_laser.setup_manager
7+
{
8+
class Settings
9+
{
10+
private ScriptSettings fileSetBlipColor;
11+
12+
public Settings(string directory)
13+
{
14+
fileSetBlipColor =
15+
ScriptSettings.Load($"{directory}/ColorForTheLaserBeam.ini");
16+
17+
SetTheColor();
18+
}
19+
20+
void SetTheColor()
21+
{
22+
var colorsFromArgb =
23+
PickTheColorForTheLaserBeam();
24+
25+
SettingColor.ColorOfTheLaserBeam = Color.FromArgb(colorsFromArgb[0],
26+
colorsFromArgb[1],
27+
colorsFromArgb[2],
28+
colorsFromArgb[3]);
29+
30+
}
31+
int[] PickTheColorForTheLaserBeam()
32+
{
33+
return new[]
34+
{
35+
fileSetBlipColor.GetValue<int>("Color From Argb", "Alpha:", 255),
36+
fileSetBlipColor.GetValue<int>("Color From Argb", "Red:", 255),
37+
fileSetBlipColor.GetValue<int>("Color From Argb", "Green:", 215),
38+
fileSetBlipColor.GetValue<int>("Color From Argb", "Blue:", 255)
39+
};
40+
}
41+
}
42+
}

0 commit comments

Comments
 (0)