├── resource ├── Client.net.dll ├── Server.net.dll ├── fxmanifest.lua └── stream │ └── prop_afsign_vbike.ydr ├── src ├── Server.cs └── Main.cs ├── README.md ├── .gitignore └── LICENCE.md /resource/Client.net.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LondonStudios/LiveFaceRecognition/HEAD/resource/Client.net.dll -------------------------------------------------------------------------------- /resource/Server.net.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LondonStudios/LiveFaceRecognition/HEAD/resource/Server.net.dll -------------------------------------------------------------------------------- /resource/fxmanifest.lua: -------------------------------------------------------------------------------- 1 | fx_version 'bodacious' 2 | game 'gta5' 3 | 4 | client_script 'Client.net.dll' 5 | server_script 'Server.net.dll' -------------------------------------------------------------------------------- /resource/stream/prop_afsign_vbike.ydr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LondonStudios/LiveFaceRecognition/HEAD/resource/stream/prop_afsign_vbike.ydr -------------------------------------------------------------------------------- /src/Server.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using CitizenFX.Core; 7 | using static CitizenFX.Core.Native.API; 8 | 9 | namespace Server 10 | { 11 | public class Server : BaseScript 12 | { 13 | public Server() 14 | { 15 | EventHandlers["Server:SyncCamera"] += new Action((location, id, remove) => 16 | { 17 | TriggerClientEvent("Client:SyncCamera", location, id, remove); 18 | }); 19 | 20 | EventHandlers["Server:CameraNotification"] += new Action((targetCoords, netId, name, pncNotes) => 21 | { 22 | TriggerClientEvent("Client:CameraNotification", targetCoords, netId, name, pncNotes); 23 | }); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![London Studios](https://i.ibb.co/1mwSS1q/Untitled-design.png) 2 | 3 | # London Studios - Update 4 | Since forming London Studios in April 2020 we've created a number of **high quality** and **premium** resources for the FiveM project, focusing on the emergency services and aiming to bring your server to the next level. 5 | 6 | Although we made a number of free resources such as this one in the first year, we've now switched to creating paid content, keeping them constantly updated and working along with providing the best possible support to our customers. 7 | 8 | Our **most popular** resources now include *Smart Fires, Police Grappler* and *Smart Hose*. 9 | 10 | With **thousands** of **happy customers** we are confident you'll love our resources and our active support team are on hand to help if you have any questions! 11 | 12 | # Our store: https://store.londonstudios.net/github 13 | # Our discord: https://discord.gg/nC2krpN 14 | 15 | Therefore, this resource is now likely *out of date* and is *no longer supported by us*. The full source code is available should you wish to make any changes. All of our paid resources however are constantly updated and we invite you to take a look! 16 | 17 | ![LiveFaceRecognition](https://i.imgur.com/2ICPsAH.png) 18 | 19 | # Live Face Recogition - London Studios 20 | **Live Face Recognition** is a **FiveM** resource allowing you to setup a live face recognition zone around a vehicle, often a van. The plugin creates a camera on top of the vehicle and places two signs around the vehicle, warning people of the use of face recognition. 21 | 22 | Join our Discord [here](https://discord.gg/mkFVCpE). 23 | 24 | Buy Me A Coffee 25 | 26 | If a person adds themselves to the system, the camera will take a photo to them and show officers there has been an activation - with the offence they are wanted for. 27 | 28 | This is used by the Met Police (UK) and other forces around the world. After researching, their systems only ping for people who are wanted for a serious offence, so if you use this - try to keep it to that. 29 | 30 | **Please note:** The camera will not work with all vehicles. 31 | 32 | This plugin is made by **LondonStudios**, we have created a variety of releases including TaserFramework, SearchHandler, ActivateAlarm, SmartTester, SmartSounds, CustodyAlarm, SmartObservations and more! 33 | 34 | ## Usage 35 | **/lfr [setup / remove]** - Setup or remove a live face recognition camera. You may only have one at once and you must be inside a vehicle to set one up. Make sure the area in front of the vehicle and behind are clear, as a sign will spawn there. 36 | 37 | **/facedetect [FirstName] [LastName] [Notes/Wanted for.......]** - Add yourself to the face recognition system as a civilian. You can change your name just by doing the command again, great for changing characters. If you walk past one of these cameras after performing the command, the camera will take a photo of you, showing officers your name and the offence you are wanted for. 38 | 39 | ## Installation 40 | 1. Create a new **resource folder** on your server. 41 | 2. Add the contents of **"resource"** inside it. This includes: 42 | "Client.net.dll", "Server.net.dll", "fxmanifest.lua", "stream" 43 | 3. In **server.cfg**, "ensure" Live Face Recognition, to make it load with your server startup. 44 | 45 | **Changing textures:** 46 | You have the ability to change the textures of the sign 47 | File name: prop_afsign_vbike.ydr. 48 | The textures are embedded, use OpenIV to change them. 49 | 50 | ## Source Code 51 | Please find the source code in the **"src"** folder. Please ensure you follow the licence in **"LICENCE.md"**. 52 | 53 | ## Feedback 54 | We appreciate feedback, bugs and suggestions related to Live Face Recognition and future plugins. We hope you enjoy using the resource and look forward to hearing from people! 55 | 56 | ## Errors & Suggestions 57 | If you encounter any bugs or errors with the plugin, we encourage you to report them and we will actively fix them. We are also looking for suggestions on how we can improve this, ensuring all users get the best possible experience. 58 | 59 | ## Screenshots 60 | We've really enjoyed making this plugin. Take a look at some screenshots of the plugin in action. 61 | ![LFR](https://i.imgur.com/z3Cf1sY.png) 62 | 63 | ![LFR](https://i.imgur.com/1sey05R.png) 64 | 65 | ![LFR](https://i.imgur.com/Oqeam6B.png) 66 | 67 | ![LFR![LFR](https://i.imgur.com/vUt2wcu.png) 68 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Aa][Rr][Mm]/ 27 | [Aa][Rr][Mm]64/ 28 | bld/ 29 | [Bb]in/ 30 | [Oo]bj/ 31 | [Ll]og/ 32 | [Ll]ogs/ 33 | 34 | # Visual Studio 2015/2017 cache/options directory 35 | .vs/ 36 | # Uncomment if you have tasks that create the project's static files in wwwroot 37 | #wwwroot/ 38 | 39 | # Visual Studio 2017 auto generated files 40 | Generated\ Files/ 41 | 42 | # MSTest test Results 43 | [Tt]est[Rr]esult*/ 44 | [Bb]uild[Ll]og.* 45 | 46 | # NUnit 47 | *.VisualState.xml 48 | TestResult.xml 49 | nunit-*.xml 50 | 51 | # Build Results of an ATL Project 52 | [Dd]ebugPS/ 53 | [Rr]eleasePS/ 54 | dlldata.c 55 | 56 | # Benchmark Results 57 | BenchmarkDotNet.Artifacts/ 58 | 59 | # .NET Core 60 | project.lock.json 61 | project.fragment.lock.json 62 | artifacts/ 63 | 64 | # StyleCop 65 | StyleCopReport.xml 66 | 67 | # Files built by Visual Studio 68 | *_i.c 69 | *_p.c 70 | *_h.h 71 | *.ilk 72 | *.meta 73 | *.obj 74 | *.iobj 75 | *.pch 76 | *.pdb 77 | *.ipdb 78 | *.pgc 79 | *.pgd 80 | *.rsp 81 | *.sbr 82 | *.tlb 83 | *.tli 84 | *.tlh 85 | *.tmp 86 | *.tmp_proj 87 | *_wpftmp.csproj 88 | *.log 89 | *.vspscc 90 | *.vssscc 91 | .builds 92 | *.pidb 93 | *.svclog 94 | *.scc 95 | 96 | # Chutzpah Test files 97 | _Chutzpah* 98 | 99 | # Visual C++ cache files 100 | ipch/ 101 | *.aps 102 | *.ncb 103 | *.opendb 104 | *.opensdf 105 | *.sdf 106 | *.cachefile 107 | *.VC.db 108 | *.VC.VC.opendb 109 | 110 | # Visual Studio profiler 111 | *.psess 112 | *.vsp 113 | *.vspx 114 | *.sap 115 | 116 | # Visual Studio Trace Files 117 | *.e2e 118 | 119 | # TFS 2012 Local Workspace 120 | $tf/ 121 | 122 | # Guidance Automation Toolkit 123 | *.gpState 124 | 125 | # ReSharper is a .NET coding add-in 126 | _ReSharper*/ 127 | *.[Rr]e[Ss]harper 128 | *.DotSettings.user 129 | 130 | # TeamCity is a build add-in 131 | _TeamCity* 132 | 133 | # DotCover is a Code Coverage Tool 134 | *.dotCover 135 | 136 | # AxoCover is a Code Coverage Tool 137 | .axoCover/* 138 | !.axoCover/settings.json 139 | 140 | # Visual Studio code coverage results 141 | *.coverage 142 | *.coveragexml 143 | 144 | # NCrunch 145 | _NCrunch_* 146 | .*crunch*.local.xml 147 | nCrunchTemp_* 148 | 149 | # MightyMoose 150 | *.mm.* 151 | AutoTest.Net/ 152 | 153 | # Web workbench (sass) 154 | .sass-cache/ 155 | 156 | # Installshield output folder 157 | [Ee]xpress/ 158 | 159 | # DocProject is a documentation generator add-in 160 | DocProject/buildhelp/ 161 | DocProject/Help/*.HxT 162 | DocProject/Help/*.HxC 163 | DocProject/Help/*.hhc 164 | DocProject/Help/*.hhk 165 | DocProject/Help/*.hhp 166 | DocProject/Help/Html2 167 | DocProject/Help/html 168 | 169 | # Click-Once directory 170 | publish/ 171 | 172 | # Publish Web Output 173 | *.[Pp]ublish.xml 174 | *.azurePubxml 175 | # Note: Comment the next line if you want to checkin your web deploy settings, 176 | # but database connection strings (with potential passwords) will be unencrypted 177 | *.pubxml 178 | *.publishproj 179 | 180 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 181 | # checkin your Azure Web App publish settings, but sensitive information contained 182 | # in these scripts will be unencrypted 183 | PublishScripts/ 184 | 185 | # NuGet Packages 186 | *.nupkg 187 | # NuGet Symbol Packages 188 | *.snupkg 189 | # The packages folder can be ignored because of Package Restore 190 | **/[Pp]ackages/* 191 | # except build/, which is used as an MSBuild target. 192 | !**/[Pp]ackages/build/ 193 | # Uncomment if necessary however generally it will be regenerated when needed 194 | #!**/[Pp]ackages/repositories.config 195 | # NuGet v3's project.json files produces more ignorable files 196 | *.nuget.props 197 | *.nuget.targets 198 | 199 | # Microsoft Azure Build Output 200 | csx/ 201 | *.build.csdef 202 | 203 | # Microsoft Azure Emulator 204 | ecf/ 205 | rcf/ 206 | 207 | # Windows Store app package directories and files 208 | AppPackages/ 209 | BundleArtifacts/ 210 | Package.StoreAssociation.xml 211 | _pkginfo.txt 212 | *.appx 213 | *.appxbundle 214 | *.appxupload 215 | 216 | # Visual Studio cache files 217 | # files ending in .cache can be ignored 218 | *.[Cc]ache 219 | # but keep track of directories ending in .cache 220 | !?*.[Cc]ache/ 221 | 222 | # Others 223 | ClientBin/ 224 | ~$* 225 | *~ 226 | *.dbmdl 227 | *.dbproj.schemaview 228 | *.jfm 229 | *.pfx 230 | *.publishsettings 231 | orleans.codegen.cs 232 | 233 | # Including strong name files can present a security risk 234 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 235 | #*.snk 236 | 237 | # Since there are multiple workflows, uncomment next line to ignore bower_components 238 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 239 | #bower_components/ 240 | 241 | # RIA/Silverlight projects 242 | Generated_Code/ 243 | 244 | # Backup & report files from converting an old project file 245 | # to a newer Visual Studio version. Backup files are not needed, 246 | # because we have git ;-) 247 | _UpgradeReport_Files/ 248 | Backup*/ 249 | UpgradeLog*.XML 250 | UpgradeLog*.htm 251 | ServiceFabricBackup/ 252 | *.rptproj.bak 253 | 254 | # SQL Server files 255 | *.mdf 256 | *.ldf 257 | *.ndf 258 | 259 | # Business Intelligence projects 260 | *.rdl.data 261 | *.bim.layout 262 | *.bim_*.settings 263 | *.rptproj.rsuser 264 | *- [Bb]ackup.rdl 265 | *- [Bb]ackup ([0-9]).rdl 266 | *- [Bb]ackup ([0-9][0-9]).rdl 267 | 268 | # Microsoft Fakes 269 | FakesAssemblies/ 270 | 271 | # GhostDoc plugin setting file 272 | *.GhostDoc.xml 273 | 274 | # Node.js Tools for Visual Studio 275 | .ntvs_analysis.dat 276 | node_modules/ 277 | 278 | # Visual Studio 6 build log 279 | *.plg 280 | 281 | # Visual Studio 6 workspace options file 282 | *.opt 283 | 284 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 285 | *.vbw 286 | 287 | # Visual Studio LightSwitch build output 288 | **/*.HTMLClient/GeneratedArtifacts 289 | **/*.DesktopClient/GeneratedArtifacts 290 | **/*.DesktopClient/ModelManifest.xml 291 | **/*.Server/GeneratedArtifacts 292 | **/*.Server/ModelManifest.xml 293 | _Pvt_Extensions 294 | 295 | # Paket dependency manager 296 | .paket/paket.exe 297 | paket-files/ 298 | 299 | # FAKE - F# Make 300 | .fake/ 301 | 302 | # CodeRush personal settings 303 | .cr/personal 304 | 305 | # Python Tools for Visual Studio (PTVS) 306 | __pycache__/ 307 | *.pyc 308 | 309 | # Cake - Uncomment if you are using it 310 | # tools/** 311 | # !tools/packages.config 312 | 313 | # Tabs Studio 314 | *.tss 315 | 316 | # Telerik's JustMock configuration file 317 | *.jmconfig 318 | 319 | # BizTalk build output 320 | *.btp.cs 321 | *.btm.cs 322 | *.odx.cs 323 | *.xsd.cs 324 | 325 | # OpenCover UI analysis results 326 | OpenCover/ 327 | 328 | # Azure Stream Analytics local run output 329 | ASALocalRun/ 330 | 331 | # MSBuild Binary and Structured Log 332 | *.binlog 333 | 334 | # NVidia Nsight GPU debugger configuration file 335 | *.nvuser 336 | 337 | # MFractors (Xamarin productivity tool) working folder 338 | .mfractor/ 339 | 340 | # Local History for Visual Studio 341 | .localhistory/ 342 | 343 | # BeatPulse healthcheck temp database 344 | healthchecksdb 345 | 346 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 347 | MigrationBackup/ 348 | 349 | # Ionide (cross platform F# VS Code tools) working folder 350 | .ionide/ 351 | -------------------------------------------------------------------------------- /LICENCE.md: -------------------------------------------------------------------------------- 1 | 2 | ## **Attribution - Non-Commercial 2.0 England and Wales** 3 | _Licence_ 4 | 5 | THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENCE ("CCPL" OR "LICENCE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORISED UNDER THIS LICENCE OR COPYRIGHT LAW IS PROHIBITED. BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO BE BOUND BY THE TERMS OF THIS LICENCE. THE LICENCOR GRANTS YOU THE RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS. 6 | 7 | This Creative Commons England and Wales Public Licence enables You (all capitalised terms defined below) to view, edit, modify, translate and distribute Works worldwide, provided that You credit the Original Author. 8 | 9 | **'The Licensor'** [one or more legally recognised persons or entities offering the Work under the terms and conditions of this Licence] 10 | 11 | and 12 | 13 | **'You'** 14 | 15 | agree as follows: 16 | 17 | **1. Definitions** 18 | 19 | 1. **"Attribution"** means acknowledging all the parties who have contributed to and have rights in the Work, Derivative Work or Collective Work under this Licence. 20 | 2. **"Collective Work"** means the Work in its entirety in unmodified form along with a number of other separate and independent works, assembled into a collective whole. 21 | 3. **"Derivative Work"** means any work created by the editing, modification, adaptation or translation of the Work in any media (however a work that constitutes a Collective Work will not be considered a Derivative Work for the purpose of this Licence). For the avoidance of doubt, where the Work is a musical composition or sound recording, the synchronization of the Work in timed-relation with a moving image ("synching") will be considered a Derivative Work for the purpose of this Licence. 22 | 4. **"Licence"** means this Creative Commons England and Wales Public Licence agreement. 23 | 5. **"Non-Commercial"** means "not primarily intended for or directed towards commercial advantage or private monetary compensation". The exchange of the Work for other copyrighted works by means of digital file-sharing or otherwise shall not be considered to be intended for or directed towards commercial advantage or private monetary compensation, provided there is no payment of any monetary compensation in connection with the exchange of copyrighted works. 24 | 6. **"Original Author"** means the individual (or entity) who created the Work. 25 | 7. **"Work"** means the work protected by copyright which is offered under the terms of this Licence. 26 | 8. For the purpose of this Licence, when not inconsistent with the context, words in the singular number include the plural number. 27 | 28 | **2. Licence Terms** 29 | 30 | 2.1 The Licensor hereby grants to You a worldwide, royalty-free, non-exclusive, Licence for Non-Commercial use and for the duration of copyright in the Work. 31 | 32 | **You may:** 33 | 34 | - copy the Work; 35 | - create one or more Derivative Works; 36 | - incorporate the Work into one or more Collective Works; 37 | - copy Derivative Works or the Work as incorporated in any Collective Work; and 38 | - publish, distribute, archive, perform or otherwise disseminate the Work, Derivative Works or the Work as incorporated in any Collective Work, to the public in any material form in any media whether now known or hereafter created. 39 | 40 | **HOWEVER,** 41 | 42 | **You must not:** 43 | 44 | - impose any terms on the use to be made of the Work, the Derivative Work or the Work as incorporated in a Collective Work that alter or restrict the terms of this Licence or any rights granted under it or has the effect or intent of restricting the ability to exercise those rights; 45 | - impose any digital rights management technology on the Work, the Derivative Work or the Work as incorporated in a Collective Work that alters or restricts the terms of this Licence or any rights granted under it or has the effect or intent of restricting the ability to exercise those rights; 46 | - sublicense the Work; 47 | - subject the Work to any derogatory treatment as defined in the Copyright, Designs and Patents Act 1988. 48 | 49 | **FINALLY,** 50 | 51 | **You must:** 52 | 53 | - make reference to this Licence (by Uniform Resource Identifier (URI), spoken word or as appropriate to the media used) on all copies of the Work and Derivative Works and Collective Works published, distributed, performed or otherwise disseminated or made available to the public by You; 54 | - recognise the Licensor's / Original Author's right of attribution in any Work, Derivative Work and Collective Work that You publish, distribute, perform or otherwise disseminate to the public and ensure that You credit the Licensor / Original Author as appropriate to the media used; and 55 | - to the extent reasonably practicable, keep intact all notices that refer to this Licence, in particular the URI, if any, that the Licensor specifies to be associated with the Work, unless such URI does not refer to the copyright notice or licensing information for the Work. 56 | 57 | **Additional Provisions for third parties making use of the Work** 58 | 59 | 2.2. Further licence from the Licensor 60 | 61 | Each time You publish, distribute, perform or otherwise disseminate 62 | 63 | - the Work; or 64 | - any Derivative Work; or 65 | - the Work as incorporated in a Collective Work 66 | 67 | the Licensor agrees to offer to the relevant third party making use of the Work (in any of the alternatives set out above) a licence to use the Work on the same terms and conditions as granted to You hereunder. 68 | 69 | 2.3. This Licence does not affect any rights that the User may have under any applicable law, including fair use, fair dealing or any other legally recognised limitation or exception to copyright infringement. 70 | 71 | 2.4. All rights not expressly granted by the Licensor are hereby reserved, including but not limited to, the exclusive right to collect, whether individually or via a licensing body, such as a collecting society, royalties for any use of the Work. 72 | 73 | **3. Warranties and Disclaimer** 74 | 75 | Except as required by law, the Work or any Derivative Work is licensed by the Licensor on an "as is" and "as available" basis and without any warranty of any kind, either express or implied. 76 | 77 | **4. Limit of Liability** 78 | 79 | Subject to any liability which may not be excluded or limited by law the Licensor shall not be liable and hereby expressly excludes all liability for loss or damage howsoever and whenever caused to You. 80 | 81 | **5. Termination** 82 | 83 | The rights granted to You under this Licence shall terminate automatically upon any breach by You of the terms of this Licence. Individuals or entities who have received Derivative Works or Collective Works from You under this Licence, however, will not have their Licences terminated provided such individuals or entities remain in full compliance with those Licences. 84 | 85 | **6. General** 86 | 87 | 6.1. The validity or enforceability of the remaining terms of this agreement is not affected by the holding of any provision of it to be invalid or unenforceable. 88 | 89 | 6.2. This Licence constitutes the entire Licence Agreement between the parties with respect to the Work licensed here. There are no understandings, agreements or representations with respect to the Work not specified here. The Licensor shall not be bound by any additional provisions that may appear in any communication in any form. 90 | 91 | 6.3. A person who is not a party to this Licence shall have no rights under the Contracts (Rights of Third Parties) Act 1999 to enforce any of its terms. 92 | 93 | 6.4. This Licence shall be governed by the law of England and Wales and the parties irrevocably submit to the exclusive jurisdiction of the Courts of England and Wales. 94 | 95 | **7. On the role of Creative Commons** 96 | 97 | 7.1. Neither the Licensor nor the User may use the Creative Commons logo except to indicate that the Work is licensed under a Creative Commons Licence. Any permitted use has to be in compliance with the Creative Commons trade mark usage guidelines at the time of use of the Creative Commons trade mark. These guidelines may be found on the Creative Commons website or be otherwise available upon request from time to time. 98 | 99 | 7.2. Creative Commons Corporation does not profit financially from its role in providing this Licence and will not investigate the claims of any Licensor or user of the Licence. 100 | 101 | 7.3. One of the conditions that Creative Commons Corporation requires of the Licensor and You is an acknowledgement of its limited role and agreement by all who use the Licence that the Corporation is not responsible to anyone for the statements and actions of You or the Licensor or anyone else attempting to use or using this Licence. 102 | 103 | 7.4. Creative Commons Corporation is not a party to this Licence, and makes no warranty whatsoever in connection to the Work or in connection to the Licence, and in all events is not liable for any loss or damage resulting from the Licensor's or Your reliance on this Licence or on its enforceability. 104 | 105 | 7.5. USE OF THIS LICENCE MEANS THAT YOU AND THE LICENSOR EACH ACCEPTS THESE CONDITIONS IN SECTION 7.1, 7.2, 7.3, 7.4 AND EACH ACKNOWLEDGES CREATIVE COMMONS CORPORATION'S VERY LIMITED ROLE AS A FACILITATOR OF THE LICENCE FROM THE LICENSOR TO YOU. -------------------------------------------------------------------------------- /src/Main.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using CitizenFX.Core; 7 | using static CitizenFX.Core.Native.API; 8 | 9 | namespace FacialRecognition 10 | { 11 | public class Main : BaseScript 12 | { 13 | public string firstName; 14 | public string lastName; 15 | public string pncNotes; 16 | public bool detecting; 17 | 18 | public int camera = 0; 19 | public int sign = 0; 20 | public int sign2 = 0; 21 | public int cameraNetId; 22 | public int blip; 23 | 24 | public Dictionary cameraDatabase = new Dictionary { }; 25 | 26 | public Main() 27 | { 28 | Request(GetHashKey("prop_cctv_cam_04a")); 29 | Request(GetHashKey("prop_afsign_vbike")); 30 | 31 | TriggerEvent("chat:addSuggestion", "/lfr", "Setup or remove live facial recognition", new[] 32 | { 33 | new { name="Action", help="setup/remove" }, 34 | }); 35 | 36 | TriggerEvent("chat:addSuggestion", "/facedetect", "Add yourself to the facial recognition system", new[] 37 | { 38 | new { name="First Name", help="eg, John" }, 39 | new { name="Last Name", help="eg, Smith" }, 40 | new { name="PNC Notes", help="eg, Wanted - GBH" }, 41 | }); 42 | 43 | RegisterCommand("lfr", new Action, string>((source, args, raw) => 44 | { 45 | try 46 | { 47 | var arg = Convert.ToString(args[0]); 48 | if (arg.ToLower() == "setup") 49 | { 50 | SetupCamera(); 51 | } 52 | else if (arg.ToLower() == "remove") 53 | { 54 | RemoveCamera(); 55 | } 56 | } 57 | catch 58 | { 59 | ProcessError("Usage /fn [setup/remove]"); 60 | } 61 | }), false); 62 | 63 | RegisterCommand("facedetect", new Action, string>((source, args, raw) => 64 | { 65 | try 66 | { 67 | firstName = Convert.ToString(args[0]); 68 | lastName = Convert.ToString(args[1]); 69 | var argshandler = args.ConvertAll(x => Convert.ToString(x)); 70 | argshandler.Remove(firstName); 71 | argshandler.Remove(lastName); 72 | pncNotes = string.Join(" ", argshandler); 73 | detecting = true; 74 | 75 | CameraDetection(); 76 | 77 | ShowNotification("You have now been added to the ~b~facial recognition system."); 78 | } 79 | catch 80 | { 81 | ProcessError("Usage /facedetect [First Name] [Last Name] [PNC Notes]"); 82 | } 83 | }), false); 84 | 85 | EventHandlers["Client:SyncCamera"] += new Action((location, id, remove) => 86 | { 87 | if (!remove) 88 | { 89 | cameraDatabase.Add(location, id); 90 | } 91 | else 92 | { 93 | if (cameraDatabase.ContainsKey(location)) 94 | { 95 | cameraDatabase.Remove(location); 96 | } 97 | } 98 | }); 99 | 100 | EventHandlers["Client:CameraNotification"] += new Action((targetCoords, netId, name, pncNotes) => 101 | { 102 | Vector3 playerCoords = GetEntityCoords(PlayerPedId(), true); 103 | var distance = Vdist(playerCoords.X, playerCoords.Y, playerCoords.Z, targetCoords.X, targetCoords.Y, targetCoords.Z); 104 | if (distance < 26.0f) 105 | { 106 | PlaySoundFrontend(-1, "TIMER_STOP", "HUD_MINI_GAME_SOUNDSET", true); 107 | var ped = NetworkGetEntityFromNetworkId(netId); 108 | ProcessHeadshot(ped, name, pncNotes); 109 | } 110 | }); 111 | } 112 | 113 | private async void ProcessHeadshot(int ped, string name, string pnc) 114 | { 115 | var handle = RegisterPedheadshot(ped); 116 | while (!IsPedheadshotReady(handle) || (!IsPedheadshotValid(handle))) 117 | { 118 | await Delay(0); 119 | } 120 | await Delay(300); 121 | var txd = GetPedheadshotTxdString(handle); 122 | 123 | BeginTextCommandThefeedPost("STRING"); 124 | AddTextComponentSubstringPlayerName($"Name: {name}\nPNC Notes: {pnc}"); 125 | var title = "Facial Recognition"; 126 | var subtitle = "New Detection:"; 127 | var iconType = 0; 128 | EndTextCommandThefeedPostMessagetext(txd, txd, false, iconType, title, subtitle); 129 | EndTextCommandThefeedPostTicker(false, true); 130 | } 131 | 132 | private void ProcessError(string message = "An error has occured.") 133 | { 134 | PlaySoundFrontend(-1, "Place_Prop_Fail", "DLC_Dmod_Prop_Editor_Sounds", false); 135 | TriggerEvent("chat:addMessage", new 136 | { 137 | color = new[] { 255, 0, 0 }, 138 | args = new[] { "[Facial Recognition]", $"{message}" } 139 | }); 140 | } 141 | 142 | private void SetupCamera() 143 | { 144 | if (IsEligible()) 145 | { 146 | SpawnModel(); 147 | ShowNotification("You have setup a ~b~facial recognition ~w~camera at this location."); 148 | } 149 | else 150 | { 151 | if (!IsPedInAnyVehicle(PlayerPedId(), true)) 152 | { 153 | ShowNotification("You must be inside a vehicle to setup a camera."); 154 | } 155 | else 156 | { 157 | ShowNotification("You are not able to setup a camera."); 158 | } 159 | } 160 | } 161 | 162 | [Command("spawnsign")] 163 | private void SpawnSign() 164 | { 165 | 166 | } 167 | 168 | private async void CameraDetection() 169 | { 170 | while (detecting) 171 | { 172 | if (cameraDatabase.Keys.Count < 1) 173 | { 174 | await Delay(20000); 175 | if (cameraDatabase.Keys.Count < 1) 176 | { 177 | detecting = false; 178 | ShowNotification("No ~b~facial recognition ~w~cameras setup, use ~b~/facedetect [First Name] [Last Name] [PNC Notes] ~w~again when ready."); 179 | } 180 | } 181 | var coords = GetEntityCoords(PlayerPedId(), true); 182 | 183 | foreach (KeyValuePair kvp in cameraDatabase) 184 | { 185 | if (coords.DistanceToSquared(kvp.Key) < 20.0f) 186 | { 187 | TriggerServerEvent("Server:CameraNotification", GetEntityCoords(PlayerPedId(), true), Game.Player.Character.NetworkId, firstName + " " + lastName, pncNotes); 188 | ShowNotification("You have ~g~activated ~w~a ~b~facial recognition ~w~camera"); 189 | await Delay(10000); 190 | break; 191 | } 192 | } 193 | await Delay(350); 194 | } 195 | } 196 | 197 | private void SetupSign(Vector3 coords, Vector3 coords2, float heading = 0f) 198 | { 199 | sign = CreateObject(GetHashKey("prop_afsign_vbike"), coords.X, coords.Y, coords.Z, true, true, true); 200 | PlaceObjectOnGroundProperly(sign); 201 | SetEntityHeading(sign, heading + -110f); 202 | var networkId = ObjToNet(sign); 203 | SetNetworkIdExistsOnAllMachines(networkId, true); 204 | SetNetworkIdCanMigrate(networkId, false); 205 | NetworkSetNetworkIdDynamic(networkId, true); 206 | 207 | sign2 = CreateObject(GetHashKey("prop_afsign_vbike"), coords2.X, coords2.Y, coords2.Z, true, true, true); 208 | PlaceObjectOnGroundProperly(sign2); 209 | SetEntityHeading(sign2, heading + -110f); 210 | var networkId2 = ObjToNet(sign2); 211 | SetNetworkIdExistsOnAllMachines(networkId2, true); 212 | SetNetworkIdCanMigrate(networkId2, false); 213 | NetworkSetNetworkIdDynamic(networkId2, true); 214 | 215 | FreezeEntityPosition(sign, true); 216 | FreezeEntityPosition(sign2, true); 217 | } 218 | 219 | private async void SpawnModel() 220 | { 221 | var vehicle = GetVehiclePedIsIn(PlayerPedId(), false); 222 | var coords = GetEntityCoords(PlayerPedId(), true); 223 | camera = CreateObject(GetHashKey("prop_cctv_cam_04a"), coords.X, coords.Y, coords.Z, true, true, true); 224 | FreezeEntityPosition(camera, true); 225 | var networkId = ObjToNet(camera); 226 | cameraNetId = networkId; 227 | SetNetworkIdExistsOnAllMachines(networkId, true); 228 | SetNetworkIdCanMigrate(networkId, false); 229 | NetworkSetNetworkIdDynamic(networkId, true); 230 | AttachEntityToEntity(camera, vehicle, GetEntityBoneIndexByName(vehicle, "windscreen"), 0f, -1f, 0.3f, 0f, 0f, 90f, false, false, false, false, 0, true); 231 | var offset = GetOffsetFromEntityInWorldCoords(vehicle, 0f, 5f, 0f); 232 | var offset2 = GetOffsetFromEntityInWorldCoords(vehicle, 0f, -5f, 0f); 233 | SetupSign(offset, offset2, GetEntityHeading(vehicle)); 234 | 235 | TriggerServerEvent("Server:SyncCamera", GetEntityCoords(camera, true), networkId, false); 236 | 237 | blip = AddBlipForEntity(camera); 238 | SetBlipAsFriendly(blip, true); 239 | SetBlipColour(blip, 38); 240 | SetBlipDisplay(blip, 2); 241 | AddTextEntry("camera", "Facial Recognition Camera"); 242 | BeginTextCommandSetBlipName("camera"); 243 | EndTextCommandSetBlipName(blip); 244 | await Delay(100); 245 | } 246 | 247 | private void ShowNotification(string text) 248 | { 249 | SetNotificationTextEntry("STRING"); 250 | AddTextComponentString(text); 251 | EndTextCommandThefeedPostTicker(false, false); 252 | } 253 | 254 | private void RemoveCamera() 255 | { 256 | if (!(camera == 0)) 257 | { 258 | var coords = GetEntityCoords(camera, true); 259 | var netid = cameraNetId; 260 | DeleteEntity(ref camera); 261 | DeleteEntity(ref sign); 262 | DeleteEntity(ref sign2); 263 | sign = 0; 264 | sign2 = 0; 265 | camera = 0; 266 | cameraNetId = 0; 267 | TriggerServerEvent("Server:SyncCamera", coords, netid, true); 268 | ShowNotification("~b~Facial Recognition ~w~camera removed."); 269 | } 270 | else 271 | { 272 | ProcessError("No camera found to remove"); 273 | } 274 | } 275 | 276 | private bool IsEligible() 277 | { 278 | if (IsPedInAnyVehicle(PlayerPedId(), true) && camera == 0) 279 | { 280 | return true; 281 | } 282 | return false; 283 | } 284 | 285 | 286 | private async void Request(int model) 287 | { 288 | RequestModel((uint)model); 289 | while (!HasModelLoaded((uint)model)) 290 | { 291 | await Delay(0); 292 | } 293 | } 294 | } 295 | } 296 | --------------------------------------------------------------------------------