Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update 2.0 #1

Merged
merged 2 commits into from
Jan 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto

###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp

###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary

###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary

###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain
34 changes: 23 additions & 11 deletions Client/Main.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,33 @@
using System.Threading.Tasks;
using System;
using System.Threading.Tasks;
using CitizenFX.Core;
using CitizenFX.Core.Native;
using CitizenFX.Core.UI;

namespace Client
{
public class Main : BaseScript
{
private Ped _p = Game.PlayerPed;
private bool _reticleAllowed = false;

public Main()
{
Log("Resource loaded.");

EventHandlers.Add("NoReticle:Client:SetPlayerReticleAceAllowed", new Action(SetPlayerReticleAceAllowed));

TriggerServerEvent("NoReticle:Server:GetPlayerReticleAceAllowed", Game.Player.Handle);

Tick += ProcessTask;
}

private void SetPlayerReticleAceAllowed()
{
Screen.ShowNotification("Allowing reticle.", true);
_reticleAllowed = true;
}

private async Task ProcessTask()
{
if (_p != null)
Expand All @@ -23,27 +37,25 @@ private async Task ProcessTask()

if (w != null)
{
// if current weapon group defines weapon as a sniper then..
if (w.Group != WeaponGroup.Sniper)
WeaponHash wHash = w.Hash;

if (wHash != WeaponHash.Unarmed && wHash != WeaponHash.StunGun &&
wHash != WeaponHash.SniperRifle && wHash != WeaponHash.HeavySniper &&
wHash != WeaponHash.HeavySniperMk2 &&
wHash != WeaponHash.MarksmanRifle &&
API.GetHashKey(wHash.ToString()) != -1783943904) // add MarksmanRifle MKII
{
// if ace perm "Reticle" is not allowed (cannot have reticle) then..
if (API.IsAceAllowed("Reticle") == false)
if (_reticleAllowed == false)
{
Log("Ace 'Reticle' not allowed.");

// hides reticle (white dot [HUD] when aiming in).
API.HideHudComponentThisFrame(14);
}
else
{
Log("Ace 'Reticle' allowed.");
}
}
}
}
else
{
Log("Player ped does not exist.. ?");
_p = Game.PlayerPed;
}
}
Expand Down
6 changes: 6 additions & 0 deletions NoReticle.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ VisualStudioVersion = 15.0.27428.2005
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Client", "Client\Client.csproj", "{F8C5642D-8030-46B7-B55F-C5FCE19080BE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Server", "Server\Server.csproj", "{A74E9727-19EF-46FE-B940-056978E2DA99}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -15,6 +17,10 @@ Global
{F8C5642D-8030-46B7-B55F-C5FCE19080BE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F8C5642D-8030-46B7-B55F-C5FCE19080BE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F8C5642D-8030-46B7-B55F-C5FCE19080BE}.Release|Any CPU.Build.0 = Release|Any CPU
{A74E9727-19EF-46FE-B940-056978E2DA99}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A74E9727-19EF-46FE-B940-056978E2DA99}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A74E9727-19EF-46FE-B940-056978E2DA99}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A74E9727-19EF-46FE-B940-056978E2DA99}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
23 changes: 23 additions & 0 deletions Server/Main.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System;
using CitizenFX.Core;
using CitizenFX.Core.Native;

namespace Server
{
public class Main : BaseScript
{
public Main()
{
EventHandlers.Add("NoReticle:Server:GetPlayerReticleAceAllowed", new Action<Player>(GetPlayerReticleAceAllowed));
}

private void GetPlayerReticleAceAllowed([FromSource] Player p)
{
// if ace permission 'Reticle' is allowed for the player then show the reticle..
if (API.IsPlayerAceAllowed(p.Handle, "Reticle") == true)
{
p.TriggerEvent("NoReticle:Client:SetPlayerReticleAceAllowed");
}
}
}
}
36 changes: 36 additions & 0 deletions Server/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Server")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Server")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("a74e9727-19ef-46fe-b940-056978e2da99")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
52 changes: 52 additions & 0 deletions Server/Server.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{A74E9727-19EF-46FE-B940-056978E2DA99}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Server</RootNamespace>
<AssemblyName>Server.net</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>embedded</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\build\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>embedded</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\build\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<Reference Include="CitizenFX.Core.Server">
<HintPath>..\dependencies\server\CitizenFX.Core.Server.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Main.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>