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 for latest fx updates; fixed reticle showing in first-person on sniper rifles when not aimed in; fixed ace permissions not working #12

Merged
merged 1 commit into from
Jan 17, 2022
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: 0 additions & 63 deletions .gitattributes

This file was deleted.

14 changes: 0 additions & 14 deletions Client/fxmanifest.lua

This file was deleted.

30 changes: 16 additions & 14 deletions Client/Main.cs → NoReticle.Client/ClientMain.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
using CitizenFX.Core;
using CitizenFX.Core.Native;
using System;
using static CitizenFX.Core.Native.API;
using System.Threading.Tasks;
using CitizenFX.Core.UI;

namespace Client
namespace NoReticle.Client
{
public class Main : BaseScript
public class ClientMain : BaseScript
{
private bool _reticleAllowed, _stunGunReticleAllowed;
private bool reticleAllowed, stunGunReticleAllowed;

public Main()
public ClientMain()
{
Log("Resource loaded.");
TriggerServerEvent("NoReticle:Server:GetAcePermissions", Game.Player.Handle);
Expand All @@ -19,44 +19,46 @@ public Main()
private void SetPlayerReticleAceAllowed()
{
Log("Allowing reticle.");
_reticleAllowed = true;
reticleAllowed = true;
}

[EventHandler("NoReticle:Client:SetStunGunReticleAllowed")]
private void SetStunGunReticleAllowed()
{
Log("Allowing stun gun reticle.");
_stunGunReticleAllowed = true;
stunGunReticleAllowed = true;
}

[Tick]
private async Task ProcessTask()
private Task OnTick()
{
// gets client's current weapon.
Weapon w = Game.PlayerPed?.Weapons?.Current;

if (w != null)
{
// disable reticle for musket and all weapons EXCEPT snipers, unarmed, stungun (if permissions allowed), and aircraft (w.Group == 0).
if (w.Hash == WeaponHash.Musket || !(w.Group == WeaponGroup.Sniper || w.Group == WeaponGroup.Unarmed || (_stunGunReticleAllowed && w.Group == WeaponGroup.Stungun) || w.Group == 0))
if (w.Hash == WeaponHash.Musket || !((w.Group == WeaponGroup.Sniper && IsFirstPersonAimCamActive()) || w.Group == WeaponGroup.Unarmed || (stunGunReticleAllowed && w.Group == WeaponGroup.Stungun) || w.Group == 0))
{
// if ace perm "Reticle" is not allowed (cannot have reticle) then..
if (!_reticleAllowed)
if (!reticleAllowed)
{
// hides reticle (white dot [HUD] when aiming in).
API.HideHudComponentThisFrame(14);
HideHudComponentThisFrame(14);
}
}
}

return Task.FromResult(0);
}

/// <summary>
/// Writes debug message to client's console.
/// Writes debug message to the client's console.
/// </summary>
/// <param name="msg">Message to display.</param>
private void Log(string msg)
{
Debug.Write($"[NoReticle]: {msg}\n");
}
}
}
}
26 changes: 16 additions & 10 deletions Server/Server.csproj → NoReticle.Client/NoReticle.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,41 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{A74E9727-19EF-46FE-B940-056978E2DA99}</ProjectGuid>
<ProjectGuid>{7BCB0CF3-3F9F-4A32-9852-39A4E2EA7529}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Server</RootNamespace>
<AssemblyName>Server.net</AssemblyName>
<RootNamespace>NoReticle.Client</RootNamespace>
<AssemblyName>NoReticle.Client.net</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>portable</DebugType>
<DebugType>embedded</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\build\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DefineConstants>
</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>portable</DebugType>
<DebugType>embedded</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\build\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<DefineConstants>
</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<PropertyGroup>
<AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects>
</PropertyGroup>
<ItemGroup>
<Reference Include="CitizenFX.Core.Server, Version=0.0.0.0, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\packages\CitizenFX.Core.Server.1.0.3212\lib\net45\CitizenFX.Core.Server.dll</HintPath>
<Reference Include="CitizenFX.Core.Client, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\CitizenFX.Core.Client.1.0.5230\lib\net45\CitizenFX.Core.Client.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
Expand All @@ -45,7 +51,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Main.cs" />
<Compile Include="ClientMain.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
// 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: AssemblyTitle("NoReticle.Client")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Server")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyProduct("NoReticle.Client")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -20,7 +20,7 @@
[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")]
[assembly: Guid("7bcb0cf3-3f9f-4a32-9852-39a4e2ea7529")]

// Version information for an assembly consists of the following four values:
//
Expand All @@ -32,5 +32,5 @@
// 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("2.2.0")]
[assembly: AssemblyFileVersion("2.2.0")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CitizenFX.Core.Client" version="1.0.3212" targetFramework="net452" />
<package id="CitizenFX.Core.Client" version="1.0.5230" targetFramework="net452" />
</packages>
21 changes: 12 additions & 9 deletions Client/Client.csproj → NoReticle.Server/NoReticle.Server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,38 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{F8C5642D-8030-46B7-B55F-C5FCE19080BE}</ProjectGuid>
<ProjectGuid>{980F4CA9-BCB5-4A47-8E65-94E14B0A32BF}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Client</RootNamespace>
<AssemblyName>Client.net</AssemblyName>
<RootNamespace>NoReticle.Server</RootNamespace>
<AssemblyName>NoReticle.Server.net</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>embedded</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\build\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DefineConstants>
</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>
<DefineConstants>
</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<Reference Include="CitizenFX.Core.Client, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\CitizenFX.Core.Client.1.0.3212\lib\net45\CitizenFX.Core.Client.dll</HintPath>
<Reference Include="CitizenFX.Core.Server, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\CitizenFX.Core.Server.1.0.5230\lib\net45\CitizenFX.Core.Server.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
Expand All @@ -45,14 +48,14 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Main.cs" />
<Compile Include="ServerMain.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<None Include="fxmanifest.lua">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
// 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("Client")]
[assembly: AssemblyTitle("NoReticle.Server")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Client")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyProduct("NoReticle.Server")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -20,7 +20,7 @@
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("f8c5642d-8030-46b7-b55f-c5fce19080be")]
[assembly: Guid("980f4ca9-bcb5-4a47-8e65-94e14b0a32bf")]

// Version information for an assembly consists of the following four values:
//
Expand All @@ -32,5 +32,5 @@
// 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("2.2.0")]
[assembly: AssemblyFileVersion("2.2.0")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
12 changes: 5 additions & 7 deletions Server/Main.cs → NoReticle.Server/ServerMain.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
using CitizenFX.Core;
using CitizenFX.Core.Native;
using static CitizenFX.Core.Native.API;

namespace Server
namespace NoReticle.Server
{
public class Main : BaseScript
public class ServerMain : BaseScript
{
public Main() { }

[EventHandler("NoReticle:Server:GetAcePermissions")]
private void GetAcePermissions([FromSource] Player p)
{
// if ace permission 'Reticle' is allowed for the player then show the reticle..
if (API.IsPlayerAceAllowed(p.Handle, "Reticle"))
if (IsPlayerAceAllowed(p.Handle, "Reticle"))
{
p.TriggerEvent("NoReticle:Client:SetPlayerReticleAceAllowed");
}
// if ace permission 'ReticleStunGun' is allowed for the player then show the reticle..
if (API.IsPlayerAceAllowed(p.Handle, "ReticleStunGun"))
if (IsPlayerAceAllowed(p.Handle, "ReticleStunGun"))
{
p.TriggerEvent("NoReticle:Client:SetStunGunReticleAllowed");
}
Expand Down
8 changes: 8 additions & 0 deletions NoReticle.Server/fxmanifest.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
fx_version 'cerulean'
game 'gta5'

author 'ToastinYou'
version '2.3.0'

client_script 'NoReticle.Client.net.dll'
server_script 'NoReticle.Server.net.dll'
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CitizenFX.Core.Server" version="1.0.3212" targetFramework="net452" />
<package id="CitizenFX.Core.Server" version="1.0.5230" targetFramework="net452" />
</packages>
Loading