diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/.gitattributes @@ -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 diff --git a/Client/Main.cs b/Client/Main.cs index 9ae3503..964063c 100644 --- a/Client/Main.cs +++ b/Client/Main.cs @@ -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) @@ -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; } } diff --git a/NoReticle.sln b/NoReticle.sln index c95f97c..d3999f5 100644 --- a/NoReticle.sln +++ b/NoReticle.sln @@ -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 @@ -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 diff --git a/Server/Main.cs b/Server/Main.cs new file mode 100644 index 0000000..2e79a68 --- /dev/null +++ b/Server/Main.cs @@ -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(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"); + } + } + } +} diff --git a/Server/Properties/AssemblyInfo.cs b/Server/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..6cea91d --- /dev/null +++ b/Server/Properties/AssemblyInfo.cs @@ -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")] diff --git a/Server/Server.csproj b/Server/Server.csproj new file mode 100644 index 0000000..1955b9b --- /dev/null +++ b/Server/Server.csproj @@ -0,0 +1,52 @@ + + + + + Debug + AnyCPU + {A74E9727-19EF-46FE-B940-056978E2DA99} + Library + Properties + Server + Server.net + v4.5.2 + 512 + + + true + embedded + false + ..\..\build\ + DEBUG;TRACE + prompt + 4 + + + embedded + true + ..\..\build\ + TRACE + prompt + 4 + true + + + + ..\dependencies\server\CitizenFX.Core.Server.dll + False + + + + + + + + + + + + + + + + \ No newline at end of file