├── .gitignore ├── LICENSE ├── README.MD ├── autoupdate ├── chat_commands ├── __resource.lua ├── commands │ └── info ├── modules │ ├── cl_overhead_text.lua │ └── info ├── settings.lua ├── system │ ├── cl_proximity.lua │ ├── sv_chat_commands.lua │ ├── sv_fxcheck_1226.lua │ ├── sv_pre.lua │ └── versioncheck.lua └── version └── examples ├── cmds_911.lua ├── cmds_admin.lua ├── cmds_direct_message.lua ├── cmds_example_pack.lua ├── cmds_info.lua ├── cmds_police.lua ├── cmds_rack.lua ├── cmds_report.lua ├── cmds_roleplay_toolkit.lua └── info /.gitignore: -------------------------------------------------------------------------------- 1 | FORUMS.MD 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED. 2 | 3 | BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS. 4 | 5 | 1. Definitions 6 | 7 | "Adaptation" means a work based upon the Work, or upon the Work and other pre-existing works, such as a translation, adaptation, derivative work, arrangement of music or other alterations of a literary or artistic work, or phonogram or performance and includes cinematographic adaptations or any other form in which the Work may be recast, transformed, or adapted including in any form recognizably derived from the original, except that a work that constitutes a Collection will not be considered an Adaptation for the purpose of this License. For the avoidance of doubt, where the Work is a musical work, performance or phonogram, the synchronization of the Work in timed-relation with a moving image ("synching") will be considered an Adaptation for the purpose of this License. 8 | "Collection" means a collection of literary or artistic works, such as encyclopedias and anthologies, or performances, phonograms or broadcasts, or other works or subject matter other than works listed in Section 1(f) below, which, by reason of the selection and arrangement of their contents, constitute intellectual creations, in which the Work is included in its entirety in unmodified form along with one or more other contributions, each constituting separate and independent works in themselves, which together are assembled into a collective whole. A work that constitutes a Collection will not be considered an Adaptation (as defined above) for the purposes of this License. 9 | "Distribute" means to make available to the public the original and copies of the Work through sale or other transfer of ownership. 10 | "Licensor" means the individual, individuals, entity or entities that offer(s) the Work under the terms of this License. 11 | "Original Author" means, in the case of a literary or artistic work, the individual, individuals, entity or entities who created the Work or if no individual or entity can be identified, the publisher; and in addition (i) in the case of a performance the actors, singers, musicians, dancers, and other persons who act, sing, deliver, declaim, play in, interpret or otherwise perform literary or artistic works or expressions of folklore; (ii) in the case of a phonogram the producer being the person or legal entity who first fixes the sounds of a performance or other sounds; and, (iii) in the case of broadcasts, the organization that transmits the broadcast. 12 | "Work" means the literary and/or artistic work offered under the terms of this License including without limitation any production in the literary, scientific and artistic domain, whatever may be the mode or form of its expression including digital form, such as a book, pamphlet and other writing; a lecture, address, sermon or other work of the same nature; a dramatic or dramatico-musical work; a choreographic work or entertainment in dumb show; a musical composition with or without words; a cinematographic work to which are assimilated works expressed by a process analogous to cinematography; a work of drawing, painting, architecture, sculpture, engraving or lithography; a photographic work to which are assimilated works expressed by a process analogous to photography; a work of applied art; an illustration, map, plan, sketch or three-dimensional work relative to geography, topography, architecture or science; a performance; a broadcast; a phonogram; a compilation of data to the extent it is protected as a copyrightable work; or a work performed by a variety or circus performer to the extent it is not otherwise considered a literary or artistic work. 13 | "You" means an individual or entity exercising rights under this License who has not previously violated the terms of this License with respect to the Work, or who has received express permission from the Licensor to exercise rights under this License despite a previous violation. 14 | "Publicly Perform" means to perform public recitations of the Work and to communicate to the public those public recitations, by any means or process, including by wire or wireless means or public digital performances; to make available to the public Works in such a way that members of the public may access these Works from a place and at a place individually chosen by them; to perform the Work to the public by any means or process and the communication to the public of the performances of the Work, including by public digital performance; to broadcast and rebroadcast the Work by any means including signs, sounds or images. 15 | "Reproduce" means to make copies of the Work by any means including without limitation by sound or visual recordings and the right of fixation and reproducing fixations of the Work, including storage of a protected performance or phonogram in digital form or other electronic medium. 16 | 2. Fair Dealing Rights. Nothing in this License is intended to reduce, limit, or restrict any uses free from copyright or rights arising from limitations or exceptions that are provided for in connection with the copyright protection under copyright law or other applicable laws. 17 | 18 | 3. License Grant. Subject to the terms and conditions of this License, Licensor hereby grants You a worldwide, royalty-free, non-exclusive, perpetual (for the duration of the applicable copyright) license to exercise the rights in the Work as stated below: 19 | 20 | to Reproduce the Work, to incorporate the Work into one or more Collections, and to Reproduce the Work as incorporated in the Collections; and, 21 | to Distribute and Publicly Perform the Work including as incorporated in Collections. 22 | For the avoidance of doubt: 23 | 24 | Non-waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme cannot be waived, the Licensor reserves the exclusive right to collect such royalties for any exercise by You of the rights granted under this License; 25 | Waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme can be waived, the Licensor waives the exclusive right to collect such royalties for any exercise by You of the rights granted under this License; and, 26 | Voluntary License Schemes. The Licensor waives the right to collect royalties, whether individually or, in the event that the Licensor is a member of a collecting society that administers voluntary licensing schemes, via that society, from any exercise by You of the rights granted under this License. 27 | The above rights may be exercised in all media and formats whether now known or hereafter devised. The above rights include the right to make such modifications as are technically necessary to exercise the rights in other media and formats, but otherwise you have no rights to make Adaptations. Subject to Section 8(f), all rights not expressly granted by Licensor are hereby reserved. 28 | 29 | 4. Restrictions. The license granted in Section 3 above is expressly made subject to and limited by the following restrictions: 30 | 31 | You may Distribute or Publicly Perform the Work only under the terms of this License. You must include a copy of, or the Uniform Resource Identifier (URI) for, this License with every copy of the Work You Distribute or Publicly Perform. You may not offer or impose any terms on the Work that restrict the terms of this License or the ability of the recipient of the Work to exercise the rights granted to that recipient under the terms of the License. You may not sublicense the Work. You must keep intact all notices that refer to this License and to the disclaimer of warranties with every copy of the Work You Distribute or Publicly Perform. When You Distribute or Publicly Perform the Work, You may not impose any effective technological measures on the Work that restrict the ability of a recipient of the Work from You to exercise the rights granted to that recipient under the terms of the License. This Section 4(a) applies to the Work as incorporated in a Collection, but this does not require the Collection apart from the Work itself to be made subject to the terms of this License. If You create a Collection, upon notice from any Licensor You must, to the extent practicable, remove from the Collection any credit as required by Section 4(b), as requested. 32 | If You Distribute, or Publicly Perform the Work or Collections, You must, unless a request has been made pursuant to Section 4(a), keep intact all copyright notices for the Work and provide, reasonable to the medium or means You are utilizing: (i) the name of the Original Author (or pseudonym, if applicable) if supplied, and/or if the Original Author and/or Licensor designate another party or parties (e.g., a sponsor institute, publishing entity, journal) for attribution ("Attribution Parties") in Licensor's copyright notice, terms of service or by other reasonable means, the name of such party or parties; (ii) the title of the Work if supplied; (iii) to the extent reasonably practicable, the URI, if any, that Licensor specifies to be associated with the Work, unless such URI does not refer to the copyright notice or licensing information for the Work. The credit required by this Section 4(b) may be implemented in any reasonable manner; provided, however, that in the case of a Collection, at a minimum such credit will appear, if a credit for all contributing authors of the Collection appears, then as part of these credits and in a manner at least as prominent as the credits for the other contributing authors. For the avoidance of doubt, You may only use the credit required by this Section for the purpose of attribution in the manner set out above and, by exercising Your rights under this License, You may not implicitly or explicitly assert or imply any connection with, sponsorship or endorsement by the Original Author, Licensor and/or Attribution Parties, as appropriate, of You or Your use of the Work, without the separate, express prior written permission of the Original Author, Licensor and/or Attribution Parties. 33 | Except as otherwise agreed in writing by the Licensor or as may be otherwise permitted by applicable law, if You Reproduce, Distribute or Publicly Perform the Work either by itself or as part of any Collections, You must not distort, mutilate, modify or take other derogatory action in relation to the Work which would be prejudicial to the Original Author's honor or reputation. 34 | 5. Representations, Warranties and Disclaimer 35 | 36 | UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU. 37 | 38 | 6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 39 | 40 | 7. Termination 41 | 42 | This License and the rights granted hereunder will terminate automatically upon any breach by You of the terms of this License. Individuals or entities who have received Collections from You under this License, however, will not have their licenses terminated provided such individuals or entities remain in full compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will survive any termination of this License. 43 | Subject to the above terms and conditions, the license granted here is perpetual (for the duration of the applicable copyright in the Work). Notwithstanding the above, Licensor reserves the right to release the Work under different license terms or to stop distributing the Work at any time; provided, however that any such election will not serve to withdraw this License (or any other license that has been, or is required to be, granted under the terms of this License), and this License will continue in full force and effect unless terminated as stated above. 44 | 8. Miscellaneous 45 | 46 | Each time You Distribute or Publicly Perform the Work or a Collection, the Licensor offers to the recipient a license to the Work on the same terms and conditions as the license granted to You under this License. 47 | If any provision of this License is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this License, and without further action by the parties to this agreement, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable. 48 | No term or provision of this License shall be deemed waived and no breach consented to unless such waiver or consent shall be in writing and signed by the party to be charged with such waiver or consent. 49 | This License constitutes the entire 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. Licensor shall not be bound by any additional provisions that may appear in any communication from You. This License may not be modified without the mutual written agreement of the Licensor and You. 50 | The rights granted under, and the subject matter referenced, in this License were drafted utilizing the terminology of the Berne Convention for the Protection of Literary and Artistic Works (as amended on September 28, 1979), the Rome Convention of 1961, the WIPO Copyright Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996 and the Universal Copyright Convention (as revised on July 24, 1971). These rights and subject matter take effect in the relevant jurisdiction in which the License terms are sought to be enforced according to the corresponding provisions of the implementation of those treaty provisions in the applicable national law. If the standard suite of rights granted under applicable copyright law includes additional rights not granted under this License, such additional rights are deemed to be included in the License; this License is not intended to restrict the license of any rights under applicable law. 51 | Creative Commons Notice 52 | Creative Commons is not a party to this License, and makes no warranty whatsoever in connection with the Work. Creative Commons will not be liable to You or any party on any legal theory for any damages whatsoever, including without limitation any general, special, incidental or consequential damages arising in connection to this license. Notwithstanding the foregoing two (2) sentences, if Creative Commons has expressly identified itself as the Licensor hereunder, it shall have all rights and obligations of Licensor. 53 | 54 | Except for the limited purpose of indicating to the public that the Work is licensed under the CCPL, Creative Commons does not authorize the use by either party of the trademark "Creative Commons" or any related trademark or logo of Creative Commons without the prior written consent of Creative Commons. Any permitted use will be in compliance with Creative Commons' then-current trademark usage guidelines, as may be published on its website or otherwise made available upon request from time to time. For the avoidance of doubt, this trademark restriction does not form part of this License. 55 | 56 | Creative Commons may be contacted at https://creativecommons.org/. 57 | -------------------------------------------------------------------------------- /README.MD: -------------------------------------------------------------------------------- 1 | # FiveM Chat Command System 2 | #### A custom system made to allow easy installation of chat command packs that allows advanced customized behavior, and allows quick and easy modification for server owners. 3 | 4 | This system is designed to be one universal method of creating and using simple interaction commands, and to replace old and copy-pasted methods released in the past. 5 | 6 | It provides server owners with a simple way of installing and configuring their commands. 7 | 8 | ## Features 9 | * Framework compatiblity (vRP & ESX) 10 | * Automatic name formatting based on server frameworks 11 | * Easy configuration 12 | * Simple drag-and-drop installation 13 | * Universal bridge between chat commands and frameworks 14 | * Potentially powerful API, yet also simple to use. 15 | 16 | ## Resource Installation 17 | * Download the repository 18 | * Put the chat_commands folder in your resources directory 19 | * Add `start chat_commands` to your server config 20 | * Configure `settings.lua` to your liking 21 | * If you are using ESX or vRP, set the `use_esx` or `use_vrp` field to true! 22 | 23 | ## Command Pack Installation 24 | * Download the command pack, they usually come as `.lua` files 25 | * Drag and drop the pack file into the `chat_commands/commands` folder 26 | * You should now see that the pack is loaded when the server is started 27 | 28 | ## Updating 29 | * By enabling `check_updates` in `settings.lua`, the resource will automatically check for updates 30 | * If an update is found, you will be given the option to update. 31 | * To update, use `chat_commands autoupdate` in the console. 32 | * Your resource files will be automatically updated to their newest version. 33 | * This will not overwrite your `settings.lua` file or your command packs. 34 | 35 | ## Note 36 | #### Warning! This resource depends on a feature only available since FXServer version `1226`! 37 | There are a few example command packs in this repository download, more may be available on the FiveM Forums. 38 | 39 | There should be enough comments etc. to get started on creating your own commands, even if you're not an experienced programmer. 40 | 41 | All commands can only be ran by players, and will be blocked in the console. 42 | 43 | ## Settings 44 | There are a couple settings you can configure for your server. 45 | These can be found in the `settings.lua` file. 46 | 47 | | Setting | Required | Type | Description | 48 | |---------|----------|----------|-------------------------------------------------------------------------------------| 49 | | show_id | No | boolean | makes the players name also include the players ID | 50 | | logging | No | boolean | enables print output to the console (and chat during commands) | 51 | | use_esx | No | boolean | compatibility with ESX | 52 | | use_vrp | No | boolean | compatibility with vRP (f.ex Dunko's vRP) (does not support vRP 2!) | 53 | | cb | No | function | Global callback function, can be used to log every command, or do other fancy stuff | 54 | | use_framework_name | No | boolean | automatically format names using framework systems, such as character identity | 55 | | check_updates | No | boolean | check for updates on startup (recommended) | 56 | 57 | ## Credits 58 | Version check system by [BlueTheFurry](https://github.com/Bluethefurry) 59 | 60 | [GitHub Download](https://github.com/Bluethefurry/FiveM-Resource-Version-Check-Thing) 61 | 62 | ## Creating a command pack 63 | Creating a command pack can be very easy, as there is very little that is required to make a command 64 | 65 | To create a new command pack, create a new file with a `.lua` extension. 66 | In this file, add the following code: 67 | ```lua 68 | CommandPack("PACK_NAME", "AUTHOR_NAME", { 69 | -- Add commands here 70 | }, { 71 | -- Default values 72 | } 73 | ``` 74 | And replace the `PACK_NAME` and `AUTHOR_NAME` fields. 75 | 76 | Commands are defined as a table containing command parameters. 77 | 78 | You can also add the parameters to the default values table, these parameters will be given to all commands (in the pack) that are not already using said parameter. 79 | 80 | The following parameters are available per command. 81 | 82 | | Parameter | Required | Type | Description | 83 | |-----------|----------|----------|-----------------------------------------------------------------------------------------------| 84 | | command | Yes | string | the name of the command as used in chat, without the / | 85 | | format | Yes (unless using `reply`) | string | how the message appears (with custom formatting) | 86 | | title | | string | same as format, but appears as the message sender | 87 | | color | | table | table with RGB, used with title (default is {255, 255, 255}) | 88 | | help | | string | help text for the command, shown under the chat input | 89 | | usage | | string | shown when no text is sent with the command | 90 | | range | | number | maximum distance for receiving players (-1 or not specified means global range) | 91 | | hidden | | boolean | if true, the message is not shown in chat | 92 | | cb | | function | callback function with (source, message, command, args, raw) parameters | 93 | | prereq | | function | function with (source, command, args, raw), returns wether the command can be executed or not | 94 | | noperm | | string | message that is shown if the prereq fails | 95 | | admin | | boolean | if true, only administrators can use this command, compatible with ESX and vRP, uses ACE by default | 96 | | reply | | string | forced reply to command, no other parts of the command is executed (for simple info commands) | 97 | 98 | ### Format Parameter 99 | The `format` parameter allows for specific formatting, where key elements are replaced based on server settings. 100 | 101 | The following keywords are available: 102 | 103 | | Keyword | Description | 104 | |---|---| 105 | | `#name#` | Replaced with the players name, if IDs are enabled, then the ID is appended aswell. If framework names are enabled, this is the framework specific name. | 106 | | `#char#` | Same as `#name#`, but ignores the ID setting. | 107 | | `#id#` | Replaced with the players server ID. Normally the players source ID, but if vRP is enabled then this is the players vRP ID. | 108 | | `#time#` | Replaced with the current timestamp of the server. | 109 | | `#username#` | Same as `#name#`, but does not use framework name. In cases where only the username should be shown. | 110 | 111 | ## Example command pack 112 | This example pack will add some simple roleplay chat commands, these are just examples. Do not use these for your server. 113 | ```lua 114 | CommandPack("Example Pack", "glitchdetector", { 115 | -- Simple OOC command, using the only two required parameters 116 | { 117 | command = "ooc", 118 | format = "^9[[[ OOC #name# #message# ]]]", 119 | }, 120 | -- A /me command with range and help information 121 | { 122 | command = "me", 123 | format = "^6* #name# #message#", 124 | help = "Personal action", 125 | usage = "/me [action]", 126 | args = {{name = "action", help = "The action you're performing"}}, 127 | range = 50.0, 128 | }, 129 | -- Admin only announcement command (can only be used by ACE administrators), the administrator name is not shown 130 | { 131 | command = "adminge" 132 | format = "#message#", 133 | title = "ADMINISTRATOR ANNOUNCEMENT", 134 | color = {255, 0, 0}, 135 | admin = true, 136 | }, 137 | -- Example command that relays the message to something else, like discord (actual discord code not included) 138 | { 139 | command = "report", 140 | format = "**#name# reports an issue:** #message#", 141 | help = "Report an issue", 142 | hidden = true, -- Prevents the message from being shown in chat 143 | cb = function(source, message) 144 | TriggerEvent("SendMessageToDiscord", message) 145 | end, 146 | }, 147 | }, { 148 | -- Default values, if one is not specified for the command 149 | -- We don't need to specify any default values here for this example 150 | }) 151 | ``` 152 | 153 | ## Disclaimer 154 | Please refrain from remixing this resource. 155 | 156 | It is intended to be a universal solution, if there are missing features, please submit a PR on GitHub with improvements. 157 | 158 | You may include this as part of pack downloads, as long as it is not modified. 159 | 160 | ## License 161 | [Attribution-NoDerivs 3.0 Unported (CC BY-ND 3.0)](https://creativecommons.org/licenses/by-nd/3.0/) 162 | -------------------------------------------------------------------------------- /autoupdate: -------------------------------------------------------------------------------- 1 | commands/info 2 | modules/info 3 | modules/cl_overhead_text.lua 4 | system/cl_proximity.lua 5 | system/sv_chat_commands.lua 6 | system/sv_fxcheck_1226.lua 7 | system/sv_pre.lua 8 | system/versioncheck.lua 9 | __resource.lua 10 | version 11 | -------------------------------------------------------------------------------- /chat_commands/__resource.lua: -------------------------------------------------------------------------------- 1 | resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937' 2 | 3 | name 'Chat Command System' 4 | author 'glitchdetector' 5 | contact 'glitchdetector@gmail.com' 6 | version '1.0.0' 7 | 8 | description 'A configurable and extendable chat command system, designed for easy drag-and-drop usage.' 9 | usage [[ 10 | By default, an example command pack is installed. You most likely want to delete this pack. 11 | Command packs like these can simply be dragged and dropped into the "commands" folder. 12 | 13 | Certain settings can be configured in the settings.lua file 14 | ]] 15 | 16 | -- vRP compatibility 17 | server_script '@vrp/lib/utils.lua' 18 | 19 | -- ESX compatibility 20 | server_script '@mysql-async/lib/MySQL.lua' 21 | 22 | client_script 'system/cl_proximity.lua' 23 | 24 | shared_script 'settings.lua' 25 | 26 | client_script 'modules/cl_*.lua' 27 | server_script 'modules/sv_*.lua' 28 | shared_script 'modules/sh_*.lua' 29 | 30 | server_script 'system/sv_pre.lua' 31 | server_script "commands/*.lua" 32 | 33 | server_script 'system/sv_fxcheck_*.lua' 34 | server_script 'system/sv_chat_commands.lua' 35 | 36 | server_script 'system/versioncheck.lua' 37 | -------------------------------------------------------------------------------- /chat_commands/commands/info: -------------------------------------------------------------------------------- 1 | -- This is where command packs are supposed to be installed -- 2 | Simply drag and drop a command pack file (.lua file) into this directory and restart the server 3 | -------------------------------------------------------------------------------- /chat_commands/modules/cl_overhead_text.lua: -------------------------------------------------------------------------------- 1 | -- Enables rendering of text above someones head, to show certain actions being performed 2 | 3 | local FloatingText = {} 4 | local FloatingTextDuration = 5000 5 | local FloatingTextSize = 1.0 6 | local FloatingTextColor = {255, 255, 255, 255} 7 | local FloatingTextFont = 4 8 | local FloatingTextMaxDistance = 50.0 9 | 10 | RegisterNetEvent("chat_commands:showFloatingText") 11 | AddEventHandler("chat_commands:showFloatingText", function(target, text) 12 | table.insert(FloatingText, {target = GetPlayerFromServerId(target), text = text, life = GetGameTimer() + FloatingTextDuration}) 13 | end) 14 | 15 | local function DrawText3D(text, x, y, z) 16 | local onScreen, _x, _y = World3dToScreen2d(x, y, z) 17 | local px, py, pz = table.unpack(GetGameplayCamCoords()) 18 | local dist = GetDistanceBetweenCoords(px, py, pz, x, y, z, 1) 19 | local s = FloatingTextSize 20 | local scale = ((1 / dist) * 2) * s 21 | local fov = (1 / GetGameplayCamFov()) * 100 22 | local scale = scale * fov 23 | if onScreen then 24 | SetDrawOrigin(x, y, z, 0) 25 | SetTextScale(0.0 * scale, 1.1 * scale) 26 | SetTextFont(FloatingTextFont) 27 | SetTextProportional(1) 28 | SetTextColour(FloatingTextColor[1], FloatingTextColor[2], FloatingTextColor[3], FloatingTextColor[4]) 29 | SetTextEdge(2, 0, 0, 0, 150) 30 | SetTextDropShadow() 31 | SetTextOutline() 32 | SetTextEntry("STRING") 33 | SetTextCentre(1) 34 | AddTextComponentString(text) 35 | DrawText(0.0, 0.0) 36 | ClearDrawOrigin() 37 | end 38 | end 39 | 40 | Citizen.CreateThread(function() 41 | print("[Chat Commands] Overhead Text enabled") 42 | while true do 43 | Wait(0) 44 | local lpos = GetEntityCoords(PlayerPedId()) 45 | for n, text in next, FloatingText do 46 | if NetworkIsPlayerActive(text.target) then 47 | local ply = GetPlayerPed(text.target) 48 | local pos = GetWorldPositionOfEntityBone(ply, GetEntityBoneIndexByName(ply, "head")) 49 | if #(lpos - pos) <= FloatingTextMaxDistance then 50 | DrawText3D(text.text, pos.x, pos.y, pos.z + 0.2) 51 | end 52 | else 53 | -- Offline player 54 | end 55 | if text.life < GetGameTimer() then 56 | -- Remove old floating text 57 | table.remove(FloatingText, n) 58 | end 59 | end 60 | end 61 | end) 62 | -------------------------------------------------------------------------------- /chat_commands/modules/info: -------------------------------------------------------------------------------- 1 | -- This is where extension modules are placed -- 2 | Simply drag and drop the module in here, client files are prefixed cl_ and server files sv_, shared files sh_ 3 | -------------------------------------------------------------------------------- /chat_commands/settings.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | Note: 3 | - When updating the resource (if ever needed), please keep a copy of your settings so you don't lose them 4 | - Only enable framework compatibility if your server is running said framework 5 | ]] 6 | 7 | SETTINGS = { 8 | show_id = true, -- makes the name also include the players ID 9 | logging = true, -- enables print output to the console (and chat during commands) 10 | use_esx = false, -- enables ESX compatibility for admin commands, and for advanced commands 11 | use_vrp = false, -- enables vRP compatibility for admin commands, and for advanced commands 12 | use_framework_name = true, -- replaces the players name with their framework name, such as vRP identity 13 | cb = function(source, message, command, args, raw) 14 | -- You can do things after any command is executed (useful for logging) 15 | end, 16 | check_updates = true, -- check for updates on startup (recommended) 17 | } 18 | -------------------------------------------------------------------------------- /chat_commands/system/cl_proximity.lua: -------------------------------------------------------------------------------- 1 | RegisterNetEvent("chat_commands:proximity") 2 | AddEventHandler("chat_commands:proximity", function(serverId, range, chatMessage) 3 | local player = GetPlayerFromServerId(serverId) 4 | local playerPed = GetPlayerPed(player) 5 | local ped = PlayerPedId() 6 | local dist = #(GetEntityCoords(playerPed) - GetEntityCoords(ped)) 7 | if player ~= -1 and (dist <= range or player == PlayerId()) then 8 | TriggerEvent("chat:addMessage", chatMessage) 9 | end 10 | end) 11 | -------------------------------------------------------------------------------- /chat_commands/system/sv_chat_commands.lua: -------------------------------------------------------------------------------- 1 | local function commandHandler(command, source, args, raw) 2 | if not source or source == 0 then 3 | log("This command can not be executed by the console") 4 | return false 5 | end 6 | -- Responds with a message, can contain title 7 | local function reply(text, title) 8 | local messageArgs = {text} 9 | if title then messageArgs = {title, text} end 10 | TriggerClientEvent("chat:addMessage", source, { 11 | color = command.color or {255, 255, 255}, 12 | multiline = true, 13 | args = messageArgs 14 | }) 15 | end 16 | local function deny() 17 | if command.noperm then 18 | reply(command.noperm) 19 | end 20 | end 21 | if command.prereq then 22 | if not command.prereq(source, command, args, raw) then 23 | deny() 24 | return false 25 | end 26 | end 27 | if command.admin then 28 | if SETTINGS.use_vrp then 29 | -- Check if user is a vRP admin 30 | if vRP then 31 | local function isVRPAdmin() 32 | local user_id = vRP.getUserId({source}) 33 | if vRP.hasPermission({user_id, "admin.announce"}) then return true end 34 | return false 35 | end 36 | if not isVRPAdmin() then 37 | deny() 38 | return false 39 | end 40 | else 41 | reply("Server is configured to use vRP, but vRP is not initialized.") 42 | return false 43 | end 44 | elseif SETTINGS.use_esx then 45 | -- ESX admin is already handled by the command def 46 | else 47 | -- Nothing needs to be done, ACE should already handle this case 48 | end 49 | end 50 | if command.reply then 51 | if command.title then 52 | reply(command.reply, command.title) 53 | else 54 | reply(command.reply) 55 | end 56 | return true 57 | end 58 | if #args > 0 or command.noargs then 59 | local visualName = GetPlayerName(source) 60 | local visualUsername = GetPlayerName(source) 61 | local visualId = source 62 | if SETTINGS.use_framework_name then 63 | if SETTINGS.use_vrp then 64 | local user_id = vRP.getUserId({source}) 65 | local loaded = false 66 | vRP.getUserIdentity({user_id, function(identity) 67 | visualName = ("%s %s"):format(identity.firstname, identity.name) 68 | visualId = user_id 69 | loaded = true 70 | end}) 71 | while not loaded do Wait(0) end 72 | elseif SETTINGS.use_esx then 73 | local function getESXPlayername() 74 | local identifier = GetPlayerIdentifiers(source)[1] 75 | local result = MySQL.Sync.fetchAll("SELECT * FROM users WHERE identifier = @identifier", {['@identifier'] = identifier}) 76 | if result[1] ~= nil then 77 | local identity = result[1] 78 | return true, identity['firstname'], identity['lastname'] 79 | end 80 | return false, "", "" 81 | end 82 | local ok, firstName, lastName = getESXPlayername() 83 | if ok then 84 | visualName = ("%s %s"):format(firstName, lastName) 85 | end 86 | end 87 | end 88 | local message = command.format 89 | message = message:gsub("#username#", SETTINGS.show_id and ("%s (%s)"):format(visualUsername, visualId) or visualUsername) 90 | message = message:gsub("#char#", visualName) 91 | message = message:gsub("#name#", SETTINGS.show_id and ("%s (%s)"):format(visualName, visualId) or visualName) 92 | message = message:gsub("#id#", visualId) 93 | message = message:gsub("#message#", table.concat(args, " ")) 94 | 95 | if not command.hidden then 96 | local messageArgs = {message} 97 | if command.title then 98 | local title = command.title 99 | title = title:gsub("#username#", SETTINGS.show_id and ("%s (%s)"):format(visualUsername, visualId) or visualUsername) 100 | title = title:gsub("#char#", visualName) 101 | title = title:gsub("#name#", SETTINGS.show_id and ("%s (%s)"):format(visualName, visualId) or visualName) 102 | title = title:gsub("#id#", visualId) 103 | title = title:gsub("#message#", table.concat(args, " ")) 104 | messageArgs = {title, message} 105 | end 106 | 107 | if command.range and command.range ~= -1 then 108 | -- Local range, send as proximity 109 | TriggerClientEvent("chat_commands:proximity", -1, source, command.range, { 110 | color = command.color or {255, 255, 255}, 111 | multiline = true, 112 | args = messageArgs 113 | }) 114 | else 115 | -- Global range 116 | TriggerClientEvent("chat:addMessage", -1, { 117 | color = command.color or {255, 255, 255}, 118 | multiline = true, 119 | args = messageArgs 120 | }) 121 | end 122 | end 123 | 124 | if command.cb then 125 | command.cb(source, message, command, args, raw) 126 | end 127 | if SETTINGS.cb then 128 | SETTINGS.cb(source, message, command, args, raw) 129 | end 130 | else 131 | if command.usage then 132 | reply(command.usage, "^3Usage") 133 | end 134 | end 135 | end 136 | 137 | for _, command in next, COMMANDS do 138 | log(("Registering command /%s from pack %s by %s"):format(command.command, command.pack, command.author)) 139 | local aceLocked = false 140 | if command.admin then 141 | if SETTINGS.use_vrp then 142 | -- Do not ACE lock the command, we use vRP admin checking 143 | elseif SETTINGS.use_esx then 144 | -- Do not ACE lock the command, we use ESX admin checking 145 | else 146 | aceLocked = true 147 | end 148 | end 149 | if SETTINGS.use_esx and command.admin then 150 | -- Register command as an essentialmode admin command 151 | TriggerEvent('es:addGroupCommand', command.command, 'admin', function(source, args, user) 152 | commandHandler(command, source, args, raw) 153 | end, function(source, args, user) 154 | TriggerClientEvent('chat:addMessage', source, { args = { '^1SYSTEM', (command.noperm and command.noperm or 'Insufficient Permissions.') } }) 155 | end) 156 | else 157 | RegisterCommand(command.command, function(source, args, raw) 158 | commandHandler(command, source, args, raw) 159 | end, aceLocked) 160 | end 161 | if command.help then 162 | TriggerClientEvent("chat:addSuggestion", -1, "/" .. command.command, command.help, command.args) 163 | end 164 | end 165 | 166 | if not SETTINGS.fxcheck then 167 | log("|=====================") 168 | log("| WARNING!") 169 | log("|=====================") 170 | log("| Unsupported FXServer version!") 171 | log("| Required: FXServer 1226 or newer") 172 | log("| Current: " .. GetConvar("version", "")) 173 | log("|=====================") 174 | end 175 | -------------------------------------------------------------------------------- /chat_commands/system/sv_fxcheck_1226.lua: -------------------------------------------------------------------------------- 1 | -- This file is never executed on pre-1226 FXServer builds 2 | SETTINGS.fxcheck = true 3 | -------------------------------------------------------------------------------- /chat_commands/system/sv_pre.lua: -------------------------------------------------------------------------------- 1 | function log(text) 2 | if SETTINGS.logging then 3 | print("^3[Chat Commands] ^7" .. text .. "^7") 4 | end 5 | end 6 | 7 | function shallowcopy(orig) 8 | local orig_type = type(orig) 9 | local copy 10 | if orig_type == 'table' then 11 | copy = {} 12 | for orig_key, orig_value in pairs(orig) do 13 | copy[orig_key] = orig_value 14 | end 15 | else -- number, string, boolean, etc 16 | copy = orig 17 | end 18 | return copy 19 | end 20 | 21 | ESX = nil 22 | vRP = nil 23 | vRPclient = nil 24 | 25 | -- vRP compatibility 26 | if SETTINGS.use_vrp then 27 | log("Enabling vRP compatibility") 28 | local Proxy = module("vrp", "lib/Proxy") 29 | local Tunnel = module("vrp", "lib/Tunnel") 30 | vRP = Proxy.getInterface("vRP") 31 | vRPclient = Tunnel.getInterface("vRP","chat_commands") 32 | log("vRP compatibility enabled") 33 | end 34 | 35 | -- ESX compatibility 36 | if SETTINGS.use_esx then 37 | log("Enabling ESX compatibility") 38 | while not ESX do 39 | TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) 40 | end 41 | log("ESX compatibility enabled") 42 | end 43 | 44 | COMMANDS = {} 45 | 46 | local function AddCommand(command) 47 | if not command.command then return "Missing command parameter" end 48 | if not command.format and not command.reply then return "Missing format parameter" end 49 | if command.reply and (command.cb or command.hidden or command.usage) then log("Warning! Using reply will stop the command from executing fully!") end 50 | log(("Added /%s"):format(command.command)) 51 | table.insert(COMMANDS, command) 52 | return nil 53 | end 54 | 55 | local function AddAlias(alias, commandName) 56 | for _, command in next, COMMANDS do 57 | if command.command == commandName then 58 | local aliasCommand = shallowcopy(command) 59 | aliasCommand.command = alias 60 | table.insert(COMMANDS, aliasCommand) 61 | log(("Added alias /%s for /%s"):format(alias, commandName)) 62 | return true 63 | end 64 | end 65 | log(("Could not create alias /%s for /%s: %s"):format(alias, commandName, "Command does not exist")) 66 | return false 67 | end 68 | 69 | function CommandPack(packName, packAuthor, commands, defaults, aliases) 70 | log(("== Loading command pack %s by %s =="):format(packName, packAuthor)) 71 | for _, command in next, commands do 72 | command.author = packAuthor 73 | command.pack = packName 74 | if defaults then 75 | for default, value in next, defaults do 76 | if not command[default] then 77 | command[default] = value 78 | end 79 | end 80 | end 81 | local result = AddCommand(command) 82 | if result then 83 | log(("Could not add /%s: %s"):format(command.command, result)) 84 | end 85 | end 86 | if aliases then 87 | for _, alias in next, aliases do 88 | if alias[1] and alias[2] then 89 | AddAlias(alias[1], alias[2]) 90 | else 91 | log("Malformed alias") 92 | end 93 | end 94 | end 95 | log(("== Pack loaded with %s command%s =="):format(#commands, #commands == 1 and "" or "s")) 96 | end 97 | 98 | log("Starting chat command loading process") 99 | -------------------------------------------------------------------------------- /chat_commands/system/versioncheck.lua: -------------------------------------------------------------------------------- 1 | if SETTINGS.check_updates then 2 | log("Checking for updates...") 3 | Citizen.CreateThread( function() 4 | local updatePath = "/glitchdetector/fivem-chat-commands" -- your git user/repo path 5 | local resourceName = "FiveM Chat Command System ("..GetCurrentResourceName()..")" -- the resource name 6 | function checkVersion(err, responseText, headers) 7 | local curVersion = LoadResourceFile(GetCurrentResourceName(), "version") -- make sure the "version" file actually exists in your resource root! 8 | if not responseText then 9 | log("Update check failed, where did the remote repository go?") 10 | elseif curVersion ~= responseText and tonumber(curVersion) < tonumber(responseText) then 11 | log("###############################") 12 | log(""..resourceName.." is outdated.") 13 | log("Available version: " .. responseText) 14 | log("Current Version: " .. curVersion) 15 | log("Please update it from https://github.com"..updatePath.."") 16 | log("###############################") 17 | log("Or do /" .. GetCurrentResourceName() .. " autoupdate") 18 | log("(This will not overwrite your settings.lua file)") 19 | log("(This will not remove your command packs)") 20 | log("###############################") 21 | 22 | elseif tonumber(curVersion) > tonumber(responseText) then 23 | log("You somehow skipped a few versions of "..resourceName.." or the git went offline, if it's still online i advise you to update ( or downgrade? )") 24 | else 25 | log(""..resourceName.." is up to date, have fun!") 26 | end 27 | end 28 | PerformHttpRequest("https://raw.githubusercontent.com"..updatePath.."/master/chat_commands/version", checkVersion, "GET") 29 | end) 30 | end 31 | 32 | RegisterCommand(GetCurrentResourceName(), function(_, args) 33 | if args[1] == "autoupdate" then 34 | log("###############################") 35 | log("Updating resource") 36 | log("###############################") 37 | local updatePath = "/glitchdetector/fivem-chat-commands" -- your git user/repo path 38 | PerformHttpRequest("https://raw.githubusercontent.com"..updatePath.."/master/autoupdate", function(err, responseText, headers) 39 | local function updateFile(fileName) 40 | local ok = false 41 | local _l = false 42 | PerformHttpRequest("https://raw.githubusercontent.com"..updatePath.."/master/chat_commands/" .. fileName, function(err, responseText, headers) 43 | if err ~= 200 then 44 | log("Failed to download file " .. fileName .. ": " .. err) 45 | else 46 | if LoadResourceFile(GetCurrentResourceName(), fileName) ~= responseText then 47 | log("Downloading file " .. fileName) 48 | SaveResourceFile(GetCurrentResourceName(), fileName, responseText, -1) 49 | 50 | if not LoadResourceFile(GetCurrentResourceName(), fileName) then 51 | log("Failed to save file " .. fileName.. ". Does the directory exist?") 52 | else 53 | ok = true 54 | end 55 | end 56 | end 57 | _l = true 58 | end) 59 | while not _l do Wait(0) end 60 | return ok 61 | end 62 | local files = 0 63 | for fileName in string.gmatch(responseText, "%S+") do 64 | if updateFile(fileName) then 65 | files = files + 1 66 | end 67 | end 68 | if files > 0 then 69 | log("###############################") 70 | log("Updated " .. files .. " files") 71 | else 72 | log("No changes were made") 73 | end 74 | log("###############################") 75 | if SETTINGS.use_esx then 76 | -- ESX command def is so wonky it will duplicate commands if we reload lol 77 | log("Please restart the server") 78 | else 79 | log("Please /refresh then /restart " .. GetCurrentResourceName()) 80 | end 81 | log("###############################") 82 | end, "GET") 83 | else 84 | log("Did you mean to do /" .. GetCurrentResourceName() .. " autoupdate?") 85 | end 86 | end, true) 87 | -------------------------------------------------------------------------------- /chat_commands/version: -------------------------------------------------------------------------------- 1 | 927 2 | -------------------------------------------------------------------------------- /examples/cmds_911.lua: -------------------------------------------------------------------------------- 1 | -- Simple 911 script, sends message to online dispatch, if not using a framework it just sends it to everyone 2 | CommandPack("Information Commands", "glitchdetector", { 3 | -- Add commands here 4 | -- /911 command with dispatch code 5 | { 6 | command = "911", 7 | format = "^2^*Call by #name#: ^r^7#message#", 8 | help = "Calls 911 dispatch", 9 | usage = "/911 [message]", 10 | args = {{name = "message", help = "Message to send"}}, 11 | cb = function(source, message, command, _) 12 | if SETTINGS.use_vrp then 13 | local users = vRP.getUsersByPermission({"police.pc"}) 14 | local alerted = 0 15 | for _, user in next, users do 16 | alerted = alerted + 1 17 | TriggerClientEvent("chat:addMessage", user, {args = {command.title, message}, color = command.color}) 18 | end 19 | TriggerClientEvent("chat:addMessage", source, {args = {command.title, (alerted > 0 and "Your message has been sent" or "No available dispatch")}, color = command.color}) 20 | elseif SETTINGS.use_esx then 21 | local xPlayers = ESX.GetPlayers() 22 | local alerted = 0 23 | for i=1, #xPlayers, 1 do 24 | local xPlayer = ESX.GetPlayerFromId(xPlayers[i]) 25 | if xPlayer.job.name == 'police' or xPlayer.job.name == 'ambulance' then 26 | alerted = alerted + 1 27 | TriggerClientEvent("chat:addMessage", xPlayers[i], {args = {command.title, message}, color = command.color}) 28 | end 29 | end 30 | TriggerClientEvent("chat:addMessage", source, {args = {command.title, (alerted > 0 and "Your message has been sent" or "No available dispatch")}, color = command.color}) 31 | else 32 | TriggerClientEvent("chat:addMessage", -1, {args = {command.title, message}, color = command.color}) 33 | end 34 | end, 35 | }, 36 | }, { 37 | -- Default values, in this case the info text and color in chat 38 | hidden = true, 39 | title = "[911 Dispatch]", 40 | color = {200, 0, 0}, 41 | }, { 42 | -- Aliases 43 | {"dispatch", "911"}, 44 | {"999", "911"}, 45 | {"112", "911"}, 46 | }) 47 | -------------------------------------------------------------------------------- /examples/cmds_admin.lua: -------------------------------------------------------------------------------- 1 | -- A simple announcement command locked behind administrator access. 2 | CommandPack("Administrator Commands Example", "glitchdetector", { 3 | -- Add commands here 4 | -- Administrator Announcement 5 | { 6 | command = "announce", 7 | format = "#message#", 8 | title = "ADMINISTRATOR ANNOUNCEMENT", 9 | help = "Administrator Announcement", 10 | usage = "/announce [announcement]", 11 | args = {{name = "announcement", help = "The message to announce"}}, 12 | color = {255, 0, 0}, 13 | }, 14 | }, { 15 | -- Default values, if one is not specified for the command 16 | admin = true, 17 | noperm = "You do not have permission to use this command.", 18 | }) 19 | -------------------------------------------------------------------------------- /examples/cmds_direct_message.lua: -------------------------------------------------------------------------------- 1 | -- A simple DM / SMS system with a reply feature. 2 | -- Save previous messager for reply command 3 | local PreviousMessager = {} 4 | CommandPack("Direct Messaging", "glitchdetector", { 5 | -- Add commands here 6 | -- An SMS command 7 | { 8 | command = "sms", 9 | format = "#message#", 10 | help = "Send an SMS to a player", 11 | usage = "/sms [player] [message]", 12 | args = {{name = "player", help = "ID of receiving player"}, {name = "message", help = "The SMS contents"}}, 13 | cb = function(source, message, _, args) 14 | local receiver = tonumber(args[1]) 15 | if receiver and GetPlayerName(receiver) then 16 | PreviousMessager[receiver] = source 17 | message = message:sub(#args[1]+1) 18 | TriggerClientEvent("chat:addMessage", source, { 19 | args = {(("^*^5(SMS to %s (%s)) ^r^7%s"):format(GetPlayerName(receiver), receiver, message))}, 20 | }) 21 | TriggerClientEvent("chat:addMessage", receiver, { 22 | args = {(("^*^5(SMS from %s (%s)) ^r^7%s"):format(GetPlayerName(source), source, message))}, 23 | }) 24 | else 25 | -- Malformed ID 26 | TriggerClientEvent("chat:addMessage", source, { 27 | args = {"This player does not exist"}, 28 | }) 29 | end 30 | end, 31 | }, 32 | -- Reply command 33 | { 34 | command = "reply", 35 | format = "#message#", 36 | help = "Reply to your last SMS", 37 | usage = "/reply [message]", 38 | args = {{name = "message", help = "The SMS contents"}}, 39 | cb = function(source, message, _, args) 40 | local receiver = PreviousMessager[source] 41 | if receiver and GetPlayerName(receiver) then 42 | PreviousMessager[receiver] = source 43 | TriggerClientEvent("chat:addMessage", source, { 44 | args = {(("^*^5(SMS to %s (%s)) ^r^7%s"):format(GetPlayerName(receiver), receiver, message))}, 45 | }) 46 | TriggerClientEvent("chat:addMessage", receiver, { 47 | args = {(("^*^5(SMS from %s (%s)) ^r^7%s"):format(GetPlayerName(source), source, message))}, 48 | }) 49 | else 50 | -- No previous conversation 51 | TriggerClientEvent("chat:addMessage", source, { 52 | args = {"This player does not exist"}, 53 | }) 54 | end 55 | end, 56 | }, 57 | }, { 58 | -- Default values, if one is not specified for the command 59 | hidden = true, 60 | }, { 61 | -- Aliases 62 | {"m", "sms"}, 63 | {"r", "reply"}, 64 | }) 65 | -------------------------------------------------------------------------------- /examples/cmds_example_pack.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | Command parameters: 3 | - command: the name of the command as used in chat, without the / 4 | - format: how the message appears 5 | #name#: is replaced with the players name (and ID depending on settings) 6 | #message#: is replaced with the message sent by the player 7 | #time#: is replaced with the current timestamp 8 | - title (optional): same as format, but appears as the message sender 9 | - color (optional): table with RGB, used with title (default is {255, 255, 255}) 10 | - help (optional): help text for the command 11 | - usage (optional): shown when no text is sent with the command 12 | - range (optional): maximum distance for receiving players (-1 or not specified means global range) 13 | 14 | Advanced parameters: 15 | - hidden (optional): if true, the message is not shown in chat 16 | - cb (optional): callback function with (source, message, command, args, raw) parameters 17 | - prereq (optional): function with (source, command, args, raw), returns wether the command can be executed or not 18 | - noperm (optional) message that is shown if the prereq fails 19 | - admin (optional): if true, only ACE administrators can use this 20 | 21 | Extra notes: 22 | - You do not need to use any of the formatted parameters, such as #name#, #message# etc. 23 | - If show_id is turned on in settings, the players SOURCE ID will appear with the name automatically 24 | ]] 25 | 26 | -- This is just an example pack, do not use this for a server. 27 | 28 | CommandPack("Example Pack", "glitchdetector", { 29 | -- Simple OOC command, using the only two required parameters 30 | { 31 | command = "ex_ooc", 32 | format = "^9[[[ OOC #name# #message# ]]]", 33 | }, 34 | -- A /me command with range and help information 35 | { 36 | command = "ex_me", 37 | format = "^6* #name# #message#", 38 | help = "Personal action", 39 | usage = "/me [action]", 40 | args = {{name = "action", help = "The action you're performing"}}, 41 | range = 50.0, 42 | }, 43 | -- Admin only announcement command (can only be used by ACE administrators), the administrator name is not shown 44 | { 45 | command = "ex_adminge", 46 | format = "#message#", 47 | title = "ADMINISTRATOR ANNOUNCEMENT", 48 | color = {255, 0, 0}, 49 | admin = true, 50 | }, 51 | }, { 52 | -- Default values, if one is not specified for the command 53 | -- We don't need to specify any default values here for this example 54 | }) 55 | -------------------------------------------------------------------------------- /examples/cmds_info.lua: -------------------------------------------------------------------------------- 1 | -- Commands that give the player some information, such as Discord invites etc. (must be configured) 2 | CommandPack("Information Commands", "glitchdetector", { 3 | -- Add commands here 4 | -- Simple /discord command that replies with the current discord invite 5 | { 6 | command = "discord", 7 | title = "Discord Link", 8 | reply = "https://discord.gg/mynewfxserver", 9 | help = "Get the discord invite link", 10 | }, 11 | -- Simple /teamspeak command that replies with the teamspeak IP 12 | { 13 | command = "teamspeak", 14 | title = "TeamSpeak IP", 15 | reply = "e621.teamspeak.leet", 16 | help = "Get the teamspeak IP", 17 | }, 18 | -- Simple /forum command that replies with the forum URL 19 | { 20 | command = "forum", 21 | title = "Forum Link", 22 | reply = "https://www.mynewfxserver.com", 23 | help = "Check out our forum!", 24 | }, 25 | }, { 26 | -- Default values, in this case the info text and color in chat 27 | color = {0, 0, 200}, 28 | }) 29 | -------------------------------------------------------------------------------- /examples/cmds_police.lua: -------------------------------------------------------------------------------- 1 | -- Example pack that utilizes a check for the police job in both vRP and ESX, no ACE permission since there's no "police" oncept in base FXS 2 | CommandPack("Police Requirement Example", "glitchdetector", { 3 | -- Add commands here 4 | -- Check if you are a valid police officer 5 | { 6 | command = "polcheck", 7 | reply = "You are a police officer!", 8 | }, 9 | -- Speak via police megaphone 10 | { 11 | command = "polmega", 12 | usage = "/polmega [message]", 13 | help = "Speak loudly through your megaphone", 14 | args = {{name = "message", help = "Message to send"}}, 15 | format = "^4^*#message#", 16 | range = 25.0, 17 | } 18 | }, { 19 | -- Default values 20 | prereq = function(source) 21 | if SETTINGS.use_vrp then 22 | local user_id = vRP.getUserId({source}) 23 | return vRP.hasPermission({user_id, "police.service"}) -- Most Police jobs in Dunko's vRP uses police.service 24 | elseif SETTINGS.use_esx then 25 | local xPlayer = ESX.GetPlayerFromId(source) 26 | return xPlayer.job.name == 'police' -- No clue if there's a way to check multiple jobs without "or"-ing them all 27 | end 28 | return false 29 | end, 30 | noperm = "You are not a police officer!", 31 | }) 32 | -------------------------------------------------------------------------------- /examples/cmds_rack.lua: -------------------------------------------------------------------------------- 1 | -- Implementation of: 2 | -- https://forum.fivem.net/t/release-unrack-and-rack-simple-reply-script/108735 3 | -- Simple /rack /unrack reply script 4 | CommandPack("Rifle Racking / Unracking", "glitchdetector", { 5 | -- Add commands here 6 | -- Unrack your rifle 7 | { 8 | command = "unrack", 9 | format = "^*^6* #name# unracks rifle from their car!", 10 | help = "Unrack rifle from your car", 11 | cb = function(source, _, _, args) 12 | local message = "* unracks rifle from their car *" 13 | TriggerClientEvent("chat_commands:showFloatingText", -1, source, message) 14 | end, 15 | }, 16 | -- Rack your rifle 17 | { 18 | command = "rack", 19 | format = "^*^6* #name# racks rifle back into their car!", 20 | help = "Unrack rifle from your car", 21 | cb = function(source, _, _, args) 22 | local message = "* racks rifle back into their car *" 23 | TriggerClientEvent("chat_commands:showFloatingText", -1, source, message) 24 | end, 25 | }, 26 | }, { 27 | -- Default values 28 | noargs = true, -- Doesn't take any arguments 29 | range = 50.0, 30 | }, { 31 | -- Aliases 32 | {"grab", "unrack"}, 33 | {"away", "rack"}, 34 | }) 35 | -------------------------------------------------------------------------------- /examples/cmds_report.lua: -------------------------------------------------------------------------------- 1 | -- Dependencies: 2 | -- https://forum.fivem.net/t/release-fivem-to-discord/62618 3 | -- A command that sends a report to your Discord using @flatracer’s FiveM to Discord resource: 4 | CommandPack("Report Pack", "glitchdetector", { 5 | -- Add commands here 6 | -- Report command, sends a message to Discord 7 | { 8 | command = "report", 9 | format = "#message#", 10 | help = "Report an issue to the staff team", 11 | usage = "/report [issue]", 12 | args = {{name = "issue", help = "Your issue"}}, 13 | hidden = true, -- Prevents the message from being shown in chat 14 | cb = function(source, message) 15 | -- Sends a message to discord using the FiveM to Discord resource 16 | TriggerEvent('DiscordBot:ToDiscord', 'system', ('%s (%s) reports an issue'):format(GetPlayerName(source), source), message, 'https://wiki.fivem.net/w/images/d/db/FiveM-Wiki.png', true) 17 | end, 18 | }, 19 | }, { 20 | -- Default values 21 | }) 22 | -------------------------------------------------------------------------------- /examples/cmds_roleplay_toolkit.lua: -------------------------------------------------------------------------------- 1 | -- An essential roleplay command kit. No configuration required. 2 | CommandPack("Roleplay Toolkit", "glitchdetector", { 3 | -- Add commands here 4 | -- Global Out of Character chat 5 | { 6 | command = "ooc", 7 | format = "^*^2[[[ OOC #username# #message# ]]]", 8 | help = "Global out of character chat", 9 | usage = "/ooc [message]", 10 | args = {{name = "message", help = "An out of character message"}}, 11 | }, 12 | -- Global in-character tweet 13 | { 14 | command = "tweet", 15 | format = "^*^5[#char# @#username#] ^r^7#message#", 16 | help = "Twitter message", 17 | usage = "/tweet [message]", 18 | args = {{name = "message", help = "Tweet message"}}, 19 | }, 20 | -- Local Out of Character chat 21 | { 22 | command = "looc", 23 | format = "^*^2[ Local OOC #username# #message# ]", 24 | help = "Local out of character chat", 25 | usage = "/looc [message]", 26 | args = {{name = "message", help = "An out of character message"}}, 27 | range = 50.0, 28 | }, 29 | -- A /me command with range and help information 30 | { 31 | command = "me", 32 | format = "^*^6* #name# #message#", 33 | help = "Personal action", 34 | usage = "/me [action]", 35 | args = {{name = "action", help = "The action you're performing"}}, 36 | range = 50.0, 37 | cb = function(source, _, _, args) 38 | local message = "* " .. table.concat(args, " ") .. " *" 39 | TriggerClientEvent("chat_commands:showFloatingText", -1, source, message) 40 | end, 41 | }, 42 | }, { 43 | -- Default values, if one is not specified for the command 44 | }, { 45 | -- Aliases 46 | {"twt", "tweet"}, 47 | {"b", "looc"}, 48 | {"do", "me"}, 49 | }) 50 | -------------------------------------------------------------------------------- /examples/info: -------------------------------------------------------------------------------- 1 | -- These files are example command packs -- 2 | Some of them serve a specific purpose, some of them are only examples. 3 | --------------------------------------------------------------------------------