├── CitizenFX.Core.dll ├── CitizenFX.Core.Server.dll ├── FivemPlayerlist ├── packages.config ├── Properties │ └── AssemblyInfo.cs ├── FivemPlayerlist.csproj └── FivemPlayerlist.cs ├── LICENSE ├── FivemPlayerlistServer ├── Properties │ └── AssemblyInfo.cs ├── FPLServer.cs └── FivemPlayerlistServer.csproj ├── FivemPlayerlist.sln ├── .gitattributes ├── README.md └── .gitignore /CitizenFX.Core.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DevTestingPizza/FiveM-Playerlist/HEAD/CitizenFX.Core.dll -------------------------------------------------------------------------------- /CitizenFX.Core.Server.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DevTestingPizza/FiveM-Playerlist/HEAD/CitizenFX.Core.Server.dll -------------------------------------------------------------------------------- /FivemPlayerlist/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | # Custom License 2 | 3 | COPYRIGHT © 2018 TOM GROBBE 4 | 5 | You are allowed to: 6 | - Use this resource on your any/all FiveM server(s) you own or work on. 7 | - Edit the resource for personal use. 8 | - Re-release **EDITED VERSIONS** as a GITHUB FORK, as long as: 9 | - You credit me. 10 | - You provide a link to this original resource. 11 | - You STATE ALL CHANGES MADE. 12 | - You do not claim it to be your original work. 13 | - You keep this license. 14 | 15 | 16 | You are not allowed to: 17 | - Claim this as your own work. 18 | - Re-release this resource if all you did was change a simple keybind, please make sure you actually made some decent changes before re-releasing your edited version of this resource. 19 | 20 | -------------------------------------------------------------------------------- /FivemPlayerlist/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("FivemScoreboard")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("FivemScoreboard")] 13 | [assembly: AssemblyCopyright("Copyright © 2018")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("82c80b4b-e908-4379-88ba-d929a1aa91af")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /FivemPlayerlistServer/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("FivemScoreboardServer")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("FivemScoreboardServer")] 13 | [assembly: AssemblyCopyright("Copyright © 2018")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("41280f1d-863d-4cdb-a312-db3bc1186afe")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /FivemPlayerlist.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27130.2020 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FivemPlayerlist", "FivemPlayerlist\FivemPlayerlist.csproj", "{82C80B4B-E908-4379-88BA-D929A1AA91AF}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FivemPlayerlistServer", "FivemPlayerlistServer\FivemPlayerlistServer.csproj", "{41280F1D-863D-4CDB-A312-DB3BC1186AFE}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Release|Any CPU = Release|Any CPU 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {82C80B4B-E908-4379-88BA-D929A1AA91AF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {82C80B4B-E908-4379-88BA-D929A1AA91AF}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {82C80B4B-E908-4379-88BA-D929A1AA91AF}.Release|Any CPU.ActiveCfg = Release|Any CPU 19 | {82C80B4B-E908-4379-88BA-D929A1AA91AF}.Release|Any CPU.Build.0 = Release|Any CPU 20 | {41280F1D-863D-4CDB-A312-DB3BC1186AFE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {41280F1D-863D-4CDB-A312-DB3BC1186AFE}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {41280F1D-863D-4CDB-A312-DB3BC1186AFE}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {41280F1D-863D-4CDB-A312-DB3BC1186AFE}.Release|Any CPU.Build.0 = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {955FF85B-DECB-4ADC-B346-321B2580841A} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /FivemPlayerlistServer/FPLServer.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 | 10 | 11 | namespace FivemPlayerlistServer 12 | { 13 | public class FPLServer : BaseScript 14 | { 15 | 16 | private Dictionary list = new Dictionary(); 17 | public FPLServer() 18 | { 19 | EventHandlers.Add("fs:getMaxPlayers", new Action(ReturnMaxPlayers)); 20 | Exports.Add("setPlayerRowConfig", new Action(SetPlayerConfig2)); 21 | EventHandlers.Add("fs:setPlayerRowConfig", new Action(SetPlayerConfig)); 22 | } 23 | 24 | private async void ReturnMaxPlayers([FromSource] Player source) 25 | { 26 | source.TriggerEvent("fs:setMaxPlayers", int.Parse(GetConvar("sv_maxClients", "30").ToString())); 27 | var pl = new PlayerList(); 28 | foreach (Player p in pl) 29 | { 30 | if (list.ContainsKey(int.Parse(p.Handle))) 31 | { 32 | var listItem = list[int.Parse(p.Handle)]; 33 | var p1 = listItem[0]; 34 | var p2 = listItem[1]; 35 | var p3 = listItem[2]; 36 | var p4 = listItem[3]; 37 | source.TriggerEvent("fs:setPlayerRowConfig", p1, p2, p3, p4); 38 | await Delay(1); 39 | } 40 | } 41 | } 42 | 43 | private void SetPlayerConfig2(string playerServerId, string crewName, string jobPoints, string showJobPointsIcon) 44 | { 45 | SetPlayerConfig(int.Parse(playerServerId), crewName, int.Parse(jobPoints ?? "-1"), bool.Parse(showJobPointsIcon ?? "false")); 46 | } 47 | private void SetPlayerConfig(int playerServerId, string crewName, int jobPoints, bool showJobPointsIcon) 48 | { 49 | if (playerServerId > 0) 50 | { 51 | list[playerServerId] = new dynamic[4] { playerServerId, crewName ?? "", jobPoints != null ? jobPoints : -1, showJobPointsIcon != null ? showJobPointsIcon : false }; 52 | TriggerClientEvent("fs:setPlayerConfig", playerServerId, crewName ?? "", jobPoints != null ? jobPoints : -1, 53 | showJobPointsIcon != null ? showJobPointsIcon : false); 54 | } 55 | } 56 | 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /FivemPlayerlistServer/FivemPlayerlistServer.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {41280F1D-863D-4CDB-A312-DB3BC1186AFE} 8 | Library 9 | Properties 10 | FivemPlayerlistServer 11 | FivemPlayerlistServer.net 12 | v4.5.2 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | ..\..\..\..\..\FXserver\vMenu\resources\fivem-scoreboard\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | ..\builds\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | 34 | ..\CitizenFX.Core.Server.dll 35 | False 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /FivemPlayerlist/FivemPlayerlist.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {82C80B4B-E908-4379-88BA-D929A1AA91AF} 8 | Library 9 | Properties 10 | FivemPlayerlist 11 | FivemPlayerlist.net 12 | v4.5.2 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | ..\..\..\..\..\FXserver\vMenu\resources\fivem-scoreboard\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | ..\builds\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | 34 | ..\packages\CitizenFX.Core.1.3.0\lib\net45\CitizenFX.Core.dll 35 | False 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # FiveM-Playerlist 2 | GTA:O styled playerlist for FiveM servers (future proof: supports > 32 players). 3 | 4 | ### Preview: 5 | 6 | ![](https://www.vespura.com/hi/i/2018-05-10_20-49_%25pn_2847cbc57cd7dffc8f.png) 7 | 8 | ### Features: 9 | 10 | - Configurable rows through a server event or export. 11 | - Configured rows update live as soon as the event/export is called, even if someone has the playerlist open at that time. 12 | - GTA:O scaleform used, so it looks exactly like GTA:O. 13 | - Future proof, it supports more than 32 online players. 14 | - "Max Players" indicator updates with the "sv_maxClients" convar, so no need to configure this manually. 15 | 16 | ### Installation 17 | 18 | Download the latest version, drag the folder from the zip file into your resources folder and add `start playerlist` to your server.cfg file. 19 | 20 | 21 | ### Configuration 22 | 23 | There is no config file to change any of the "visual" settings for player rows. You will have to create your own script to modify the rows through the playerlist api. 24 | 25 | 26 | ### Developer info 27 | 28 | To change the player's row settings, trigger this server event: 29 | ```lua 30 | TriggerEvent("fs:setPlayerRowConfig", 1, "SNAIL", 50, true) 31 | ``` 32 | 33 | 34 | #### Parameters 35 | 36 | |type|name|description| 37 | |:-|:-|:-| 38 | |_int_|**playerServerId**|This is the player's server id for the player you want to change the row of.| 39 | |_string_|**crewText**|The text to display for the "crew" tag behind the player's username. Pass an empty string (`""`) to disable the crew label.| 40 | |_int_|**jobPointsAmount**|The number to display for the "job points (jp)" value. Set to -1 to disable.| 41 | |_bool_|**showJobPointsIcon**|Should the "(JP)" icon be visible next to the job points number?| 42 | 43 | 44 | You can access this event from both C# or Lua scripts. By default the crew tag, job points amount and job points logo are all hidden for all players, only if you add them using the event will it make them visible for that specific player row. (syncing for all clients is managed by the resource) 45 | 46 | 47 | You can also use the provided server export (`setPlayerRowConfig()`) however, due to some issues (possibly a bug with FiveM) this is kind of buggy now. Use the event for now, once I figure out why some parameters are not getting passed on when using the export I'll make sure to add documentation for the server export. 48 | 49 | 50 | ### Download / Source Code 51 | 52 | Download the resource on [GitHub](https://github.com/TomGrobbe/FiveM-Playerlist). Make sure to go to the "releases" page and download the latest release, don't download the repository as that's useless if you don't know how to use visual studio or don't want to edit the resource. 53 | 54 | 55 | ### Usage in-game 56 | 57 | When in-game, press "Z" to open the first page, press "Z" again to go to the next page (just like the playerlist in GTA:O). If you're at the last page, pressing "Z" will close the playerlist. If the playerlist is open and you don't close it yourself, then it will auto-close after a couple of seconds. 58 | For controller support, use DPAD-DOWN. 59 | 60 | Note, if other resources on your server disable the "Z" key or the "DPAD-DOWN" (`INPUT_MULTIPLAYER_INFO` / `20`) control, then you won't be able to toggle the playerlist. 61 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | bld/ 21 | [Bb]in/ 22 | [Oo]bj/ 23 | [Ll]og/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | project.fragment.lock.json 46 | artifacts/ 47 | 48 | *_i.c 49 | *_p.c 50 | *_i.h 51 | *.ilk 52 | *.meta 53 | *.obj 54 | *.pch 55 | *.pdb 56 | *.pgc 57 | *.pgd 58 | *.rsp 59 | *.sbr 60 | *.tlb 61 | *.tli 62 | *.tlh 63 | *.tmp 64 | *.tmp_proj 65 | *.log 66 | *.vspscc 67 | *.vssscc 68 | .builds 69 | *.pidb 70 | *.svclog 71 | *.scc 72 | 73 | # Chutzpah Test files 74 | _Chutzpah* 75 | 76 | # Visual C++ cache files 77 | ipch/ 78 | *.aps 79 | *.ncb 80 | *.opendb 81 | *.opensdf 82 | *.sdf 83 | *.cachefile 84 | *.VC.db 85 | *.VC.VC.opendb 86 | 87 | # Visual Studio profiler 88 | *.psess 89 | *.vsp 90 | *.vspx 91 | *.sap 92 | 93 | # TFS 2012 Local Workspace 94 | $tf/ 95 | 96 | # Guidance Automation Toolkit 97 | *.gpState 98 | 99 | # ReSharper is a .NET coding add-in 100 | _ReSharper*/ 101 | *.[Rr]e[Ss]harper 102 | *.DotSettings.user 103 | 104 | # JustCode is a .NET coding add-in 105 | .JustCode 106 | 107 | # TeamCity is a build add-in 108 | _TeamCity* 109 | 110 | # DotCover is a Code Coverage Tool 111 | *.dotCover 112 | 113 | # NCrunch 114 | _NCrunch_* 115 | .*crunch*.local.xml 116 | nCrunchTemp_* 117 | 118 | # MightyMoose 119 | *.mm.* 120 | AutoTest.Net/ 121 | 122 | # Web workbench (sass) 123 | .sass-cache/ 124 | 125 | # Installshield output folder 126 | [Ee]xpress/ 127 | 128 | # DocProject is a documentation generator add-in 129 | DocProject/buildhelp/ 130 | DocProject/Help/*.HxT 131 | DocProject/Help/*.HxC 132 | DocProject/Help/*.hhc 133 | DocProject/Help/*.hhk 134 | DocProject/Help/*.hhp 135 | DocProject/Help/Html2 136 | DocProject/Help/html 137 | 138 | # Click-Once directory 139 | publish/ 140 | 141 | # Publish Web Output 142 | *.[Pp]ublish.xml 143 | *.azurePubxml 144 | # TODO: Comment the next line if you want to checkin your web deploy settings 145 | # but database connection strings (with potential passwords) will be unencrypted 146 | #*.pubxml 147 | *.publishproj 148 | 149 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 150 | # checkin your Azure Web App publish settings, but sensitive information contained 151 | # in these scripts will be unencrypted 152 | PublishScripts/ 153 | 154 | # NuGet Packages 155 | *.nupkg 156 | # The packages folder can be ignored because of Package Restore 157 | **/packages/* 158 | # except build/, which is used as an MSBuild target. 159 | !**/packages/build/ 160 | # Uncomment if necessary however generally it will be regenerated when needed 161 | #!**/packages/repositories.config 162 | # NuGet v3's project.json files produces more ignoreable files 163 | *.nuget.props 164 | *.nuget.targets 165 | 166 | # Microsoft Azure Build Output 167 | csx/ 168 | *.build.csdef 169 | 170 | # Microsoft Azure Emulator 171 | ecf/ 172 | rcf/ 173 | 174 | # Windows Store app package directories and files 175 | AppPackages/ 176 | BundleArtifacts/ 177 | Package.StoreAssociation.xml 178 | _pkginfo.txt 179 | 180 | # Visual Studio cache files 181 | # files ending in .cache can be ignored 182 | *.[Cc]ache 183 | # but keep track of directories ending in .cache 184 | !*.[Cc]ache/ 185 | 186 | # Others 187 | ClientBin/ 188 | ~$* 189 | *~ 190 | *.dbmdl 191 | *.dbproj.schemaview 192 | *.jfm 193 | *.pfx 194 | *.publishsettings 195 | node_modules/ 196 | orleans.codegen.cs 197 | 198 | # Since there are multiple workflows, uncomment next line to ignore bower_components 199 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 200 | #bower_components/ 201 | 202 | # RIA/Silverlight projects 203 | Generated_Code/ 204 | 205 | # Backup & report files from converting an old project file 206 | # to a newer Visual Studio version. Backup files are not needed, 207 | # because we have git ;-) 208 | _UpgradeReport_Files/ 209 | Backup*/ 210 | UpgradeLog*.XML 211 | UpgradeLog*.htm 212 | 213 | # SQL Server files 214 | *.mdf 215 | *.ldf 216 | 217 | # Business Intelligence projects 218 | *.rdl.data 219 | *.bim.layout 220 | *.bim_*.settings 221 | 222 | # Microsoft Fakes 223 | FakesAssemblies/ 224 | 225 | # GhostDoc plugin setting file 226 | *.GhostDoc.xml 227 | 228 | # Node.js Tools for Visual Studio 229 | .ntvs_analysis.dat 230 | 231 | # Visual Studio 6 build log 232 | *.plg 233 | 234 | # Visual Studio 6 workspace options file 235 | *.opt 236 | 237 | # Visual Studio LightSwitch build output 238 | **/*.HTMLClient/GeneratedArtifacts 239 | **/*.DesktopClient/GeneratedArtifacts 240 | **/*.DesktopClient/ModelManifest.xml 241 | **/*.Server/GeneratedArtifacts 242 | **/*.Server/ModelManifest.xml 243 | _Pvt_Extensions 244 | 245 | # Paket dependency manager 246 | .paket/paket.exe 247 | paket-files/ 248 | 249 | # FAKE - F# Make 250 | .fake/ 251 | 252 | # JetBrains Rider 253 | .idea/ 254 | *.sln.iml 255 | 256 | # CodeRush 257 | .cr/ 258 | builds/* 259 | -------------------------------------------------------------------------------- /FivemPlayerlist/FivemPlayerlist.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 | using static CitizenFX.Core.UI.Screen; 9 | 10 | namespace FivemPlayerlist 11 | { 12 | public class FivemPlayerlist : BaseScript 13 | { 14 | private int maxClients = -1; 15 | private bool ScaleSetup = false; 16 | private int currentPage = 0; 17 | Scaleform scale; 18 | private int maxPages = (int)Math.Ceiling((double)new PlayerList().Count() / 16.0); 19 | public struct PlayerRowConfig 20 | { 21 | public string crewName; 22 | public int jobPoints; 23 | public bool showJobPointsIcon; 24 | } 25 | private Dictionary playerConfigs = new Dictionary(); 26 | 27 | private Dictionary textureCache = new Dictionary(); 28 | 29 | /// 30 | /// Constructor 31 | /// 32 | public FivemPlayerlist() 33 | { 34 | TriggerServerEvent("fs:getMaxPlayers"); 35 | Tick += ShowScoreboard; 36 | Tick += DisplayController; 37 | Tick += BackupTimer; 38 | 39 | // Periodically update the player headshots so, you don't have to wait for them later 40 | Tick += UpdateHeadshots; 41 | 42 | EventHandlers.Add("fs:setMaxPlayers", new Action(SetMaxPlayers)); 43 | EventHandlers.Add("fs:setPlayerConfig", new Action(SetPlayerConfig)); 44 | } 45 | 46 | /// 47 | /// Set the config for the specified player. 48 | /// 49 | /// 50 | /// 51 | /// 52 | /// 53 | private async void SetPlayerConfig(int playerServerId, string crewname, int jobpoints, bool showJPicon) 54 | { 55 | var cfg = new PlayerRowConfig() 56 | { 57 | crewName = crewname ?? "", 58 | jobPoints = jobpoints, 59 | showJobPointsIcon = showJPicon 60 | }; 61 | playerConfigs[playerServerId] = cfg; 62 | if (currentPage > -1) 63 | await LoadScale(); 64 | } 65 | 66 | 67 | /// 68 | /// Used to close the page if the regular timer fails to close it for some odd reason. 69 | /// 70 | /// 71 | private async Task BackupTimer() 72 | { 73 | var timer = GetGameTimer(); 74 | var oldPage = currentPage; 75 | while (GetGameTimer() - timer < 8000 && currentPage > 0 && currentPage == oldPage) 76 | { 77 | await Delay(0); 78 | } 79 | if (oldPage == currentPage) 80 | { 81 | currentPage = 0; 82 | } 83 | } 84 | 85 | /// 86 | /// Updates the max pages to disaplay based on the player count. 87 | /// 88 | private void UpdateMaxPages() 89 | { 90 | maxPages = (int)Math.Ceiling((double)new PlayerList().Count() / 16.0); 91 | } 92 | 93 | /// 94 | /// Manages the display and page setup of the playerlist. 95 | /// 96 | /// 97 | private async Task DisplayController() 98 | { 99 | if (Game.IsControlJustPressed(0, Control.MultiplayerInfo)) 100 | { 101 | UpdateMaxPages(); 102 | if (ScaleSetup) 103 | { 104 | currentPage++; 105 | if (currentPage > maxPages) 106 | { 107 | currentPage = 0; 108 | } 109 | await LoadScale(); 110 | var timer = GetGameTimer(); 111 | bool nextPage = false; 112 | while (GetGameTimer() - timer < 8000) 113 | { 114 | await Delay(1); 115 | if (Game.IsControlJustPressed(0, Control.MultiplayerInfo)) 116 | { 117 | nextPage = true; 118 | break; 119 | } 120 | } 121 | if (nextPage) 122 | { 123 | UpdateMaxPages(); 124 | if (currentPage < maxPages) 125 | { 126 | currentPage++; 127 | await LoadScale(); 128 | } 129 | else 130 | { 131 | currentPage = 0; 132 | } 133 | } 134 | else 135 | { 136 | currentPage = 0; 137 | } 138 | } 139 | } 140 | } 141 | 142 | /// 143 | /// Updates the max players (triggered from server event) 144 | /// 145 | /// 146 | private void SetMaxPlayers(int count) 147 | { 148 | maxClients = count; 149 | } 150 | 151 | /// 152 | /// Shows the scoreboard. 153 | /// 154 | /// 155 | private async Task ShowScoreboard() 156 | { 157 | if (maxClients != -1) 158 | { 159 | if (!ScaleSetup) 160 | { 161 | await LoadScale(); 162 | ScaleSetup = true; 163 | } 164 | if (currentPage > 0) 165 | { 166 | float safezone = GetSafeZoneSize(); 167 | float change = (safezone - 0.89f) / 0.11f; 168 | float x = 50f; 169 | x -= change * 78f; 170 | float y = 50f; 171 | y -= change * 50f; 172 | 173 | var width = 400f; 174 | var height = 490f; 175 | if (scale != null) 176 | { 177 | if (scale.IsLoaded) 178 | { 179 | scale.Render2DScreenSpace(new System.Drawing.PointF(x, y), new System.Drawing.PointF(width, height)); 180 | } 181 | } 182 | } 183 | } 184 | } 185 | 186 | /// 187 | /// Loads the scaleform. 188 | /// 189 | /// 190 | private async Task LoadScale() 191 | { 192 | if (scale != null) 193 | { 194 | for (var i = 0; i < maxClients * 2; i++) 195 | { 196 | scale.CallFunction("SET_DATA_SLOT_EMPTY", i); 197 | } 198 | scale.Dispose(); 199 | } 200 | scale = null; 201 | while (!HasScaleformMovieLoaded(RequestScaleformMovie("MP_MM_CARD_FREEMODE"))) 202 | { 203 | await Delay(0); 204 | } 205 | scale = new Scaleform("MP_MM_CARD_FREEMODE"); 206 | var titleIcon = "2"; 207 | var titleLeftText = "FiveM"; 208 | var titleRightText = $"Players {NetworkGetNumConnectedPlayers()}/{maxClients}"; 209 | scale.CallFunction("SET_TITLE", titleLeftText, titleRightText, titleIcon); 210 | await UpdateScale(); 211 | scale.CallFunction("DISPLAY_VIEW"); 212 | } 213 | 214 | /// 215 | /// Struct used for the player info row options. 216 | /// 217 | struct PlayerRow 218 | { 219 | public int serverId; 220 | public string name; 221 | public string rightText; 222 | public int color; 223 | public string iconOverlayText; 224 | public string jobPointsText; 225 | public string crewLabelText; 226 | public enum DisplayType 227 | { 228 | NUMBER_ONLY = 0, 229 | ICON = 1, 230 | NONE = 2 231 | }; 232 | public DisplayType jobPointsDisplayType; 233 | public enum RightIconType 234 | { 235 | NONE = 0, 236 | INACTIVE_HEADSET = 48, 237 | MUTED_HEADSET = 49, 238 | ACTIVE_HEADSET = 47, 239 | RANK_FREEMODE = 65, 240 | KICK = 64, 241 | LOBBY_DRIVER = 79, 242 | LOBBY_CODRIVER = 80, 243 | SPECTATOR = 66, 244 | BOUNTY = 115, 245 | DEAD = 116, 246 | DPAD_GANG_CEO = 121, 247 | DPAD_GANG_BIKER = 122, 248 | DPAD_DOWN_TARGET = 123 249 | }; 250 | public int rightIcon; 251 | public string textureString; 252 | public char friendType; 253 | } 254 | 255 | /// 256 | /// Returns the ped headshot string used for the image of the ped for each row. 257 | /// 258 | /// 259 | /// 260 | private async Task GetHeadshotImage(int ped) 261 | { 262 | var headshotHandle = RegisterPedheadshot(ped); 263 | /* 264 | * For some reason, the below loop didn't work originally without the Valid check or the re-registering of the headshot 265 | */ 266 | while (!IsPedheadshotReady(headshotHandle) || !IsPedheadshotValid(headshotHandle)) 267 | { 268 | headshotHandle = RegisterPedheadshot(ped); 269 | await Delay(0); 270 | } 271 | return GetPedheadshotTxdString(headshotHandle) ?? ""; 272 | } 273 | 274 | /// 275 | /// Updates the scaleform settings. 276 | /// 277 | /// 278 | private async Task UpdateScale() 279 | { 280 | List rows = new List(); 281 | 282 | for (var x = 0; x < 150; x++) // cleaning up in case of a reload, this frees up all ped headshot handles :) 283 | { 284 | UnregisterPedheadshot(x); 285 | } 286 | 287 | var amount = 0; 288 | foreach (Player p in new PlayerList()) 289 | { 290 | if (IsRowSupposedToShow(amount)) 291 | { 292 | PlayerRow row = new PlayerRow(); // Set as a blank PlayerRow obj 293 | 294 | if (playerConfigs.ContainsKey(p.ServerId)) 295 | { 296 | row = new PlayerRow() 297 | { 298 | color = 111, 299 | crewLabelText = playerConfigs[p.ServerId].crewName, 300 | friendType = ' ', 301 | iconOverlayText = "", 302 | jobPointsDisplayType = playerConfigs[p.ServerId].showJobPointsIcon ? PlayerRow.DisplayType.ICON : 303 | (playerConfigs[p.ServerId].jobPoints >= 0 ? PlayerRow.DisplayType.NUMBER_ONLY : PlayerRow.DisplayType.NONE), 304 | jobPointsText = playerConfigs[p.ServerId].jobPoints >= 0 ? playerConfigs[p.ServerId].jobPoints.ToString() : "", 305 | name = p.Name.Replace("<", "").Replace(">", "").Replace("^", "").Replace("~", "").Trim(), 306 | rightIcon = (int)PlayerRow.RightIconType.RANK_FREEMODE, 307 | rightText = $"{p.ServerId}", 308 | serverId = p.ServerId, 309 | }; 310 | } 311 | else 312 | { 313 | row = new PlayerRow() 314 | { 315 | color = 111, 316 | crewLabelText = "", 317 | friendType = ' ', 318 | iconOverlayText = "", 319 | jobPointsDisplayType = PlayerRow.DisplayType.NUMBER_ONLY, 320 | jobPointsText = "", 321 | name = p.Name.Replace("<", "").Replace(">", "").Replace("^", "").Replace("~", "").Trim(), 322 | rightIcon = (int)PlayerRow.RightIconType.RANK_FREEMODE, 323 | rightText = $"{p.ServerId}", 324 | serverId = p.ServerId, 325 | }; 326 | } 327 | 328 | //Debug.WriteLine("Checking if {0} is in the Dic. Their SERVER ID {1}.", p.Name, p.ServerId); 329 | if (textureCache.ContainsKey(p.ServerId)) 330 | { 331 | row.textureString = textureCache[p.ServerId]; 332 | } 333 | else 334 | { 335 | //Debug.WriteLine("Not in setting image to blank"); 336 | row.textureString = ""; 337 | } 338 | 339 | rows.Add(row); 340 | } 341 | amount++; 342 | } 343 | rows.Sort((row1, row2) => row1.serverId.CompareTo(row2.serverId)); 344 | for (var i = 0; i < maxClients * 2; i++) 345 | { 346 | scale.CallFunction("SET_DATA_SLOT_EMPTY", i); 347 | } 348 | var index = 0; 349 | foreach (PlayerRow row in rows) 350 | { 351 | if (row.crewLabelText != "") 352 | { 353 | scale.CallFunction("SET_DATA_SLOT", index, row.rightText, row.name, row.color, row.rightIcon, row.iconOverlayText, row.jobPointsText, 354 | $"..+{row.crewLabelText}", (int)row.jobPointsDisplayType, row.textureString, row.textureString, row.friendType); 355 | } 356 | else 357 | { 358 | scale.CallFunction("SET_DATA_SLOT", index, row.rightText, row.name, row.color, row.rightIcon, row.iconOverlayText, row.jobPointsText, 359 | "", (int)row.jobPointsDisplayType, row.textureString, row.textureString, row.friendType); 360 | } 361 | index++; 362 | } 363 | 364 | await Delay(0); 365 | } 366 | 367 | /// 368 | /// Used to check if the row from the loop is supposed to be displayed based on the current page view. 369 | /// 370 | /// 371 | /// 372 | private bool IsRowSupposedToShow(int row) 373 | { 374 | if (currentPage > 0) 375 | { 376 | var max = currentPage * 16; 377 | var min = (currentPage * 16) - 16; 378 | if (row >= min && row < max) 379 | { 380 | return true; 381 | } 382 | return false; 383 | } 384 | return false; 385 | } 386 | 387 | /// 388 | /// Update the "textureCache" Dictionary with headshots of the players online. 389 | /// 390 | /// 391 | private async Task UpdateHeadshots() 392 | { 393 | PlayerList playersToCheck = new PlayerList(); 394 | 395 | foreach (Player p in playersToCheck) 396 | { 397 | string headshot = await GetHeadshotImage(GetPlayerPed(p.Handle)); 398 | 399 | textureCache[p.ServerId] = headshot; 400 | } 401 | 402 | //Maybe make configurable? 403 | await Delay(1000); 404 | } 405 | 406 | } 407 | } 408 | --------------------------------------------------------------------------------