├── CHANGELOG.md
├── LICENSE
├── README.md
├── VERSION
├── __resource.lua
└── src
├── area
├── area.client.lua
└── areas.client.lua
├── blip
├── blip.client.lua
└── blips.client.lua
├── entity
├── entity.client.lua
├── object.client.lua
├── ped.client.lua
├── pickup.client.lua
├── player.client.lua
└── vehicle.client.lua
├── load.client.lua
├── marker
├── marker.client.lua
└── markers.client.lua
├── menu
├── menu.client.lua
└── menus.client.lua
├── trigger
├── trigger.client.lua
└── triggers.client.lua
├── ui
├── instructionalButtons.client.lua
└── ui.client.lua
└── utils
├── utils.client.lua
├── utils.common.lua
└── utils.server.lua
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 | All notable changes to this project will be documented in this file.
3 |
4 | ## [Released]
5 |
6 | ## [1.2.2] - 2018-11-11
7 | ### Changed
8 | - Fix playerCoords
9 | - Add client export for GetVehicleInDirection function
10 |
11 | ## [1.2.1] - 2018-10-09
12 | ### Changed
13 | - Fix enable on Area
14 |
15 | ## [1.2] - 2018-10-08
16 | ### Added
17 | - Implement GetPlayerPed function
18 | - Implement GetPlayerCoords function
19 | - Implement GetDistanceBetween3DCoords function
20 | - Implement GetObjects function
21 | - Implement GetPeds function
22 | - Implement GetVehicles function
23 | - Implement GetPickups function
24 | - Implement GetEntityInDirection function
25 | - Implement GetEntityObjectInDirection function
26 | - Implement GetPedInDirection function
27 | - Implement GetPlayerPedInDirection function
28 | - Implement GetPlayerServerIdInDirection function
29 | - Implement GetVehicleInDirection function
30 | - Implement GetObjectInDirection function
31 | - Implement GetEntitiesInArea function
32 | - Implement GetObjectsInArea function
33 | - Implement GetPedsInArea function
34 | - Implement GetPickupsInArea function
35 | - Implement GetVehiclesInArea function
36 | - Implement GetEntitiesInAround function
37 | - Implement GetObjectsInAround function
38 | - Implement GetPedsInAround function
39 | - Implement GetPickupsInAround function
40 | - Implement GetVehiclesInAround function
41 | - Implement GetPlayersPed function
42 | - Implement GetPlayersId function
43 | - Implement GetPlayersPedOrderById function
44 | - Implement GetEntitiesInAround function
45 | - Add client export for GetPlayerPed function
46 | - Add client export for GetPlayerCoords function
47 | - Add client export for GetDistanceBetween3DCoords function
48 | - Add client export for GetObjects function
49 | - Add client export for GetPeds function
50 | - Add client export for GetVehicles function
51 | - Add client export for GetPickups function
52 | - Add client export for GetEntityInDirection function
53 | - Add client export for GetEntityObjectInDirection function
54 | - Add client export for GetPedInDirection function
55 | - Add client export for GetPlayerPedInDirection function
56 | - Add client export for GetPlayerServerIdInDirection function
57 | - Add client export for GetVehicleInDirection function
58 | - Add client export for GetObjectInDirection function
59 | - Add client export for GetEntitiesInArea function
60 | - Add client export for GetObjectsInArea function
61 | - Add client export for GetPedsInArea function
62 | - Add client export for GetPickupsInArea function
63 | - Add client export for GetVehiclesInArea function
64 | - Add client export for GetEntitiesInAround function
65 | - Add client export for GetObjectsInAround function
66 | - Add client export for GetPedsInAround function
67 | - Add client export for GetPickupsInAround function
68 | - Add client export for GetVehiclesInAround function
69 | - Add client export for GetPlayersPed function
70 | - Add client export for GetPlayersId function
71 | - Add client export for GetPlayersPedOrderById function
72 | - Add client export for Clone function
73 | - Add client export for Copy function
74 | - Add client export for GetEntitiesInAround function
75 | - Add server export for Copy function
76 | - Add server export for SetDebug function
77 |
78 | ### Changed
79 | - Optimization and refactoring Areas functions
80 | - Optimization and refactoring Trigger functions
81 | - Optimization and refactoring Marker functions
82 | - Raname TablePrint function on PrintTable
83 | - Rename ft_libs:TablePrint event on ft_libs:PrintTable
84 | - Add lock option on buttons for menu
85 |
86 | ## [1.1] - 2018-00-00
87 | ### Added
88 | - Implement selecteButton function pushed by @THEJean-Kevin
89 | - Add variable defaultButtonPosition pushed by @THEJean-Kevin
90 | - Rename selecteButton function to SelecteButton
91 | - Refactoring SelecteButton function
92 | - Refactoring variable defaultButtonPosition
93 | - Implement DPrint function pushed by @izio38
94 | - Implement DebugPrint function pushed by @izio38
95 | - Refactoring DPrint function
96 | - Remane DPrint function to DebugPrint
97 | - Implement SetArea function
98 | - Implement SetBlip function
99 | - Implement SetMarker function
100 | - Implement SetTrigger function
101 | - Implement GetRandomString function
102 | - Add client event ft_libs:DebugMode
103 | - Add client export for DebugPrint function
104 | - Add client export for SetDebug function
105 | - Add client export for SetArea function
106 | - Add client export for SetBlip function
107 | - Add client export for SetMarker function
108 | - Add client export for SetTrigger function
109 | - Add client export for SelecteButton function
110 | - Add client export for GetRandomString function
111 | - Add server export for DebugPrint function
112 | - Add server export for GetRandomString function
113 |
114 | ### Changed
115 | - Rename CurrentMenu in GetCurrentMenu
116 | - Refactoring menu
117 | - Implement multiple table in call CleanMenuButtons function
118 | - Implement multiple table in call SetMenuButtons function
119 | - Implement multiple table in call SetMenuValue function
120 | - Implement multiple table in call AddMenuButton function
121 | - Implement multiple table in call RemoveMenuButton function
122 | - Add default text on butons in menu is empty
123 | - Add Citizen.Wait on AddMenuButton function
124 | - Change variable name on AddMenuButton function
125 | - Rename file client.client to load.client.lua
126 | - Change event ft_libs:PrintTable to ft_libs:TablePrint
127 | - Add source on header in all files
128 | - Replace Citizen.Trace to print on PrintTable function
129 | - Add customTitle on DebugPrint function
130 | - Rename variables steamID to identifier on GetSteamIDFormSource
131 | - Add check on AddArea if areas exist
132 | - Add check on AddMarker if marker exist
133 | - Add check on AddBlip if blip exist
134 | - Add check on AddTrigger if trigger exist
135 |
136 | ## [1.0] - 2018-07-19
137 | ### Added
138 | - Implement GetSteamIDFormSource function
139 | - Implement GetIpFormSource function
140 | - Implement Copy function
141 | - Implement Clone function
142 | - Implement Clone function
143 | - Add server export for GetSteamIDFormSource function
144 | - Add server export for GetIpFormSource function
145 |
146 | ### Changed
147 | - Global refactoring and optimization
148 | - Add continuously up or down for menu
149 | - Add resource_manifest_version
150 | - Fix Areas exports
151 | - Change variables name for areas
152 | - Fix clone variable on Areas
153 | - Add customTitle on OpenTextInput function
154 | - Change Citizen.Wait on OpenTextInput function
155 | - Change Citizen.Wait on Marker functions
156 | - Change Citizen.Wait on Trigger functions
157 | - Add Wrap variable on Text function
158 |
159 | ### Removed
160 | - Remove one frame system
161 |
162 | ## [Pre-Released]
163 |
164 | ## [0.7] - 2018-03-17
165 | ### Added
166 | - Implement Areas functions
167 | - Add client export for AddAreas function
168 | - Add client export for RemoveAreas function
169 | - Add client export for EnableAreas function
170 | - Add client export for DisableAreas function
171 | - Add client export for SwitchAreas function
172 | - Add client export for PrimaryMenu function
173 | - Add client export for AdvancedNotification function
174 |
175 | ### Changed
176 | - Add primarymenu variable on menu
177 | - Fix variable on Text function
178 | - Fix menu display
179 | - Fix blip rotation
180 | - Fix variables on menu
181 | - Refactoring and optimize marker
182 | - Fix currentMarker on marker
183 | - Refactoring and optimize blip
184 | - Fix error on blip
185 | - Refactoring and optimize area
186 |
187 | ### Removed
188 | - Clear all Citizen.Trace
189 |
190 | ## [0.6] - 2018-03-01
191 | ### Added
192 | - Implement Maker functions
193 | - Add client export for AddMarker function
194 | - Add client export for RemoveMarker function
195 | - Add client export for EnableMarker function
196 | - Add client export for DisableMarker function
197 | - Add client export for SwitchMarker function
198 | - Add client export for CurrentMarker function
199 |
200 | ## [0.5] - 2018-02-27
201 | ### Added
202 | - Implement Triggers functions
203 | - Add client export for AddTrigger function
204 | - Add client export for RemoveTrigger function
205 | - Add client export for SwitchTrigger function
206 | - Add client export for EnableTrigger function
207 | - Add client export for DisableTrigger function
208 | - Add client export for CurrentTrigger function
209 |
210 | ## [0.4] - 2018-02-26
211 | ### Added
212 | - Implement Blip functions
213 | - Add client export for AddBlip function
214 | - Add client export for RemoveBlip function
215 | - Add client export for ShowBlip function
216 | - Add client export for HideBlip function
217 |
218 | ### Changed
219 | - Add check for settings.center in Text function
220 |
221 | ## [0.3] - 2018-02-24
222 | ### Added
223 | - Implement Menu functions
224 | - Add client export for AddMenu function
225 | - Add client export for RemoveMenu function
226 | - Add client export for AddMenu function
227 | - Add client export for MenuIsOpen function
228 | - Add client export for CurrentMenu function
229 | - Add client export for FreezeMenu function
230 | - Add client export for OpenMenu function
231 | - Add client export for CloseMenu function
232 | - Add client export for NextMenu function
233 | - Add client export for BackMenu function
234 | - Add client export for CleanMenuButtons function
235 | - Add client export for SetMenuButtons function
236 | - Add client export for SetMenuValue function
237 | - Add client export for AddMenuButton function
238 | - Add client export for RemoveMenuButton function
239 |
240 | ## [0.2] - 2018-02-11
241 | ### Added
242 | - Implement TableLength function
243 | - Implement Round function
244 | - Implement CommaValue function
245 | - Implement GetEntityDirection function
246 | - Implement OpenTextInput function
247 | - Implement TextNotification function
248 | - Implement client event ft_libs:TextNotification
249 | - Implement server event ft_libs:PrintTable
250 | - Implement send event ft_libs:OnClientReady for client
251 | - Implement send event ft_libs:OnClientReady for server
252 | - Add client export for TableLength function
253 | - Add client export for Round function
254 | - Add client export forCommaValue function
255 | - Add client export for GetEntityDirection function
256 | - Add client export for OpenTextInput function
257 | - Add client export for TextNotification function
258 | - Add server export for Round function
259 |
260 | ### Changed
261 | - Change variable names for OpenTextInput
262 |
263 | ## [0.1] - 2018-02-04
264 | ### Added
265 | - Implement HelpPromt function
266 | - Implement LoadingPromt function
267 | - Implement Notification function
268 | - Implement AdvancedNotification function
269 | - Implement OpenTextInput function
270 | - Implement Text function
271 | - Implement client event ft_libs:AdvancedNotification
272 | - Implement client event ft_libs:Notification
273 | - Add client export for HelpPromt function
274 | - Add client export for LoadingPromt function
275 | - Add client export for Notification function
276 | - Add client export for OpenTextInput function
277 | - Add client export for Text function
278 | - Adding a readme with instructions and links
279 | - Implement one frame for all check function
280 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ft_libs
2 |
3 | ### Prerequisites
4 |
5 | Nothing
6 |
7 | ### Installing
8 |
9 | Put the folder where you want it and add it to the server.cfg file :
10 |
11 | Example:
12 |
13 | ```
14 | start ft_libs
15 | ```
16 |
17 | or put in to dependencies in __resource.lua :
18 |
19 | ```
20 | dependency 'ft_libs'
21 |
22 | or
23 |
24 | dependencies {
25 | ...
26 | 'ft_libs',
27 | ...
28 | }
29 |
30 | ```
31 |
32 | ### Documentation
33 |
34 | [Online](https://fivemtools-libs.readme.io/v1.2/)
35 |
36 | ## License
37 |
38 | This project is licensed under the GNU General Public License v3.0 - see the [LICENSE](LICENSE) file for details
39 |
40 | ## Contributors :
41 |
42 | - LH-Lawliet
43 | - THEJean-Kevin
44 | - izio38
45 |
--------------------------------------------------------------------------------
/VERSION:
--------------------------------------------------------------------------------
1 | 1.2.2
--------------------------------------------------------------------------------
/__resource.lua:
--------------------------------------------------------------------------------
1 | --
2 | -- @Project: FiveM Tools
3 | -- @Author: Samuelds
4 | -- @License: GNU General Public License v3.0
5 | -- @Source: https://github.com/FivemTools/ft_libs
6 | --
7 |
8 | resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937'
9 |
10 | client_scripts {
11 |
12 | -- Utils
13 | "src/utils/utils.common.lua",
14 | "src/utils/utils.client.lua",
15 |
16 | -- Ui
17 | "src/ui/ui.client.lua",
18 | "src/ui/instructionalButtons.client.lua",
19 |
20 | -- Menu
21 | "src/menu/menu.client.lua",
22 | "src/menu/menus.client.lua",
23 |
24 | -- Blip
25 | "src/blip/blip.client.lua",
26 | "src/blip/blips.client.lua",
27 |
28 | -- Trigger
29 | "src/trigger/trigger.client.lua",
30 | "src/trigger/triggers.client.lua",
31 |
32 | -- Marker
33 | "src/marker/marker.client.lua",
34 | "src/marker/markers.client.lua",
35 |
36 | -- Area
37 | "src/area/area.client.lua",
38 | "src/area/areas.client.lua",
39 |
40 | -- Event 100% load
41 | "src/load.client.lua",
42 |
43 | -- Entity
44 | "src/entity/entity.client.lua",
45 | "src/entity/object.client.lua",
46 | "src/entity/ped.client.lua",
47 | "src/entity/pickup.client.lua",
48 | "src/entity/player.client.lua",
49 | "src/entity/vehicle.client.lua",
50 |
51 | }
52 |
53 | exports {
54 |
55 | -- Utils
56 | "TableLength",
57 | "Round",
58 | "CommaValue",
59 | "SetDebug",
60 | "Print",
61 | "PrintTable",
62 | "TableContainsValue",
63 | "GetLastContentValue",
64 | "GetRandomString",
65 | "GetDistanceBetween3DCoords",
66 | "PrintTable",
67 | "Copy",
68 | "Clone",
69 |
70 | -- Ui
71 | "HelpPromt",
72 | "LoadingPromt",
73 | "Message",
74 | "Notification",
75 | "AdvancedNotification",
76 | "Text",
77 | "OpenTextInput",
78 | "TextNotification",
79 | "Show3DText",
80 |
81 | -- Instructional Buttons
82 | "AddInstructionalButtons",
83 | "RemoveInstructionalButtons",
84 | "DisplayInstructionalButtons",
85 | "GetCurrentInstructionalButtons",
86 |
87 | -- Menu
88 | "AddMenu",
89 | "RemoveMenu",
90 | "MenuIsOpen",
91 | "PrimaryMenu",
92 | "GetCurrentMenu",
93 | "GetPrimaryMenu",
94 | "FreezeMenu",
95 | "OpenMenu",
96 | "CloseMenu",
97 | "NextMenu",
98 | "BackMenu",
99 | "CleanMenuButtons",
100 | "SetMenuButtons",
101 | "SetMenuValue",
102 | "AddMenuButton",
103 | "RemoveMenuButton",
104 | "SelecteButton",
105 |
106 | -- Blip
107 | "AddBlip",
108 | "RemoveBlip",
109 | "ShowBlip",
110 | "HideBlip",
111 |
112 | -- Trigger
113 | "AddTrigger",
114 | "RemoveTrigger",
115 | "SwitchTrigger",
116 | "EnableTrigger",
117 | "DisableTrigger",
118 | "CurrentTrigger",
119 |
120 | -- Marker
121 | "AddMarker",
122 | "RemoveMarker",
123 | "EnableMarker",
124 | "DisableMarker",
125 | "SwitchMarker",
126 | "CurrentMarker",
127 |
128 | -- Areas
129 | "AddArea",
130 | "RemoveArea",
131 | "EnableArea",
132 | "DisableArea",
133 | "SwitchArea",
134 |
135 | -- Debug
136 | "SetDebug",
137 | "DebugPrint",
138 |
139 | -- Entity
140 | "GetEntitiesInArea",
141 | "GetEntityInDirection",
142 | "GetEntityObjectInDirection",
143 | "GetEntitiesInAround",
144 | "CastRayPlayerPedToPoint",
145 |
146 | -- Objects
147 | "GetObjects",
148 | "GetObjectsInArea",
149 | "GetObjectsInAround",
150 | "GetObjectInDirection",
151 |
152 | -- Peds
153 | "GetPeds",
154 | "GetPedsInArea",
155 | "GetPedsInAround",
156 | "GetPedInDirection",
157 |
158 | -- Vehicules
159 | "GetVehicles",
160 | "GetVehiclesInArea",
161 | "GetVehiclesInAround",
162 | "GetVehicleInDirection",
163 |
164 | -- Vehicules
165 | "GetPickups",
166 | "GetPickupsInArea",
167 | "GetPickupsInAround",
168 |
169 | -- Player
170 | "GetPlayerPed",
171 | "GetPlayersId",
172 | "GetPlayersPed",
173 | "GetPlayerCoords",
174 | "GetPlayersPedOrderById",
175 | "GetPlayerPedInDirection",
176 | "GetPlayerServerIdInDirection",
177 |
178 | }
179 |
180 | server_scripts {
181 |
182 | -- Utils
183 | "src/utils/utils.common.lua",
184 | "src/utils/utils.server.lua",
185 |
186 | }
187 |
188 | server_exports {
189 |
190 | -- Utils
191 | "TableLength",
192 | "PrintTable",
193 | "Round",
194 | "GetSteamIDFormSource",
195 | "GetIpFormSource",
196 | "TableContainsValue",
197 | "GetLastContentValue",
198 | "DebugPrint",
199 | "SetDebug",
200 | "GetRandomString",
201 | "Copy",
202 | "Clone",
203 |
204 | }
205 |
--------------------------------------------------------------------------------
/src/area/area.client.lua:
--------------------------------------------------------------------------------
1 | --
2 | -- @Project: FiveM Tools
3 | -- @Author: Samuelds
4 | -- @License: GNU General Public License v3.0
5 | -- @Source: https://github.com/FivemTools/ft_libs
6 | --
7 |
8 | --
9 | area = {}
10 |
11 | -- class table
12 | local Area = {}
13 |
14 | --
15 | -- Enable Area
16 | --
17 | function Area:Enable()
18 |
19 | EnableMarker(self.name)
20 | EnableTrigger(self.name)
21 | ShowBlip(self.name)
22 |
23 | end
24 |
25 | --
26 | -- Disable Area
27 | --
28 | function Area:Disable()
29 |
30 | DisableMarker(self.name)
31 | DisableTrigger(self.name)
32 | HideBlip(self.name)
33 |
34 | end
35 |
36 | --
37 | -- Remove Area
38 | --
39 | function Area:Remove()
40 |
41 | RemoveMarker(self.name)
42 | RemoveTrigger(self.name)
43 | RemoveBlip(self.name)
44 |
45 | end
46 |
47 | --
48 | -- Create new instace of Area
49 | --
50 | function area.new(name, data)
51 |
52 | assert(type(name) == "string", "Area : name must be text")
53 |
54 | local self = data
55 | self.name = name
56 |
57 | -- Trigger
58 | if data.trigger ~= nil then
59 | local triggerData = data.trigger
60 | triggerData.enable = self.enable
61 | triggerData.x = data.x
62 | triggerData.y = data.y
63 | triggerData.z = data.z
64 | self.area = AddTrigger(name, triggerData)
65 | end
66 |
67 | -- Blip
68 | if data.blip ~= nil then
69 | local blipData = data.blip
70 | blipData.enable = self.enable
71 | blipData.x = data.x
72 | blipData.y = data.y
73 | blipData.z = data.z
74 | self.blip = AddBlip(name, blipData)
75 | end
76 |
77 | -- Marker
78 | if data.marker ~= nil then
79 | local markerData = data.marker
80 | markerData.enable = self.enable
81 | markerData.x = data.x
82 | markerData.y = data.y
83 | markerData.z = data.z
84 | self.marker = AddMarker(name, markerData)
85 | end
86 |
87 | setmetatable(self, { __index = Area })
88 | return self
89 |
90 | end
91 |
--------------------------------------------------------------------------------
/src/area/areas.client.lua:
--------------------------------------------------------------------------------
1 | --
2 | -- @Project: FiveM Tools
3 | -- @Author: Samuelds
4 | -- @License: GNU General Public License v3.0
5 | -- @Source: https://github.com/FivemTools/ft_libs
6 | --
7 |
8 | local areas = {}
9 |
10 | --
11 | --
12 | --
13 | function EnableArea(...)
14 |
15 | local args = {...}
16 | local count = #args
17 |
18 | if count == 1 and type(args[1]) == "table" then
19 |
20 | for _, name in ipairs(args[1]) do
21 |
22 | if areas[name] ~= nil then
23 | for _, area in pairs(areas[name]) do
24 | area:Enable()
25 | area.enable = true
26 | Citizen.Wait(10)
27 | end
28 | end
29 | Citizen.Wait(10)
30 |
31 | end
32 |
33 | elseif count == 1 then
34 |
35 | local name = args[1]
36 | if areas[name] ~= nil then
37 | for _, area in pairs(areas[name]) do
38 | area:Enable()
39 | area.enable = true
40 | Citizen.Wait(10)
41 | end
42 | end
43 |
44 | end
45 |
46 | end
47 |
48 | --
49 | --
50 | --
51 | function DisableArea(...)
52 |
53 | local args = {...}
54 | local count = #args
55 |
56 | if count == 1 and type(args[1]) == "table" then
57 |
58 | for _, name in ipairs(args[1]) do
59 |
60 | if areas[name] ~= nil then
61 | for _, area in pairs(areas[name]) do
62 | area:Disable()
63 | area.enable = false
64 | Citizen.Wait(10)
65 | end
66 | end
67 | Citizen.Wait(10)
68 |
69 | end
70 |
71 | elseif count == 1 then
72 |
73 | local name = args[1]
74 | if areas[name] ~= nil then
75 | for _, area in pairs(areas[name]) do
76 | area:Disable()
77 | area.enable = false
78 | Citizen.Wait(10)
79 | end
80 | end
81 |
82 | end
83 |
84 | end
85 |
86 | --
87 | --
88 | --
89 | function SwitchArea(...)
90 |
91 | local args = {...}
92 | local count = #args
93 |
94 | if count == 1 and type(args[1]) == "table" then
95 |
96 | for name, status in ipairs(args[1]) do
97 |
98 | if areas[name] ~= nil then
99 | if status == true then
100 | EnableArea(name)
101 | elseif status == false then
102 | DisableArea(name)
103 | end
104 | end
105 | Citizen.Wait(10)
106 |
107 | end
108 |
109 | elseif count == 2 then
110 |
111 | local name = args[1]
112 | local status = args[2]
113 | if areas[name] ~= nil then
114 | for _, area in pairs(areas[name]) do
115 | if status == true then
116 | EnableArea(name)
117 | elseif status == false then
118 | DisableArea(name)
119 | end
120 | end
121 | end
122 |
123 | end
124 |
125 | end
126 |
127 | --
128 | --
129 | --
130 | function AddArea(...)
131 |
132 | local args = {...}
133 | local count = #args
134 | local array = {}
135 |
136 | if count == 1 and type(args[1]) == "table" then
137 |
138 | for name, value in pairs(args[1]) do
139 | if areas[name] == nil then
140 | areas[name] = {}
141 |
142 | local trigger = value.trigger
143 | local blip = value.blip
144 | local marker = value.marker
145 |
146 | for key, location in pairs(value.locations) do
147 | local newArea = {}
148 | newArea.x = location.x
149 | newArea.y = location.y
150 | newArea.z = location.z
151 | newArea.enable = value.enable
152 | newArea.blip = Copy(blip)
153 | newArea.marker = Copy(marker)
154 | newArea.trigger = Copy(trigger)
155 | areas[name][key] = area.new(name .. "_" .. key, newArea)
156 | Citizen.Wait(10)
157 | end
158 | end
159 | Citizen.Wait(10)
160 |
161 | end
162 |
163 | elseif count == 2 then
164 |
165 | local name = args[1]
166 | local value = args[2]
167 | if areas[name] == nil then
168 |
169 | areas[name] = {}
170 |
171 | local trigger = value.trigger
172 | local blip = value.blip
173 | local marker = value.marker
174 | for key, location in pairs(value.locations) do
175 | local newArea = {}
176 | newArea.x = location.x
177 | newArea.y = location.y
178 | newArea.z = location.z
179 | newArea.enable = value.enable
180 | newArea.blip = Copy(blip)
181 | newArea.marker = Copy(marker)
182 | newArea.trigger = Copy(trigger)
183 | areas[name][key] = area.new(name .. "_" .. key, newArea)
184 | Citizen.Wait(10)
185 | end
186 |
187 | end
188 |
189 | end
190 |
191 | end
192 |
193 | --
194 | --
195 | --
196 | function RemoveArea(...)
197 |
198 | local args = {...}
199 | local count = #args
200 | local array = {}
201 |
202 | if count == 1 and type(args[1]) == "table" then
203 |
204 | for _, name in ipairs(args[1]) do
205 |
206 | if areas[name] ~= nil then
207 |
208 | for _, area in pairs(areas[name]) do
209 | DisableArea(name)
210 | area:Remove()
211 | Citizen.Wait(10)
212 | end
213 |
214 | areas[name] = nil
215 | end
216 | Citizen.Wait(10)
217 |
218 | end
219 |
220 | elseif count == 1 then
221 |
222 | local name = args[1]
223 |
224 | if areas[name] ~= nil then
225 |
226 | for _, area in pairs(areas[name]) do
227 | DisableArea(name)
228 | area:Remove()
229 | Citizen.Wait(10)
230 | end
231 |
232 | areas[name] = nil
233 |
234 | end
235 |
236 | end
237 |
238 | end
239 |
240 | --
241 | -- Set areas values
242 | --
243 | function SetArea(...)
244 |
245 | local args = {...}
246 | local count = #args
247 |
248 | if count == 1 and type(args[1]) == "table" then
249 |
250 | for name, values in pairs(args[1]) do
251 | if areas[name] ~= nil then
252 |
253 | local area = Copy(areas[name])
254 | RemoveArea(name)
255 |
256 | local trigger = values.trigger or area.trigger
257 | local blip = values.blip or area.blip
258 | local marker = values.marker or area.marker
259 | local locations = values.locations or area.locations
260 | for key, location in pairs(locations) do
261 | local newArea = {}
262 | newArea.x = location.x
263 | newArea.y = location.y
264 | newArea.z = location.z
265 | newArea.enable = value.enable
266 | newArea.blip = Copy(blip)
267 | newArea.marker = Copy(marker)
268 | newArea.trigger = Copy(trigger)
269 | areas[name][key] = area.new(name .. "_" .. key, newArea)
270 | Citizen.Wait(10)
271 | end
272 |
273 | end
274 | Citizen.Wait(1)
275 | end
276 |
277 | elseif count == 2 then
278 |
279 | local name = args[1]
280 | local values = args[2]
281 | if areas[name] ~= nil then
282 |
283 | local area = Copy(areas[name])
284 | RemoveArea(name)
285 |
286 | local trigger = values.trigger or area.trigger
287 | local blip = values.blip or area.blip
288 | local marker = values.marker or area.marker
289 | local locations = values.locations or area.locations
290 | for key, location in pairs(locations) do
291 | local newArea = {}
292 | newArea.x = location.x
293 | newArea.y = location.y
294 | newArea.z = location.z
295 | newArea.enable = value.enable
296 | newArea.blip = Copy(blip)
297 | newArea.marker = Copy(marker)
298 | newArea.trigger = Copy(trigger)
299 | areas[name][key] = area.new(name .. "_" .. key, newArea)
300 | Citizen.Wait(10)
301 | end
302 |
303 | end
304 |
305 | end
306 |
307 | end
308 |
--------------------------------------------------------------------------------
/src/blip/blip.client.lua:
--------------------------------------------------------------------------------
1 | --
2 | -- @Project: FiveM Tools
3 | -- @Author: Samuelds
4 | -- @License: GNU General Public License v3.0
5 | -- @Source: https://github.com/FivemTools/ft_libs
6 | --
7 |
8 | --
9 | blip = {}
10 |
11 | -- class table
12 | local Blip = {}
13 |
14 | --
15 | -- Show Blip
16 | --
17 | function Blip:Show()
18 |
19 | self.blip = AddBlipForCoord(self.x, self.y, self.z)
20 | SetBlipSprite(self.blip, self.imageId)
21 | SetBlipAsShortRange(self.blip, self.shortRange)
22 | SetBlipColour(self.blip, self.colorId)
23 | SetBlipScale(self.blip, self.scale)
24 | BeginTextCommandSetBlipName("STRING")
25 | AddTextComponentString(self.text)
26 | EndTextCommandSetBlipName(self.blip)
27 | if self.rotation ~= nil then
28 | SetBlipRotation(self.blip, self.rotation)
29 | end
30 |
31 | end
32 |
33 | --
34 | -- Hide Blip
35 | --
36 | function Blip:Hide()
37 |
38 | if self.blip ~= nil then
39 | Citizen.InvokeNative(0x86A652570E5F25DD, Citizen.PointerValueIntInitialized(self.blip)) -- Use native REMOVE_BLIP
40 | end
41 |
42 | end
43 |
44 | --
45 | -- Create new instace of Marker
46 | --
47 | function blip.new(data)
48 |
49 | assert(type(data.x) == "number", "Blip : x must be number")
50 | assert(type(data.y) == "number", "Blip : y must be number")
51 | assert(type(data.text) == "string", "Blip : text must be text")
52 |
53 | local self = data
54 | self.blip = nil
55 | self.imageId = data.imageId or 1
56 | self.colorId = data.colorId or 0
57 | self.scale = data.scale or 1.0
58 |
59 | if data.shortRange == nil or type(data.shortRange) ~= "boolean" then
60 | self.shortRange = true
61 | end
62 |
63 | if data.enable == nil or type(data.enable) ~= "boolean" then
64 | self.enable = true
65 | end
66 |
67 | setmetatable(self, { __index = Blip })
68 | return self
69 |
70 | end
71 |
--------------------------------------------------------------------------------
/src/blip/blips.client.lua:
--------------------------------------------------------------------------------
1 | --
2 | -- @Project: FiveM Tools
3 | -- @Author: Samuelds
4 | -- @License: GNU General Public License v3.0
5 | -- @Source: https://github.com/FivemTools/ft_libs
6 | --
7 |
8 | local blips = {}
9 | local activeBlips = {}
10 |
11 | --
12 | --
13 | --
14 | function ShowBlip(...)
15 |
16 | local args = {...}
17 | local count = #args
18 |
19 | if count == 1 and type(args[1]) == "table" then
20 | for _, name in ipairs(args[1]) do
21 | Citizen.Wait(1)
22 | if blips[name] ~= nil and activeBlips[name] == nil then
23 | blips[name]:Show()
24 | blips[name].enable = true
25 | activeBlips[name] = true
26 | end
27 | end
28 | elseif count == 1 then
29 | local name = args[1]
30 | if blips[name] ~= nil and activeBlips[name] == nil then
31 | blips[name]:Show()
32 | blips[name].enable = true
33 | activeBlips[name] = true
34 | end
35 | end
36 |
37 | end
38 |
39 | --
40 | --
41 | --
42 | function HideBlip(...)
43 |
44 | local args = {...}
45 | local count = #args
46 |
47 | if count == 1 and type(args[1]) == "table" then
48 | for _, name in ipairs(args[1]) do
49 | Citizen.Wait(1)
50 | if blips[name] ~= nil and activeBlips[name] == true then
51 | blips[name]:Hide()
52 | blips[name].enable = false
53 | blips[name].blip = nil
54 | activeBlips[name] = nil
55 | end
56 | end
57 | elseif count == 1 then
58 | local name = args[1]
59 | if blips[name] ~= nil and activeBlips[name] == true then
60 | blips[name]:Hide()
61 | blips[name].enable = false
62 | blips[name].blip = nil
63 | activeBlips[name] = nil
64 | end
65 | end
66 |
67 | end
68 |
69 | --
70 | --
71 | --
72 | function AddBlip(...)
73 |
74 | local args = {...}
75 | local count = #args
76 |
77 | if count == 1 and type(args[1]) == "table" then
78 | for name, value in pairs(args[1]) do
79 | if blips[name] == nil then
80 | blips[name] = blip.new(value)
81 | if blips[name].enable then
82 | ShowBlip(name)
83 | end
84 | end
85 | Citizen.Wait(10)
86 | end
87 | elseif count == 2 then
88 | local name = args[1]
89 | local value = args[2]
90 | if blips[name] == nil then
91 | blips[name] = blip.new(value)
92 | if blips[name].enable then
93 | ShowBlip(name)
94 | end
95 | end
96 | end
97 |
98 | end
99 |
100 | --
101 | --
102 | --
103 | function RemoveBlip(...)
104 |
105 | local args = {...}
106 | local count = #args
107 |
108 | if count == 1 and type(args[1]) == "table" then
109 | for _, name in ipairs(args[1]) do
110 | if blips[name] ~= nil then
111 | HideBlip(name)
112 | blips[name] = nil
113 | end
114 | Citizen.Wait(10)
115 | end
116 | elseif count == 1 then
117 | local name = args[1]
118 | if blips[name] ~= nil then
119 | HideBlip(name)
120 | blips[name] = nil
121 | end
122 | end
123 |
124 | end
125 |
126 | --
127 | -- Set Blip
128 | --
129 | function SetBlip(...)
130 |
131 | local args = {...}
132 | local count = #args
133 |
134 | if count == 1 and type(args[1]) == "table" then
135 |
136 | for name, values in pairs(args[1]) do
137 | if blips[name] ~= nil then
138 | local blip = blips[name]
139 | for key, value in pairs(values) do
140 | blip[key] = value
141 | end
142 | end
143 | Citizen.Wait(1)
144 | end
145 |
146 | elseif count == 2 then
147 |
148 | local name = args[1]
149 | local values = args[2]
150 | if blips[name] ~= nil then
151 | local blip = blips[name]
152 | for key, value in pairs(values) do
153 | blip[key] = value
154 | end
155 | end
156 |
157 | end
158 |
159 | end
160 |
--------------------------------------------------------------------------------
/src/entity/entity.client.lua:
--------------------------------------------------------------------------------
1 | --
2 | -- @Project: FiveM Tools
3 | -- @Author: Samuelds
4 | -- @License: GNU General Public License v3.0
5 | -- @Source: https://github.com/FivemTools/ft_libs
6 | --
7 |
8 | --
9 | -- Get all entities
10 | --
11 | function GetEntities(findFirst, findNext, endFind)
12 |
13 | local entities = {}
14 |
15 | local iter, id = findFirst()
16 | table.insert(entities, id)
17 |
18 | while true do
19 |
20 | local iter, id = findNext(iter)
21 | table.insert(entities, id)
22 | if endFind(iter) == false or id == 0 or not id then
23 | break
24 | end
25 | Citizen.Wait(10)
26 |
27 | end
28 |
29 | return entities
30 |
31 | end
32 |
33 | --
34 | -- Shape Test Ray
35 | --
36 | function CastRayPlayerPedToPoint(range, type)
37 |
38 | local playerPed = GetPlayerPed()
39 | local playerCoords = GetPlayerCoords()
40 | local entityWorld = GetOffsetFromEntityInWorldCoords(playerPed, 0.0, range, 0.0)
41 | local rayHandle = StartShapeTestRay(playerCoords.x, playerCoords.y, playerCoords.z, entityWorld.x, entityWorld.y, entityWorld.z, type, playerPed, 0)
42 | local a, b, c, d, entity = GetRaycastResult(rayHandle)
43 | if entity ~= nil then
44 | return entity
45 | end
46 | return false
47 |
48 | end
49 |
50 | --
51 | -- Get entity in direction
52 | --
53 | function GetEntityInDirection(range)
54 |
55 | if type(range) ~= "number" then
56 | range = 20.0
57 | end
58 | return CastRayPlayerPedToPoint(range, 10)
59 |
60 | end
61 |
62 | --
63 | -- Get object in direction
64 | --
65 | function GetEntityObjectInDirection(range)
66 |
67 | if type(range) ~= "number" then
68 | range = 20.0
69 | end
70 | return CastRayPlayerPedToPoint(range, 16)
71 |
72 | end
73 |
74 | --
75 | -- Get entity in coords
76 | --
77 | function GetEntitiesInArea(settings)
78 |
79 | local settings = settings or {}
80 | assert(type(settings.entities) == "table", "GetEntitiesInArea : entities must be table")
81 | assert(type(settings.coords) == "table" or type(settings.coords) == "vector3", "GetEntitiesInArea : coords must be table")
82 | assert(type(settings.coords.x) == "number", "GetEntitiesInArea : coords x must be number")
83 | assert(type(settings.coords.y) == "number", "GetEntitiesInArea : coords y must be number")
84 | assert(type(settings.coords.z) == "number", "GetEntitiesInArea : coords z must be number")
85 |
86 | if type(range) ~= "number" then
87 | settings.range = 20.0
88 | end
89 |
90 | local entitiesInArea = {}
91 | for _, entityId in pairs(settings.entities) do
92 |
93 | if DoesEntityExist(entityId) then
94 | local entityCoords = GetEntityCoords(entityId)
95 | local distance = GetDistanceBetween3DCoords(entityCoords.x, entityCoords.y, entityCoords.z, settings.coords.x, settings.coords.y, settings.coords.z)
96 | if distance <= settings.range then
97 | table.insert(entitiesInArea, entityId)
98 | end
99 | end
100 | Citizen.Wait(10)
101 |
102 | end
103 | return entitiesInArea
104 |
105 | end
106 |
107 | --
108 | --
109 | --
110 | function GetEntitiesInAround(settings)
111 |
112 | local settings = settings or {}
113 | settings.coords = GetPlayerCoords()
114 | return GetEntitiesInArea(settings)
115 |
116 | end
117 |
--------------------------------------------------------------------------------
/src/entity/object.client.lua:
--------------------------------------------------------------------------------
1 | --
2 | -- @Project: FiveM Tools
3 | -- @Author: Samuelds
4 | -- @License: GNU General Public License v3.0
5 | -- @Source: https://github.com/FivemTools/ft_libs
6 | --
7 |
8 | --
9 | -- Get all object
10 | --
11 | function GetObjects()
12 |
13 | return GetEntities(FindFirstObject, FindNextObject, EndFindObject)
14 |
15 | end
16 |
17 | --
18 | -- Get object in direction
19 | --
20 | function GetObjectInDirection(range)
21 |
22 | if type(range) ~= "number" then
23 | range = 20.0
24 | end
25 | local entity = GetEntityObjectInDirection(range)
26 | if DoesEntityExist(entity) then
27 | if GetEntityType(entity) == 3 then
28 | return entity
29 | end
30 | end
31 | return false
32 |
33 | end
34 |
35 | --
36 | -- Get objects in coords
37 | --
38 | function GetObjectsInArea(settings)
39 |
40 | local settings = settings or {}
41 | settings.entities = GetObjects()
42 | return GetEntitiesInArea(settings)
43 |
44 | end
45 |
46 | --
47 | -- Get objects in around
48 | --
49 | function GetObjectsInAround(settings)
50 |
51 | local settings = settings or {}
52 | settings.entities = GetObjects()
53 | return GetEntitiesInAround(settings)
54 |
55 | end
56 |
--------------------------------------------------------------------------------
/src/entity/ped.client.lua:
--------------------------------------------------------------------------------
1 | --
2 | -- @Project: FiveM Tools
3 | -- @Author: Samuelds
4 | -- @License: GNU General Public License v3.0
5 | -- @Source: https://github.com/FivemTools/ft_libs
6 | --
7 |
8 | --
9 | -- Get all peds
10 | --
11 | function GetPeds()
12 |
13 | return GetEntities(FindFirstPed, FindNextPed, EndFindPed)
14 |
15 | end
16 |
17 | --
18 | -- Get ped in direction
19 | --
20 | function GetPedInDirection(range)
21 |
22 | if type(range) ~= "number" then
23 | range = 20.0
24 | end
25 | local entity = GetEntityInDirection(range)
26 | if DoesEntityExist(entity) then
27 | if GetEntityType(entity) == 1 then
28 | return entity
29 | end
30 | end
31 | return false
32 |
33 | end
34 |
35 | --
36 | -- Get peds in area
37 | --
38 | function GetPedsInArea(settings)
39 |
40 | local settings = settings or {}
41 | settings.entities = GetPeds()
42 | return GetEntitiesInArea(settings)
43 |
44 | end
45 |
46 | --
47 | -- Get peds in around
48 | --
49 | function GetPedsInAround(settings)
50 |
51 | local settings = settings or {}
52 | settings.entities = GetPeds()
53 | local pedsInAround = GetEntitiesInAround(settings)
54 |
55 | -- Remove player ped
56 | local playerPed = GetPlayerPed()
57 | local key = TableContainsValue(pedsInAround, playerPed)
58 | if key ~= false then
59 | table.remove(pedsInAround, key)
60 | end
61 |
62 | return pedsInAround
63 |
64 | end
65 |
--------------------------------------------------------------------------------
/src/entity/pickup.client.lua:
--------------------------------------------------------------------------------
1 | --
2 | -- @Project: FiveM Tools
3 | -- @Author: Samuelds
4 | -- @License: GNU General Public License v3.0
5 | -- @Source: https://github.com/FivemTools/ft_libs
6 | --
7 |
8 | --
9 | -- Get all pickups
10 | --
11 | function GetPickups()
12 |
13 | return GetEntities(FindFirstPickup, FindNextPickup, EndFindPickup)
14 |
15 | end
16 |
17 | --
18 | -- Get pickups in area
19 | --
20 | function GetPickupsInArea(settings)
21 |
22 | local settings = settings or {}
23 | settings.entities = GetPickups()
24 | return GetEntitiesInArea(settings)
25 |
26 | end
27 |
28 | --
29 | -- Get pickups in around
30 | --
31 | function GetPickupsInAround(settings)
32 |
33 | local settings = settings or {}
34 | settings.entities = GetPickups()
35 | return GetEntitiesInAround(settings)
36 |
37 | end
38 |
--------------------------------------------------------------------------------
/src/entity/player.client.lua:
--------------------------------------------------------------------------------
1 | --
2 | -- @Project: FiveM Tools
3 | -- @Author: Samuelds
4 | -- @License: GNU General Public License v3.0
5 | -- @Source: https://github.com/FivemTools/ft_libs
6 | --
7 |
8 | local playerPed = nil
9 | local playerCoords = {}
10 |
11 | --
12 | -- Update ped and coords for player
13 | --
14 | function UpdatePlayerThread()
15 | Citizen.CreateThread(function()
16 |
17 | while true do
18 |
19 | playerPed = Citizen.InvokeNative(0x43A66C31C68491C0, -1) -- Use native GET_PLAYER_PED
20 | local coords = GetEntityCoords(playerPed)
21 | playerCoords = { ["x"] = coords.x, ["y"] = coords.y, ["z"] = coords.z }
22 | Citizen.Wait(200)
23 |
24 | end
25 |
26 | end)
27 | end
28 |
29 | --
30 | --
31 | --
32 | function GetPlayerPed()
33 |
34 | return playerPed
35 |
36 | end
37 |
38 | --
39 | --
40 | --
41 | function GetPlayerCoords()
42 |
43 | return playerCoords
44 |
45 | end
46 |
47 | --
48 | -- Get player in direction
49 | --
50 | function GetPlayerPedInDirection(range)
51 |
52 | if type(range) ~= "number" then
53 | range = 20.0
54 | end
55 | local entity = GetPedInDirection(range)
56 | if DoesEntityExist(entity) then
57 | local target = NetworkGetPlayerIndexFromPed(entity)
58 | local id = GetPlayerServerId(target)
59 | if id ~= nil then
60 | return entity
61 | end
62 | end
63 | return false
64 |
65 | end
66 |
67 | --
68 | -- Get player ped server id in direction
69 | --
70 | function GetPlayerServerIdInDirection(range)
71 |
72 | if type(range) ~= "number" then
73 | range = 15.50
74 | end
75 | local entity = GetPedInDirection(range)
76 | if DoesEntityExist(entity) then
77 | local entity = NetworkGetPlayerIndexFromPed(entity)
78 | local id = GetPlayerServerId(entity)
79 | if id ~= nil then
80 | return id
81 | end
82 | end
83 | return false
84 |
85 | end
86 |
87 | --
88 | --
89 | --
90 | function GetPlayersPed()
91 |
92 | local players = {}
93 | local playerPed = GetPlayerPed()
94 | for i = 0, 32, 1 do
95 | local ped = GetPlayerPed(i)
96 | if DoesEntityExist(ped) and id ~= playerPed then
97 | table.insert(players, i)
98 | end
99 | end
100 | return players
101 |
102 | end
103 |
104 | --
105 | --
106 | --
107 | function GetPlayersId()
108 |
109 | local players = {}
110 | local playersPed = GetPlayersPed()
111 | for key, ped in pairs(playersPed) do
112 | if DoesEntityExist(ped) and ped ~= GetPlayerPed() then
113 | local network = NetworkGetPlayerIndexFromPed(ped)
114 | local id = GetPlayerServerId(network)
115 | if id ~= nil then
116 | table.insert(players, id)
117 | end
118 | end
119 | end
120 | return players
121 |
122 | end
123 |
124 | --
125 | --
126 | --
127 | function GetPlayersPedOrderById()
128 |
129 | local players = {}
130 | local playersPed = GetPlayersPed()
131 | for key, ped in pairs(playersPed) do
132 | if DoesEntityExist(ped) and ped ~= GetPlayerPed() then
133 | local network = NetworkGetPlayerIndexFromPed(ped)
134 | local id = GetPlayerServerId(network)
135 | if id ~= nil then
136 | players[id] = ped
137 | end
138 | end
139 | end
140 | return players
141 |
142 | end
143 |
--------------------------------------------------------------------------------
/src/entity/vehicle.client.lua:
--------------------------------------------------------------------------------
1 | --
2 | -- @Project: FiveM Tools
3 | -- @Author: Samuelds
4 | -- @License: GNU General Public License v3.0
5 | -- @Source: https://github.com/FivemTools/ft_libs
6 | --
7 |
8 | --
9 | -- Get all vehicles
10 | --
11 | function GetVehicles()
12 |
13 | return GetEntities(FindFirstVehicle, FindNextVehicle, EndFindVehicle)
14 |
15 | end
16 |
17 | --
18 | -- Get vehicle in direction
19 | --
20 | function GetVehicleInDirection(range)
21 |
22 | if type(range) ~= "number" then
23 | range = 20.0
24 | end
25 | local entity = GetEntityInDirection(range)
26 | if DoesEntityExist(entity) then
27 | if GetEntityType(entity) == 2 then
28 | return entity
29 | end
30 | end
31 | return false
32 |
33 | end
34 |
35 | --
36 | -- Get vehicles in area
37 | --
38 | function GetVehiclesInArea(settings)
39 |
40 | local settings = settings or {}
41 | settings.entities = GetVehicles()
42 | return GetEntitiesInArea(settings)
43 |
44 | end
45 |
46 | --
47 | -- Get vehicles in around
48 | --
49 | function GetVehiclesInAround(settings)
50 |
51 | local settings = settings or {}
52 | settings.entities = GetVehicles()
53 | return GetEntitiesInAround(settings)
54 |
55 | end
56 |
--------------------------------------------------------------------------------
/src/load.client.lua:
--------------------------------------------------------------------------------
1 | --
2 | -- @Project: FiveM Tools
3 | -- @Author: Samuelds
4 | -- @License: GNU General Public License v3.0
5 | -- @Source: https://github.com/FivemTools/ft_libs
6 | --
7 |
8 | --
9 | -- Client is 100% loaded games
10 | --
11 | Citizen.CreateThread(function()
12 | while true do
13 | Citizen.Wait(1)
14 |
15 | if NetworkIsSessionStarted() then
16 |
17 | -- Send event to client & server
18 | TriggerServerEvent('ft_libs:OnClientReady')
19 | TriggerEvent('ft_libs:OnClientReady')
20 |
21 | -- tools thread
22 | MenuFrame()
23 | InstructionalButtonsFrame()
24 |
25 | -- Check player
26 | UpdatePlayerThread()
27 | Citizen.Wait(1000)
28 |
29 | -- Trigger
30 | CheckTriggerThread()
31 | ActiveTriggerThread()
32 |
33 | -- Marker
34 | CheckMarkerThread()
35 | ActiveMarkerThread()
36 |
37 | break
38 |
39 | end
40 |
41 | end
42 | end)
43 |
--------------------------------------------------------------------------------
/src/marker/marker.client.lua:
--------------------------------------------------------------------------------
1 | --
2 | -- @Project: FiveM Tools
3 | -- @Author: Samuelds
4 | -- @License: GNU General Public License v3.0
5 | -- @Source: https://github.com/FivemTools/ft_libs
6 | --
7 |
8 | --
9 | marker = {}
10 |
11 | -- class table
12 | local Marker = {}
13 |
14 | --
15 | -- Show Marker
16 | --
17 | function Marker:Show()
18 |
19 | local weight = self.weight * 2.0
20 | local height = self.height + 0.0
21 | DrawMarker(self.type, self.x, self.y, (self.z - 1), 0, 0, 0, 0, 0, 0, weight, weight, height, self.red, self.green, self.blue, self.alpha, 0, 0, 0, 0)
22 |
23 | if self.text ~= nil then
24 | Show3DText({
25 | x = self.x,
26 | y = self.y,
27 | z = self.z + self.textOffset,
28 | text = self.text,
29 | })
30 | end
31 |
32 | end
33 |
34 | --
35 | -- Create new instace of Marker
36 | --
37 | function marker.new(data)
38 |
39 | assert(type(data.x) == "number", "Marker : x must be number")
40 | assert(type(data.y) == "number", "Marker : y must be number")
41 | assert(type(data.z) == "number", "Marker : z must be number")
42 |
43 | local self = data
44 | self.type = data.type or 1
45 | self.weight = data.weight or 2.0
46 | self.height = data.height or 0.5
47 | self.red = data.red or 255
48 | self.green = data.green or 255
49 | self.blue = data.blue or 255
50 | self.alpha = data.alpha or 255
51 | self.showDistance = data.showDistance or self.weight + 20
52 | self.text = data.text
53 | self.textOffset = data.textOffset or 0
54 |
55 | if data.enable == nil or type(data.enable) ~= "boolean" then
56 | self.enable = true
57 | end
58 |
59 | setmetatable(self, { __index = Marker })
60 | return self
61 |
62 | end
63 |
--------------------------------------------------------------------------------
/src/marker/markers.client.lua:
--------------------------------------------------------------------------------
1 | --
2 | -- @Project: FiveM Tools
3 | -- @Author: Samuelds
4 | -- @License: GNU General Public License v3.0
5 | -- @Source: https://github.com/FivemTools/ft_libs
6 | --
7 |
8 | local markers = {}
9 | local activeMarkers = {}
10 | local currentMarkers = {}
11 |
12 |
13 | --
14 | -- Add Marker to activeMarkers table
15 | --
16 | function EnableMarker(...)
17 |
18 | local args = {...}
19 | local count = #args
20 | if count == 1 and type(args[1]) == "table" then
21 |
22 | for _, name in pairs(args[1]) do
23 | if markers[name] then
24 | activeMarkers[name] = true
25 | end
26 | Citizen.Wait(10)
27 | end
28 |
29 | elseif count == 1 then
30 |
31 | local name = args[1]
32 | if markers[name] then
33 | activeMarkers[name] = true
34 | end
35 |
36 | end
37 |
38 | end
39 |
40 | --
41 | -- Remove Marker to activeMarkers table
42 | --
43 | function DisableMarker(...)
44 |
45 | local args = {...}
46 | local count = #args
47 | if count == 1 and type(args[1]) == "table" then
48 |
49 | for _, name in pairs(args[1]) do
50 | activeMarkers[name] = nil
51 | currentMarkers[name] = nil
52 | Citizen.Wait(10)
53 | end
54 |
55 | elseif count == 1 then
56 |
57 | local name = args[1]
58 | activeMarkers[name] = nil
59 | currentMarkers[name] = nil
60 |
61 | end
62 |
63 | end
64 |
65 | --
66 | -- Add or Remove Marker to activeMarkers table
67 | --
68 | function SwitchMarker(...)
69 |
70 | local args = {...}
71 | local count = #args
72 | if count == 1 and type(args[1]) == "table" then
73 |
74 | for name, status in pairs(args[1]) do
75 | if markers[name] ~= nil then
76 | if status == true then
77 | EnableMarker(name)
78 | elseif status == false then
79 | DisableMarker(name)
80 | end
81 | end
82 | Citizen.Wait(10)
83 | end
84 |
85 | elseif count == 2 then
86 |
87 | local name = args[1]
88 | local status = args[2]
89 | if markers[name] ~= nil then
90 | if status == true then
91 | EnableMarker(name)
92 | else
93 | DisableMarker(name)
94 | end
95 | end
96 |
97 | end
98 |
99 | end
100 |
101 | --
102 | -- Add Marker in the markers table
103 | --
104 | function AddMarker(...)
105 |
106 | local args = {...}
107 | local count = #args
108 | if count == 1 and type(args[1]) == "table" then
109 |
110 | for name, value in pairs(args[1]) do
111 | if markers[name] == nil then
112 | markers[name] = marker.new(value)
113 | if value.enable == nil or value.enable == true then
114 | EnableMarker(name)
115 | end
116 | end
117 | Citizen.Wait(10)
118 | end
119 |
120 | elseif count == 2 then
121 |
122 | local name = args[1]
123 | local value = args[2]
124 | if markers[name] == nil then
125 | markers[name] = marker.new(value)
126 | if value.enable == nil or value.enable == true then
127 | EnableMarker(name)
128 | end
129 | end
130 |
131 | end
132 |
133 | end
134 |
135 | --
136 | -- Remove Marker in the markers table
137 | --
138 | function RemoveMarker(...)
139 |
140 | local args = {...}
141 | local count = #args
142 | if count == 1 and type(args[1]) == "table" then
143 |
144 | for _, name in ipairs(args[1]) do
145 | DisableMarker(name)
146 | markers[name] = nil
147 | Citizen.Wait(10)
148 | end
149 |
150 | elseif count == 1 then
151 |
152 | local name = args[1]
153 | DisableMarker(name)
154 | markers[name] = nil
155 |
156 | end
157 |
158 | end
159 |
160 | --
161 | -- Set Marker
162 | --
163 | function SetMarker(...)
164 |
165 | local args = {...}
166 | local count = #args
167 |
168 | if count == 1 and type(args[1]) == "table" then
169 |
170 | for name, values in pairs(args[1]) do
171 | if markers[name] ~= nil then
172 | local marker = markers[name]
173 | for key, value in pairs(values) do
174 | marker[key] = value
175 | end
176 | end
177 | Citizen.Wait(1)
178 | end
179 |
180 | elseif count == 2 then
181 |
182 | local name = args[1]
183 | local values = args[2]
184 | if markers[name] ~= nil then
185 | local marker = markers[name]
186 | for key, value in pairs(values) do
187 | marker[key] = value
188 | end
189 | end
190 |
191 | end
192 |
193 | end
194 |
195 | --
196 | -- Get Current Marker
197 | --
198 | function CurrentMarker()
199 |
200 | return currentMarkers
201 |
202 | end
203 |
204 | --
205 | -- Add check for global frame
206 | --
207 | function CheckMarkerThread()
208 |
209 | Citizen.CreateThread(function()
210 |
211 | while true do
212 |
213 | local playerCoords = GetPlayerCoords()
214 | for name, value in pairs(activeMarkers) do
215 |
216 | local target = markers[name]
217 | if target then
218 | if GetDistanceBetween3DCoords(target.x, target.y, target.z, playerCoords.x, playerCoords.y, playerCoords.z) <= target.showDistance then
219 | currentMarkers[name] = true
220 | elseif currentMarkers[name] ~= nil then
221 | currentMarkers[name] = nil
222 | end
223 | end
224 |
225 | end
226 |
227 | Citizen.Wait(500)
228 | end
229 |
230 | end)
231 |
232 | end
233 |
234 | --
235 | --
236 | --
237 | function ActiveMarkerThread()
238 |
239 | Citizen.CreateThread(function()
240 |
241 | while true do
242 |
243 | for name, value in pairs(currentMarkers) do
244 | local marker = markers[name]
245 | if marker and currentMarkers[name] ~= nil then
246 | marker:Show()
247 | end
248 | end
249 |
250 | Citizen.Wait(5)
251 | end
252 |
253 | end)
254 |
255 | end
256 |
--------------------------------------------------------------------------------
/src/menu/menu.client.lua:
--------------------------------------------------------------------------------
1 | --
2 | -- @Project: FiveM Tools
3 | -- @Author: Samuelds
4 | -- @License: GNU General Public License v3.0
5 | -- @Source: https://github.com/FivemTools/ft_libs
6 | --
7 |
8 | --
9 | --
10 | --
11 | function Menu(data)
12 |
13 | local self = {
14 |
15 | x = 0.9,
16 | y = 0.25,
17 | title = data.title or nil,
18 | menuTitle = data.menuTitle or nil,
19 | titleScale = data.titleScale or 1.0,
20 | textScale = data.textScale or 0.36,
21 | subTextScale = data.subTextScale or 0.36,
22 | position = data.position or 2,
23 | width = data.width or 0.2,
24 | height = data.height or 0.04,
25 | defaultButtonPosition = data.defaultButtonPosition or 1,
26 |
27 | colors = {
28 | header = {
29 | red = 93,
30 | blue = 202,
31 | green = 166,
32 | alpha = 150,
33 | },
34 | button = {
35 | red = 0,
36 | green = 0,
37 | blue = 0,
38 | alpha = 150,
39 | },
40 | buttonHover = {
41 | red = 255,
42 | green = 255,
43 | blue = 255,
44 | alpha = 255,
45 | },
46 | text = {
47 | red = 255,
48 | green = 255,
49 | blue = 255,
50 | alpha = 255,
51 | },
52 | textHover = {
53 | red = 0,
54 | green = 0,
55 | blue = 0,
56 | alpha = 255,
57 | }
58 | },
59 |
60 | back = {
61 | eventClient = nil,
62 | eventServer = nil,
63 | callback = nil,
64 | },
65 |
66 | buttons = data.buttons or {},
67 |
68 | }
69 |
70 | -- Closable menu
71 | self.closable = true
72 | if data.closable ~= nil then
73 | self.closable = data.closable
74 | end
75 |
76 | -- Lock back menu
77 | self.backLock = false
78 | if data.backLock ~= nil then
79 | self.backLock = data.backLock
80 | end
81 |
82 | -- Get position (1 = left / 2 - right [default])
83 | if data.position == 1 then
84 | self.x = self.width / 2
85 | end
86 |
87 | -- Get color
88 | if data.colors ~= nil then
89 |
90 | if data.colors.header ~= nil then
91 |
92 | if data.colors.header.red ~= nil then
93 | self.colors.header.red = data.colors.header.red
94 | end
95 |
96 | if data.colors.header.blue ~= nil then
97 | self.colors.header.blue = data.colors.header.blue
98 | end
99 |
100 | if data.colors.header.green ~= nil then
101 | self.colors.header.green = data.colors.header.green
102 | end
103 |
104 | if data.colors.header.alpha ~= nil then
105 | self.colors.header.alpha = data.colors.header.alpha
106 | end
107 |
108 | end
109 |
110 | if data.button ~= nil then
111 |
112 | if data.button.red ~= nil then
113 | self.button.red = data.button.red
114 | end
115 |
116 | if data.button.blue ~= nil then
117 | self.button.blue = data.button.blue
118 | end
119 |
120 | if data.header.green ~= nil then
121 | self.button.green = data.button.green
122 | end
123 |
124 | if data.button.alpha ~= nil then
125 | self.button.alpha = data.button.alpha
126 | end
127 |
128 | end
129 |
130 | if data.buttonHover ~= nil then
131 |
132 | if data.buttonHover.red ~= nil then
133 | self.buttonHover.red = data.buttonHover.red
134 | end
135 |
136 | if data.button.blue ~= nil then
137 | self.buttonHover.blue = data.buttonHover.blue
138 | end
139 |
140 | if data.header.green ~= nil then
141 | self.buttonHover.green = data.buttonHover.green
142 | end
143 |
144 | if data.button.alpha ~= nil then
145 | self.buttonHover.alpha = data.buttonHover.alpha
146 | end
147 |
148 | end
149 |
150 | if data.text ~= nil then
151 |
152 | if data.text.red ~= nil then
153 | self.text.red = data.text.red
154 | end
155 |
156 | if data.text.blue ~= nil then
157 | self.text.blue = data.text.blue
158 | end
159 |
160 | if data.text.green ~= nil then
161 | self.text.green = data.text.green
162 | end
163 |
164 | if data.text.alpha ~= nil then
165 | self.text.alpha = data.text.alpha
166 | end
167 |
168 | end
169 |
170 | if data.textHover ~= nil then
171 |
172 | if data.textHover.red ~= nil then
173 | self.textHover.red = data.textHover.red
174 | end
175 |
176 | if data.textHover.blue ~= nil then
177 | self.textHover.blue = data.textHover.blue
178 | end
179 |
180 | if data.textHover.green ~= nil then
181 | self.textHover.green = data.textHover.green
182 | end
183 |
184 | if data.textHover.alpha ~= nil then
185 | self.textHover.alpha = data.textHover.alpha
186 | end
187 |
188 | end
189 |
190 | end
191 |
192 | --
193 | -- Get back action
194 | --
195 | if data.back ~= nil then
196 |
197 | if data.back.eventClient ~= nil then
198 | self.back.eventClient = data.back.eventClient
199 | end
200 |
201 | if data.back.eventServer ~= nil then
202 | self.back.eventServer = data.back.eventServer
203 | end
204 |
205 | if data.back.callback ~= nil then
206 | self.back.callback = data.back.callback
207 | end
208 |
209 | end
210 |
211 | --
212 | -- Display big title
213 | --
214 | self.ShowBigTitle = function()
215 |
216 | if self.title ~= nil then
217 | Text({
218 | text = self.title,
219 | x = self.x,
220 | y = self.y,
221 | scale = self.titleScale,
222 | center = true,
223 | })
224 | end
225 |
226 | end
227 |
228 | --
229 | --
230 | --
231 | self.SowHeader = function(selectedButton)
232 |
233 | local y = self.y
234 | if self.title ~= nil then
235 | y = y + 0.08
236 | end
237 |
238 | -- Top menu
239 | local countText = selectedButton .. "/" .. TableLength(self.buttons)
240 |
241 | -- Sub title
242 | DrawRect(self.x, y, self.width, self.height, self.colors.header.red, self.colors.header.green, self.colors.header.blue, self.colors.header.alpha)
243 | if self.menuTitle ~= nil then
244 | Text({
245 | text = self.menuTitle,
246 | font = 0,
247 | x = self.x - (self.width / 2) + 0.005,
248 | y = y - (self.height / 2) + 0.0028,
249 | scale = 0.4,
250 | })
251 | end
252 |
253 | -- Numbers
254 | Text({
255 | text = countText,
256 | font = 0,
257 | center = 0,
258 | x = self.x + self.width / 2 - 0.0385,
259 | y = y - 0.015,
260 | scale = 0.4,
261 | })
262 |
263 | end
264 |
265 | --
266 | --
267 | --
268 | self.DrawMenuButton = function(data, x, y, width, height, selected)
269 |
270 | local color = {}
271 | if selected then
272 | color.text = self.colors.textHover
273 | color.rect = self.colors.buttonHover
274 | else
275 | color.text = self.colors.text
276 | color.rect = self.colors.button
277 | end
278 |
279 | local textScale = self.textScale
280 | local subTextScale = self.subTextScale
281 |
282 | Text({
283 | text = data.text or "Default text",
284 | font = 0,
285 | x = x - (self.width / 2) + 0.005,
286 | y = y - (self.height / 2) + 0.0035,
287 | scale = textScale,
288 | red = color.text.red,
289 | blue = color.text.blue,
290 | green = color.text.green,
291 | })
292 | DrawRect(x, y, width, height, color.rect.red, color.rect.blue, color.rect.green, color.rect.alpha)
293 |
294 | if data.subText ~= nil then
295 | Text({
296 | text = data.subText,
297 | font = 0,
298 | right = true,
299 | startWrap = self.x,
300 | endWrap = (self.x + (self.width / 2)) - 0.005,
301 | x = x - (self.width / 2),
302 | y = y - (self.height / 2) + 0.0035,
303 | scale = subTextScale,
304 | red = color.text.red,
305 | blue = color.text.blue,
306 | green = color.text.green
307 | })
308 | end
309 |
310 | end
311 |
312 | --
313 | --
314 | --
315 | self.DrawMenuButtons = function(from, to, selectedButton)
316 |
317 | local y = self.y + self.height
318 | if self.title ~= nil then
319 | y = y + 0.08
320 | end
321 |
322 | for i, button in pairs(self.buttons) do
323 |
324 | if i >= from and i <= to then
325 | if i == selectedButton then
326 | selected = true
327 | else
328 | selected = false
329 | end
330 |
331 | self.DrawMenuButton(button, self.x, y, self.width, self.height, selected)
332 | y = y + 0.04
333 | end
334 | end
335 |
336 | end
337 |
338 | --
339 | --
340 | --
341 | self.Hover = function(selectedButton)
342 |
343 | local button = self.buttons[selectedButton]
344 |
345 | if button.hover ~= nil then
346 |
347 | -- Execute function
348 | if button.hover.callback ~= nil then
349 | local callback = button.hover.callback
350 | Citizen.CreateThread(function()
351 | callback(button.data)
352 | end)
353 | end
354 |
355 | -- Send to server event
356 | if button.hover.eventServer ~= nil then
357 | TriggerServerEvent(button.hover.eventServer, button.data)
358 | end
359 |
360 | -- Send to client event
361 | if button.hover.eventClient ~= nil then
362 | TriggerEvent(button.hover.eventClient, button.data)
363 | end
364 |
365 | end
366 |
367 | end
368 |
369 | --
370 | --
371 | --
372 | self.Exec = function(selectedButton)
373 |
374 | local button = self.buttons[selectedButton]
375 |
376 | if button.exec ~= nil and button.lock ~= false then
377 |
378 | -- Execute function
379 | if button.exec.callback ~= nil then
380 | local callback = button.exec.callback
381 | Citizen.CreateThread(function()
382 | callback(button.data)
383 | end)
384 | end
385 |
386 | -- Send to server event
387 | if button.exec.eventServer ~= nil then
388 | TriggerServerEvent(button.exec.eventServer, button.data)
389 | end
390 |
391 | -- Send to client event
392 | if button.exec.eventClient ~= nil then
393 | TriggerEvent(button.exec.eventClient, button.data)
394 | end
395 |
396 | end
397 |
398 | end
399 |
400 | --
401 | --
402 | --
403 | self.Back = function()
404 |
405 | if self.back ~= nil then
406 |
407 | if self.back.callback ~= nil then
408 | local callback = self.back.callback
409 | Citizen.CreateThread(function()
410 | callback()
411 | end)
412 | end
413 |
414 | -- Send to server event
415 | if self.back.eventServer ~= nil then
416 | TriggerServerEvent(self.back.eventServer)
417 | end
418 |
419 | -- Send to client event
420 | if self.back.eventClient ~= nil then
421 | TriggerEvent(self.back.eventClient)
422 | end
423 |
424 | end
425 |
426 | end
427 |
428 | --
429 | --
430 | --
431 | self.Show = function(from, to, selectedButton)
432 |
433 | self.ShowBigTitle()
434 | self.SowHeader(selectedButton)
435 | self.DrawMenuButtons(from, to, selectedButton)
436 |
437 | end
438 |
439 | return self
440 |
441 | end
442 |
--------------------------------------------------------------------------------
/src/menu/menus.client.lua:
--------------------------------------------------------------------------------
1 | --
2 | -- @Project: FiveM Tools
3 | -- @Author: Samuelds, THEJean-Kevin
4 | -- @License: GNU General Public License v3.0
5 | -- @Source: https://github.com/FivemTools/ft_libs
6 | --
7 |
8 | Menus = {
9 | open = nil,
10 | curent = nil,
11 | primary = nil,
12 | freeze = false,
13 | from = 1,
14 | to = 10,
15 | selectedButton = 0,
16 | list = {},
17 | backMenu = {},
18 | gameMenu = false,
19 | lastKeyPressed = 0,
20 | }
21 |
22 | --
23 | --
24 | --
25 | function AddMenu(...)
26 |
27 | local args = {...}
28 | local count = #args
29 |
30 | if count == 1 and type(args[1]) == "table" then
31 |
32 | for name, value in pairs(args[1]) do
33 | if Menus.list[name] == nil then
34 | Menus.list[name] = Menu(value)
35 | end
36 | Citizen.Wait(1)
37 | end
38 |
39 | elseif count == 2 then
40 |
41 | local name = args[1]
42 | local value = args[2]
43 | if Menus.list[name] == nil then
44 | Menus.list[name] = Menu(value)
45 | end
46 |
47 | end
48 |
49 | end
50 |
51 | --
52 | --
53 | --
54 | function RemoveMenu(...)
55 |
56 | local args = {...}
57 | local count = #args
58 |
59 | if count == 1 and type(args[1]) == "table" then
60 |
61 | for _, name in ipairs(args[1]) do
62 | if Menus[name] ~= nil then
63 | Menus.list[name] = nil
64 | end
65 | Citizen.Wait(1)
66 | end
67 |
68 | elseif count == 1 then
69 |
70 | local name = args[1]
71 | if Menus[name] ~= nil then
72 | Menus.list[name] = nil
73 | end
74 |
75 | end
76 |
77 | end
78 |
79 | --
80 | -- Return if menu is open
81 | --
82 | function MenuIsOpen()
83 |
84 | if Menus.curent ~= nil then
85 | return true
86 | end
87 | return false
88 |
89 | end
90 |
91 | --
92 | -- Return current
93 | --
94 | function GetCurrentMenu()
95 |
96 | return Menus.curent
97 |
98 | end
99 |
100 | --
101 | -- Return current
102 | --
103 | function GetPrimaryMenu()
104 |
105 | return Menus.primary
106 |
107 | end
108 |
109 | --
110 | -- Freeze menu
111 | --
112 | function FreezeMenu(status)
113 |
114 | Menus.freeze = status
115 |
116 | end
117 |
118 | --
119 | -- Reset values
120 | --
121 | function ResetMenu()
122 |
123 | Menus.selectedButton = 0
124 | Menus.freeze = false
125 | Menus.from = 1
126 | Menus.to = 10
127 |
128 | end
129 |
130 |
131 |
132 | --
133 | -- Open menu
134 | --
135 | function OpenMenu(...)
136 |
137 | -- Check if menu is open
138 | if MenuIsOpen() then
139 | return false
140 | end
141 |
142 | local args = {...}
143 | local countArgs = #args
144 | local settings = {}
145 | if countArgs == 1 then
146 | menuName = args[1]
147 | elseif countArgs == 2 and type(args[2]) == "table" then
148 | menuName = args[1]
149 | settings = args[2]
150 | else
151 | return false
152 | end
153 |
154 | -- Check if menu exit
155 | if Menus.list[menuName] == nil then
156 | return false
157 | end
158 |
159 | Menus.open = true
160 | Menus.curent = menuName
161 | Menus.primary = menuName
162 |
163 | local menu = Menus.list[menuName]
164 | local countBtns = TableLength(menu.buttons)
165 | local defaultButtonPosition = settings.defaultButtonPosition or menu.defaultButtonPosition
166 | if countBtns >= 1 and defaultButtonPosition <= countBtns then
167 | Menus.selectedButton = defaultButtonPosition
168 | else
169 | Menus.selectedButton = 1
170 | end
171 |
172 | end
173 |
174 | --
175 | -- Close menu
176 | --
177 | function CloseMenu()
178 |
179 | ResetMenu()
180 | Menus.backMenu = {}
181 | Menus.curent = nil
182 | Menus.open = false
183 | Menus.primary = nil
184 |
185 | end
186 |
187 | --
188 | -- Move Up action
189 | --
190 | local function MoveUp(menu)
191 |
192 | local countBtns = TableLength(menu.buttons)
193 |
194 | if Menus.selectedButton > 1 then
195 | Menus.selectedButton = Menus.selectedButton - 1
196 | if countBtns > 11 and Menus.selectedButton < Menus.from then
197 | Menus.from = Menus.from - 1
198 | Menus.to = Menus.to - 1
199 | end
200 | else
201 | Menus.selectedButton = countBtns
202 | Menus.from = countBtns - 9
203 | Menus.to = countBtns
204 | end
205 |
206 | menu.Hover(Menus.selectedButton)
207 | PlaySound(-1, "NAV_UP_DOWN", "HUD_FRONTEND_DEFAULT_SOUNDSET", 0, 0, 1)
208 |
209 | end
210 |
211 | --
212 | -- Move down action
213 | --
214 | local function MoveDown(menu)
215 |
216 | local countBtns = TableLength(menu.buttons)
217 |
218 | if Menus.selectedButton < countBtns then
219 | Menus.selectedButton = Menus.selectedButton + 1
220 | if countBtns > 11 and Menus.selectedButton > Menus.to then
221 | Menus.to = Menus.to + 1
222 | Menus.from = Menus.from + 1
223 | end
224 | else
225 | Menus.selectedButton = 1
226 | Menus.from = 1
227 | Menus.to = 11
228 | end
229 |
230 | menu.Hover(Menus.selectedButton)
231 | PlaySound(-1, "NAV_UP_DOWN", "HUD_FRONTEND_DEFAULT_SOUNDSET", 0, 0, 1)
232 |
233 | end
234 |
235 |
236 | --
237 | -- Next menu
238 | --
239 | function NextMenu(...)
240 |
241 | if Menus.curent ~= nil then
242 |
243 | local args = {...}
244 | local countArgs = #args
245 | local settings = {}
246 | if countArgs == 1 then
247 | menuName = args[1]
248 | elseif countArgs == 2 and type(args[2]) == "table" then
249 | menuName = args[1]
250 | settings = args[2]
251 | else
252 | return false
253 | end
254 |
255 | -- Check if menu exit
256 | if Menus.list[menuName] == nil then
257 | return false
258 | end
259 |
260 | local data = {
261 | name = Menus.curent,
262 | from = Menus.from,
263 | to = Menus.to,
264 | selectedButton = Menus.selectedButton,
265 | }
266 | table.insert(Menus.backMenu, data) -- Check if curent menu is backMenu
267 | ResetMenu()
268 |
269 | Menus.curent = menuName
270 |
271 | local menu = Menus.list[menuName]
272 | local countBtns = TableLength(menu.buttons)
273 | local defaultButtonPosition = settings.defaultButtonPosition or menu.defaultButtonPosition
274 | if countBtns >= 1 and defaultButtonPosition <= countBtns then
275 | Menus.selectedButton = defaultButtonPosition
276 | else
277 | Menus.selectedButton = 1
278 | end
279 |
280 | end
281 |
282 | end
283 |
284 | --
285 | -- Back last menu
286 | --
287 | function BackMenu()
288 |
289 | local backNumber = TableLength(Menus.backMenu)
290 | local backMenu = Menus.backMenu[backNumber]
291 |
292 | -- Back menu
293 | if backMenu.from ~= nil then
294 | Menus.from = backMenu.from
295 | end
296 |
297 | if backMenu.to ~= nil then
298 | Menus.to = backMenu.to
299 | end
300 |
301 | if backMenu.selectedButton ~= nil then
302 |
303 | local name = backMenu.name
304 | local menu = Menus.list[name]
305 | local countBtns = TableLength(menu.buttons)
306 | if backMenu.selectedButton > countBtns then
307 | Menus.selectedButton = countBtns
308 | else
309 | Menus.selectedButton = backMenu.selectedButton
310 | end
311 |
312 | end
313 |
314 | Menus.curent = backMenu.name
315 | Menus.freeze = false
316 |
317 | -- Remove menu
318 | table.remove(Menus.backMenu, backNumber)
319 | Menus.backMenu[backNumber] = nil
320 |
321 | end
322 |
323 | --
324 | -- Back is press Back key
325 | --
326 | local function BackBtn(menu)
327 |
328 | local name = Menus.curent
329 | local menu = Menus.list[name]
330 |
331 | menu.Back()
332 |
333 | local backNumber = TableLength(Menus.backMenu)
334 | if next(Menus.backMenu) and backNumber > 0 and menu.backLock == false then
335 | BackMenu()
336 | elseif menu.closable == true then
337 | CloseMenu()
338 | end
339 |
340 | end
341 |
342 | --
343 | -- Execute action
344 | --
345 | local function Exec(menu)
346 |
347 | local button = menu.buttons[Menus.selectedButton]
348 | menu.Exec(Menus.selectedButton)
349 |
350 | -- Go to next menu
351 | if button.openMenu ~= nil and Menus.list[button.openMenu] ~= nil then
352 | NextMenu(button.openMenu)
353 | end
354 |
355 | -- Freeze, Close and Back
356 | if button.freeze ~= nil and button.freeze then
357 | Menus.freeze = button.freeze
358 | elseif button.close ~= nil and button.close then
359 | CloseMenu()
360 | elseif button.back ~= nil and button.back then
361 | menu.Back()
362 | BackMenu()
363 | end
364 |
365 | end
366 |
367 | --
368 | -- Clean buttons
369 | --
370 | function CleanMenuButtons(...)
371 |
372 | local args = {...}
373 | local count = #args
374 |
375 | if count == 1 and type(args[1]) == "table" then
376 |
377 | for _, name in ipairs(args[1]) do
378 | if Menus.list[name] ~= nil then
379 | Menus.list[name].buttons = {}
380 | end
381 | Citizen.Wait(1)
382 | end
383 |
384 | elseif count == 1 then
385 |
386 | local name = args[1]
387 | if Menus.list[name] ~= nil then
388 | Menus.list[name].buttons = {}
389 | end
390 |
391 | end
392 | return false
393 |
394 | end
395 | --
396 |
397 | --
398 | -- Clean buttons
399 | --
400 | function SetMenuButtons(...)
401 |
402 | local args = {...}
403 | local countArgs = #args
404 | if countArgs == 1 and type(args[1]) == "table" then
405 |
406 | for name, buttons in pairs(args[1]) do
407 | if Menus.list[name] ~= nil then
408 | Menus.list[name].buttons = buttons
409 | end
410 | Citizen.Wait(1)
411 | end
412 |
413 | elseif countArgs == 2 then
414 |
415 | local name = args[1]
416 | local buttons = args[2]
417 | if Menus.list[name] ~= nil then
418 | Menus.list[name].buttons = buttons
419 | end
420 |
421 | end
422 |
423 | end
424 |
425 | --
426 | -- Set menu value
427 | --
428 | function SetMenuValue(...)
429 |
430 | local args = {...}
431 | local count = #args
432 |
433 | if count == 1 and type(args[1]) == "table" then
434 |
435 | for name, values in pairs(args[1]) do
436 | if Menus.list[name] ~= nil then
437 |
438 | local menu = Menus.list[name]
439 | for key, value in pairs(values) do
440 | menu[key] = value
441 | end
442 |
443 | end
444 | Citizen.Wait(1)
445 | end
446 |
447 | elseif count == 2 then
448 |
449 | local name = args[1]
450 | local values = args[2]
451 |
452 | if Menus.list[name] ~= nil then
453 |
454 | local menu = Menus.list[name]
455 | for key, value in pairs(values) do
456 | menu[key] = value
457 | end
458 |
459 | end
460 |
461 | end
462 |
463 | end
464 |
465 | --
466 | -- Add button
467 | --
468 | function AddMenuButton(...)
469 |
470 | local args = {...}
471 | local count = #args
472 |
473 | if count == 1 and type(args[1]) == "table" then
474 |
475 | for name, button in pairs(args[1]) do
476 | if Menus.list[name] ~= nil and type(buttons) == "table" then
477 |
478 | if buttons[1] ~= nil then
479 | for _, value in pairs(button) do
480 | table.insert(Menus.list[name].buttons, value)
481 | end
482 | else
483 | table.insert(Menus.list[name].buttons, button)
484 | end
485 |
486 | end
487 | Citizen.Wait(1)
488 | end
489 |
490 | elseif count == 2 then
491 |
492 | local name = args[1]
493 | local button = args[2]
494 |
495 | if Menus.list[name] ~= nil and type(button) == "table" then
496 |
497 | if buttons[1] ~= nil then
498 | for _, value in pairs(button) do
499 | table.insert(Menus.list[name].buttons, value)
500 | end
501 | else
502 | table.insert(Menus.list[name].buttons, button)
503 | end
504 |
505 | end
506 |
507 | end
508 |
509 | end
510 |
511 | --
512 | -- Add button
513 | --
514 | function AddMenuButton(name, button)
515 |
516 | if Menus.list[name] ~= nil and type(button) == "table" then
517 |
518 | if button[1] ~= nil then
519 | for _, value in pairs(button) do
520 | table.insert(Menus.list[name].buttons, value)
521 | end
522 | else
523 | table.insert(Menus.list[name].buttons, button)
524 | end
525 |
526 | end
527 |
528 | end
529 |
530 |
531 | --
532 | -- remove button
533 | --
534 | function RemoveMenuButton(...)
535 |
536 | local args = {...}
537 | local count = #args
538 |
539 | if count == 1 and type(args[1]) == "table" then
540 |
541 | for name, button in pairs(args[1]) do
542 | if menus.list[name] ~= nil then
543 | table.remove(menus.list[name].buttons, button)
544 | end
545 | Citizen.Wait(1)
546 | end
547 |
548 | elseif count == 2 then
549 |
550 | local name = args[1]
551 | local button = args[2]
552 |
553 | if menus.list[name] ~= nil then
554 | table.remove(menus.list[name].buttons, button)
555 | end
556 |
557 | end
558 |
559 | end
560 |
561 | --
562 | -- Select Button
563 | --
564 | function SelecteButton(menuName, number)
565 |
566 | assert(type(number) == "number", "[FT_LIBS] SelecteButton : number must be number")
567 | assert(type(number) >= 1, "[FT_LIBS] SelecteButton : can not be negative or zero")
568 |
569 | local menu = Menus.list[menuName]
570 | if menu ~= nil and MenuIsOpen() then
571 | local countBtns = TableLength(menu.buttons)
572 | if number <= countBtns then
573 | Menus.selectedButton = number
574 | end
575 | end
576 |
577 | end
578 |
579 | --
580 | -- Init instructionalButtons
581 | --
582 | local function menuInit()
583 |
584 | AddInstructionalButtons("ft_menu", {
585 | ["Up"] = 188,
586 | ["Down"] = 187,
587 | ["Enter"] = 201,
588 | ["Back"] = 177,
589 | })
590 |
591 | end
592 |
593 | --
594 | -- Show menu
595 | --
596 | function MenuFrame()
597 |
598 | menuInit()
599 |
600 | Citizen.CreateThread(function()
601 |
602 | while true do
603 |
604 | if MenuIsOpen() and not IsHudComponentActive(19) and not IsHudComponentActive(16) and not IsPauseMenuActive() then
605 |
606 | local current = Menus.curent
607 | local menu = Menus.list[current]
608 | local countBtns = TableLength(menu.buttons)
609 |
610 | if not Menus.freeze then
611 |
612 | local gameTimer = GetGameTimer()
613 | local getLastInputMethod = GetLastInputMethod()
614 |
615 | -- Fix
616 | if Menus.selectedButton > countBtns then
617 | Menus.selectedButton = countBtns
618 | end
619 |
620 | -- Block if menu is empty
621 | if Menus.selectedButton > 0 and Menus.selectedButton <= countBtns then
622 |
623 | -- Up
624 | if IsControlPressed(2, 188) and getLastInputMethod and (gameTimer - Menus.lastKeyPressed) > 150 then
625 |
626 | MoveUp(menu)
627 | Menus.lastKeyPressed = gameTimer
628 |
629 | end
630 |
631 | -- Down
632 | if IsControlPressed(2, 187) and getLastInputMethod and (gameTimer - Menus.lastKeyPressed) > 150 then
633 |
634 | MoveDown(menu)
635 | Menus.lastKeyPressed = gameTimer
636 |
637 | end
638 |
639 | -- Enter
640 | if IsControlJustReleased(2, 201) and getLastInputMethod then
641 |
642 | Exec(menu)
643 | PlaySound(-1, "SELECT", "HUD_FRONTEND_DEFAULT_SOUNDSET", 0, 0, 1)
644 |
645 | end
646 |
647 | end
648 |
649 | -- Back
650 | if IsControlJustReleased(2, 177) and not IsControlJustReleased(2, 322) and not IsControlJustReleased(2, 24) and not IsControlJustReleased(0, 25) and getLastInputMethod then
651 |
652 | BackBtn(menu)
653 | PlaySound(-1, "SELECT", "HUD_FRONTEND_DEFAULT_SOUNDSET", 0, 0, 1)
654 |
655 | end
656 |
657 | end
658 |
659 | -- Show Memu
660 | menu.Show(Menus.from, Menus.to, Menus.selectedButton)
661 | DisplayInstructionalButtons("ft_menu")
662 |
663 | elseif GetCurrentInstructionalButtons() == "ft_menu" then
664 |
665 | DisplayInstructionalButtons(false)
666 |
667 | end -- end check menu is open
668 |
669 | Citizen.Wait(5)
670 | end
671 |
672 | end)
673 |
674 | end
675 |
--------------------------------------------------------------------------------
/src/trigger/trigger.client.lua:
--------------------------------------------------------------------------------
1 | --
2 | -- @Project: FiveM Tools
3 | -- @Author: Samuelds
4 | -- @License: GNU General Public License v3.0
5 | -- @Source: https://github.com/FivemTools/ft_libs
6 | --
7 |
8 | --
9 | trigger = {}
10 |
11 | -- class table
12 | local Trigger = {}
13 |
14 | --
15 | -- Enter
16 | --
17 | function Trigger:Enter()
18 |
19 | Citizen.CreateThread(function()
20 |
21 | if self.enter.callback ~= nil then
22 | local callback = self.enter.callback
23 | callback(self.data)
24 | end
25 |
26 | if self.enter.eventClient ~= nil then
27 | TriggerEvent(self.enter.eventClient, self.data)
28 | end
29 |
30 | if self.enter.eventServer ~= nil then
31 | TriggerServerEvent(self.enter.eventServer, self.data)
32 | end
33 |
34 | end)
35 | end
36 |
37 | --
38 | --
39 | --
40 | function Trigger:Active()
41 | Citizen.CreateThread(function()
42 |
43 | if self.active.callback ~= nil then
44 | local callback = self.active.callback
45 | callback(self.data)
46 | end
47 |
48 | if self.active.eventClient ~= nil then
49 | TriggerEvent(self.active.eventClient, self.data)
50 | end
51 |
52 | if self.active.eventServer ~= nil then
53 | TriggerServerEvent(self.active.eventServer, self.data)
54 | end
55 |
56 | end)
57 | end
58 |
59 | --
60 | --
61 | --
62 | function Trigger:Exit()
63 | Citizen.CreateThread(function()
64 |
65 | if self.exit.callback ~= nil then
66 | local callback = self.exit.callback
67 | callback(self.data)
68 | end
69 |
70 | if self.exit.eventClient ~= nil then
71 | TriggerEvent(self.exit.eventClient, self.data)
72 | end
73 |
74 | if self.exit.eventServer ~= nil then
75 | TriggerServerEvent(self.exit.eventServer, self.data)
76 | end
77 |
78 | end)
79 | end
80 |
81 | --
82 | --
83 | --
84 | function trigger.new(data)
85 |
86 | assert(type(data.x) == "number", "Trigger : x must be number")
87 | assert(type(data.y) == "number", "Trigger : y must be number")
88 | assert(type(data.z) == "number", "Trigger : z must be number")
89 |
90 | local self = data
91 | self.weight = data.weight or 2.0
92 | self.height = data.height or 2.0
93 | self.enter = data.enter or {}
94 | self.exit = data.exit or {}
95 | self.active = data.active or {}
96 | self.data = data.data or {}
97 |
98 | if data.enable == nil or type(data.enable) ~= "boolean" then
99 | self.enable = true
100 | end
101 |
102 | setmetatable(self, { __index = Trigger })
103 | return self
104 |
105 | end
106 |
--------------------------------------------------------------------------------
/src/trigger/triggers.client.lua:
--------------------------------------------------------------------------------
1 | --
2 | -- @Project: FiveM Tools
3 | -- @Author: Samuelds
4 | -- @License: GNU General Public License v3.0
5 | -- @Source: https://github.com/FivemTools/ft_libs
6 | --
7 |
8 | local triggers = {}
9 | local enabledTriggers = {}
10 | local currentTriggers = {}
11 |
12 | --
13 | -- Enable Trigger
14 | --
15 | function EnableTrigger(...)
16 |
17 | local args = {...}
18 | local count = #args
19 |
20 | if count == 1 and type(args[1]) == "table" then
21 |
22 | for _, name in pairs(args[1]) do
23 | if triggers[name] ~= nil then
24 | enabledTriggers[name] = true
25 | end
26 | Citizen.Wait(10)
27 | end
28 |
29 | elseif count == 1 then
30 |
31 | local name = args[1]
32 | if triggers[name] ~= nil then
33 | enabledTriggers[name] = true
34 | end
35 |
36 | end
37 |
38 | end
39 |
40 | --
41 | -- Disable Trigger
42 | --
43 | function DisableTrigger(...)
44 |
45 | local args = {...}
46 | local count = #args
47 |
48 | if count == 1 and type(args[1]) == "table" then
49 |
50 | for _, name in pairs(args[1]) do
51 | enabledTriggers[name] = nil
52 | currentTriggers[name] = nil
53 | Citizen.Wait(10)
54 | end
55 |
56 | elseif count == 1 then
57 |
58 | local name = args[1]
59 | enabledTriggers[name] = nil
60 | currentTriggers[name] = nil
61 |
62 | end
63 |
64 | end
65 |
66 |
67 | --
68 | -- Switch Trigger
69 | --
70 | function SwitchTrigger(...)
71 |
72 | local args = {...}
73 | local count = #args
74 | if count == 1 and type(args[1]) == "table" then
75 |
76 | for name, status in pairs(args[1]) do
77 | if triggers[name] ~= nil then
78 | if status == true then
79 | EnableTrigger(name)
80 | elseif status == false then
81 | DisableTrigger(name)
82 | end
83 | end
84 | Citizen.Wait(10)
85 | end
86 |
87 | elseif count == 2 then
88 |
89 | local name = args[1]
90 | local status = args[2]
91 | if triggers[name] ~= nil then
92 | if status == true then
93 | EnableTrigger(name)
94 | else
95 | DisableTrigger(name)
96 | end
97 | end
98 |
99 | end
100 |
101 | end
102 |
103 | --
104 | -- Add Trigger
105 | --
106 | function AddTrigger(...)
107 |
108 | local args = {...}
109 | local count = #args
110 |
111 | if count == 1 and type(args[1]) == "table" then
112 |
113 | for name, value in pairs(args[1]) do
114 | if triggers[name] == nil then
115 | triggers[name] = trigger.new(value)
116 | if value.enable == nil or value.enable == true then
117 | EnableTrigger(name)
118 | end
119 | end
120 | Citizen.Wait(10)
121 | end
122 |
123 | elseif count == 2 then
124 |
125 | local name = args[1]
126 | local value = args[2]
127 | if triggers[name] == nil then
128 | triggers[name] = trigger.new(value)
129 |
130 | if value.enable == nil or value.enable == true then
131 | EnableTrigger(name)
132 | end
133 | end
134 |
135 | end
136 |
137 | end
138 |
139 | --
140 | -- Remove Trigger
141 | --
142 | function RemoveTrigger(...)
143 |
144 | local args = {...}
145 | local count = #args
146 |
147 | if count == 1 and type(args[1]) == "table" then
148 |
149 | for _, name in ipairs(args[1]) do
150 | if triggers[name] ~= nil then
151 | DisableTrigger(name)
152 | triggers[name] = nil
153 | end
154 | Citizen.Wait(10)
155 | end
156 |
157 | elseif count == 1 then
158 |
159 | local name = args[1]
160 | if triggers[name] ~= nil then
161 | DisableTrigger(name)
162 | triggers[name] = nil
163 | end
164 |
165 | end
166 |
167 | end
168 |
169 |
170 | --
171 | -- Set areas
172 | --
173 | function SetTrigger(...)
174 |
175 | local args = {...}
176 | local count = #args
177 |
178 | if count == 1 and type(args[1]) == "table" then
179 |
180 | for name, values in pairs(args[1]) do
181 | if triggers[name] ~= nil then
182 | local trigger = triggers[name]
183 | for key, value in pairs(values) do
184 | trigger[key] = value
185 | end
186 | end
187 | Citizen.Wait(1)
188 | end
189 |
190 | elseif count == 2 then
191 |
192 | local name = args[1]
193 | local values = args[2]
194 | if triggers[name] ~= nil then
195 | local trigger = triggers[name]
196 | for key, value in pairs(values) do
197 | trigger[key] = value
198 | end
199 | end
200 |
201 | end
202 |
203 | end
204 |
205 | --
206 | -- Current Trigger
207 | --
208 | function CurrentTrigger()
209 |
210 | return currentTriggers
211 |
212 | end
213 |
214 | --
215 | -- Check
216 | --
217 | function CheckTriggerThread()
218 |
219 | Citizen.CreateThread(function()
220 |
221 | while true do
222 |
223 | local playerCoords = GetPlayerCoords()
224 | for name, value in pairs(enabledTriggers) do
225 |
226 | local target = triggers[name]
227 | if target ~= nil then
228 | player_in = (GetDistanceBetween3DCoords(target.x, target.y, target.z, playerCoords.x, playerCoords.y, playerCoords.z) < (target.weight + 0.0) and math.abs(playerCoords.z - target.z) <= (target.height + 0.0))
229 | if player_in and currentTriggers[name] == nil then
230 | currentTriggers[name] = true
231 | target:Enter()
232 | elseif not player_in and currentTriggers[name] ~= nil then
233 | currentTriggers[name] = nil
234 | target:Exit()
235 | end
236 | end
237 |
238 | end
239 |
240 | Citizen.Wait(200)
241 | end
242 |
243 | end)
244 |
245 | end
246 |
247 | --
248 | -- Check
249 | --
250 | function ActiveTriggerThread()
251 |
252 | Citizen.CreateThread(function()
253 |
254 | while true do
255 |
256 | for name, value in pairs(currentTriggers) do
257 |
258 | local target = triggers[name]
259 | if target ~= nil and currentTriggers[name] ~= nil then
260 | target:Active()
261 | end
262 |
263 | end
264 | Citizen.Wait(5)
265 | end
266 |
267 | end)
268 |
269 | end
270 |
--------------------------------------------------------------------------------
/src/ui/instructionalButtons.client.lua:
--------------------------------------------------------------------------------
1 | --
2 | -- @Project: FiveM Tools
3 | -- @Author: Samuelds
4 | -- @License: GNU General Public License v3.0
5 | -- @Source: https://github.com/FivemTools/ft_libs
6 | --
7 | local instructionalsButtonsList = {}
8 | local currentInstructionalButtons = nil
9 | local scaleform = nil
10 |
11 | --
12 | --
13 | --
14 | local function CreateInstructionalButtons(data)
15 |
16 | Citizen.CreateThread(function()
17 |
18 | -- Citizen.Trace("oui")
19 | scaleform = RequestScaleformMovie("INSTRUCTIONAL_BUTTONS")
20 | while not HasScaleformMovieLoaded(scaleform) do
21 | Citizen.Wait(10)
22 | end
23 |
24 | PushScaleformMovieFunction(scaleform, "CLEAR_ALL")
25 | PopScaleformMovieFunctionVoid()
26 |
27 | local total = 0
28 | for text, value in pairs(data) do
29 | PushScaleformMovieFunction(scaleform, "SET_DATA_SLOT")
30 | PushScaleformMovieFunctionParameterInt(total)
31 | PushScaleformMovieFunctionParameterString(GetControlInstructionalButton(2, value, true))
32 | PushScaleformMovieFunctionParameterString(text)
33 | PopScaleformMovieFunctionVoid()
34 | total = total + 1
35 | Citizen.Wait(1)
36 | end
37 |
38 | PushScaleformMovieFunction(scaleform, "DRAW_INSTRUCTIONAL_BUTTONS")
39 | PopScaleformMovieFunctionVoid()
40 |
41 | PushScaleformMovieFunction(scaleform, "SET_BACKGROUND_COLOUR")
42 | PushScaleformMovieFunctionParameterInt(0)
43 | PushScaleformMovieFunctionParameterInt(0)
44 | PushScaleformMovieFunctionParameterInt(0)
45 | PushScaleformMovieFunctionParameterInt(80)
46 | PopScaleformMovieFunctionVoid()
47 |
48 | end)
49 |
50 | end
51 |
52 | --
53 | --
54 | --
55 | function AddInstructionalButtons(...)
56 |
57 | local args = {...}
58 | local count = #args
59 |
60 | if count == 1 and type(args[1]) == "table" then
61 |
62 | for name, value in pairs(args[1]) do
63 | Citizen.Wait(1)
64 | instructionalsButtonsList[name] = value
65 | end
66 |
67 | elseif count == 2 then
68 |
69 | local name = args[1]
70 | local value = args[2]
71 | instructionalsButtonsList[name] = value
72 |
73 | else
74 |
75 | return false
76 |
77 | end
78 |
79 | end
80 |
81 | --
82 | --
83 | --
84 | function RemoveInstructionalButtons(...)
85 |
86 | local args = {...}
87 | local count = #args
88 |
89 | if count == 1 and type(args[1]) == "table" then
90 |
91 | for name, value in pairs(args[1]) do
92 | instructionalsButtonsList[name] = nil
93 | Citizen.Wait(1)
94 | end
95 |
96 | elseif count == 1 then
97 |
98 | local name = args[1]
99 | instructionalsButtonsList[name] = nil
100 |
101 | else
102 |
103 | return false
104 |
105 | end
106 |
107 | end
108 |
109 | --
110 | --
111 | --
112 | function DisplayInstructionalButtons(name)
113 |
114 | if instructionalsButtonsList[name] ~= nil and currentInstructionalButtons ~= name then
115 |
116 | currentInstructionalButtons = name
117 | CreateInstructionalButtons(instructionalsButtonsList[name])
118 |
119 | elseif currentInstructionalButtons == name then
120 |
121 | return false
122 |
123 | else
124 |
125 | currentInstructionalButtons = nil
126 | scaleform = nil
127 |
128 | end
129 |
130 | end
131 |
132 | --
133 | --
134 | --
135 | function GetCurrentInstructionalButtons()
136 |
137 | return currentInstructionalButtons
138 |
139 | end
140 |
141 | --
142 | --
143 | --
144 | function InstructionalButtonsFrame()
145 |
146 | Citizen.CreateThread(function()
147 | while true do
148 |
149 | if currentInstructionalButtons ~= nil and instructionalsButtonsList[currentInstructionalButtons] ~= nil and scaleform ~= nil then
150 | DrawScaleformMovieFullscreen(scaleform, 255, 255, 255, 255, 0)
151 | end
152 | Citizen.Wait(5)
153 |
154 | end
155 | end)
156 |
157 | end
158 |
--------------------------------------------------------------------------------
/src/ui/ui.client.lua:
--------------------------------------------------------------------------------
1 | --
2 | -- @Project: FiveM Tools
3 | -- @Author: Samuelds
4 | -- @License: GNU General Public License v3.0
5 | -- @Source: https://github.com/FivemTools/ft_libs
6 | --
7 |
8 | --
9 | -- Display info in corner top left
10 | --
11 | function HelpPromt(text)
12 |
13 | SetTextComponentFormat("STRING")
14 | AddTextComponentString(text)
15 | DisplayHelpTextFromStringLabel(0, false, false, -1)
16 |
17 | end
18 |
19 | --
20 | -- Display loading promt
21 | --
22 | function LoadingPromt(settings)
23 |
24 | settings = settings or {}
25 | local text = settings.text or "Text"
26 | local type = settings.type or 4
27 | local time = settings.time or 1000
28 |
29 | N_0xaba17d7ce615adbf("STRING")
30 | AddTextComponentString(text)
31 | N_0xbd12f8228410d9b4(type)
32 | N_0x10d373323e5b9c0d()
33 |
34 | end
35 |
36 | --
37 | -- Display notification on the top map
38 | --
39 | function Notification(message)
40 |
41 | SetNotificationTextEntry('STRING')
42 | AddTextComponentString(message)
43 | DrawNotification(false, false)
44 |
45 | end
46 |
47 | --
48 | -- Display notification on the top map
49 | --
50 | function AdvancedNotification(settings)
51 |
52 | settings = settings or {}
53 | local icon = settings.icon or "CHAR_DEFAULT"
54 | local type = settings.type or 1
55 | local text = settings.text or ""
56 | local title = settings.title or ""
57 | local subTitle = settings.subTitle or ""
58 |
59 | SetNotificationTextEntry("STRING")
60 | AddTextComponentString(text)
61 | SetNotificationMessage(icon, icon, true, type, title, subTitle)
62 | DrawNotification(false, true)
63 |
64 | end
65 |
66 | --
67 | -- Display text on the screen
68 | --
69 | function Text(settings)
70 |
71 | settings = settings or {}
72 | local text = settings.text or "Text"
73 | local font = settings.font or 1
74 | local x = settings.x or 0
75 | local y = settings.y or 0
76 | local scale = settings.scale or 1.0
77 | local red = settings.red or 255
78 | local green = settings.green or 255
79 | local blue = settings.blue or 255
80 | local alpha = settings.alpha or 255
81 | local startWrap = settings.startWrap or 0.0
82 | local endWrap = settings.endWrap or 1.0
83 |
84 | SetTextFont(font)
85 | SetTextProportional(0)
86 | SetTextScale(scale, scale)
87 | SetTextColour(red, green, blue, alpha)
88 | SetTextWrap(startWrap, endWrap)
89 | if settings.center == true then
90 | SetTextCentre(true)
91 | end
92 | if settings.right == true then
93 | SetTextJustification(2)
94 | end
95 | SetTextEntry("STRING")
96 | AddTextComponentString(text)
97 | DrawText(x, y)
98 |
99 | end
100 |
101 | --
102 | -- Open input
103 | --
104 | function OpenTextInput(settings)
105 |
106 | settings = settings or {}
107 | local title = settings.title or "FMMC_KEY_TIP8"
108 | local defaultText = settings.defaultText or ""
109 | local maxInputLength = settings.maxInputLength or 255
110 |
111 | local customTitle = false
112 | if title ~= nil and settings.customTitle ~= nil and settings.customTitle == true then
113 | AddTextEntry('FT_TEXT', title)
114 | title = "FT_TEXT"
115 | end
116 |
117 | DisplayOnscreenKeyboard(true, title, "", defaultText, "", "", "", maxInputLength)
118 |
119 | while UpdateOnscreenKeyboard() == 0 do
120 | DisableAllControlActions(0)
121 | Citizen.Wait(10)
122 | end
123 |
124 | local result = GetOnscreenKeyboardResult()
125 | if result then
126 | return result
127 | else
128 | return nil
129 | end
130 |
131 | end
132 |
133 | --
134 | -- Text on center
135 | --
136 | function TextNotification(settings)
137 |
138 | settings = settings or {}
139 | local text = settings.text or "Text"
140 | local time = settings.time or 1000
141 |
142 | SetTextEntry_2("STRING")
143 | AddTextComponentString(text)
144 | DrawSubtitleTimed(time, true)
145 |
146 | end
147 |
148 | --
149 | -- 3D text
150 | --
151 | function Show3DText(settings)
152 |
153 | settings = settings or {}
154 | local x = settings.x or 0.0
155 | local y = settings.y or 0.0
156 | local z = settings.z + 1 or 0.0
157 | local text = settings.text or "3D TEXT"
158 | local font = settings.font or 1
159 | local red = settings.red or 255
160 | local green = settings.green or 255
161 | local blue = settings.blue or 255
162 | local alpha = settings.alpha or 255
163 | local scale = settings.scale or 1.0
164 | local onScreen, _x, _y = World3dToScreen2d(x, y, z)
165 |
166 | if onScreen then
167 | local px, py, pz = table.unpack(GetGameplayCamCoords())
168 | local dist = GetDistanceBetweenCoords(px, py, pz, x, y, z, 1)
169 | local scale = ( 1 / dist) * 2
170 | local fov = ( 1 / GetGameplayCamFov() ) * 100
171 | local scale = scale * fov
172 |
173 | SetTextScale(0.2 * scale, 0.2 * scale)
174 | SetTextFont(font)
175 | SetTextProportional(1)
176 | SetTextScale(scale, scale)
177 | SetTextColour(red, green, blue, alpha)
178 | SetTextDropshadow(0, 0, 0, 0, 255)
179 | SetTextEdge(2, 0, 0, 0, 150)
180 | SetTextDropShadow()
181 | SetTextOutline()
182 | SetTextEntry("STRING")
183 | SetTextCentre(1)
184 | AddTextComponentString(text)
185 | SetDrawOrigin(x, y, z, 0)
186 | DrawText(0.0, 0.0)
187 | ClearDrawOrigin()
188 | end
189 |
190 | end
191 |
192 | --
193 | -- Events
194 | --
195 | RegisterNetEvent('ft_libs:Notification')
196 | AddEventHandler('ft_libs:Notification', Notification)
197 |
198 | RegisterNetEvent('ft_libs:AdvancedNotification')
199 | AddEventHandler('ft_libs:AdvancedNotification', AdvancedNotification)
200 |
201 | RegisterNetEvent('ft_libs:TextNotification')
202 | AddEventHandler('ft_libs:TextNotification', TextNotification)
203 |
--------------------------------------------------------------------------------
/src/utils/utils.client.lua:
--------------------------------------------------------------------------------
1 | --
2 | -- @Project: FiveM Tools
3 | -- @Author: Samuelds
4 | -- @License: GNU General Public License v3.0
5 | -- @Source: https://github.com/FivemTools/ft_libs
6 | --
7 |
8 | --
9 | -- PrintTable event
10 | --
11 | RegisterNetEvent("ft_libs:PrintTable")
12 | AddEventHandler('ft_libs:PrintTable', function(value)
13 |
14 | print("---------[ft_libs : Debug]---------")
15 | PrintTable(value)
16 | print("-------------------------")
17 |
18 | end)
19 |
20 | --
21 | -- Debug mod
22 | --
23 | RegisterNetEvent("ft_libs:DebugMode")
24 | AddEventHandler('ft_libs:DebugMode', function(status)
25 |
26 | debugMode = status
27 | if debugMode == true then
28 | Citizen.Trace("[FT_LIBS] DEBUG MODE ENABLE")
29 | else
30 | Citizen.Trace("[FT_LIBS] DEBUG MODE DISABLE")
31 | end
32 |
33 | end)
34 |
--------------------------------------------------------------------------------
/src/utils/utils.common.lua:
--------------------------------------------------------------------------------
1 | --
2 | -- @Project: FiveM Tools
3 | -- @Author: Samuelds, Izio38
4 | -- @License: GNU General Public License v3.0
5 | -- @Source: https://github.com/FivemTools/ft_libs
6 | --
7 |
8 | --
9 | -- print table
10 | --
11 | function PrintTable(table, indent)
12 |
13 | if type(table) == "table" then
14 |
15 | if not indent then
16 | indent = 0
17 | end
18 |
19 | for k, v in pairs(table) do
20 | formatting = string.rep(" ", indent) .. k .. ": "
21 | if type(v) == "table" then
22 | print(formatting)
23 | PrintTable(v, indent + 1)
24 | elseif type(v) == "boolean" then
25 | if v then
26 | print(formatting .. "true")
27 | else
28 | print(formatting .. "false")
29 | end
30 | elseif type(v) == "nil" then
31 | print(formatting .. "nil")
32 | elseif type(v) == "function" then
33 | print(formatting .. "function")
34 | else
35 | print(formatting .. tostring(v) .. " (" .. type(v) .. ")")
36 | end
37 | end
38 |
39 | elseif type(table) == "boolean" then
40 |
41 | if table then
42 | print("true")
43 | else
44 | print("false")
45 | end
46 |
47 | elseif type(table) == "nil" then
48 |
49 | print("nil")
50 |
51 | elseif type(table) == "function" then
52 |
53 | print("function")
54 |
55 | else
56 |
57 | print(tostring(table) .. " (" .. type(table) .. ")")
58 |
59 | end
60 |
61 | end
62 |
63 | --
64 | -- Count table
65 | --
66 | function TableLength(table)
67 |
68 | local count = 0
69 | for _ in pairs(table) do
70 | count = count + 1
71 | end
72 | return count
73 |
74 | end
75 |
76 | --
77 | -- Round number
78 | --
79 | function Round(settings)
80 |
81 | settings = settings or {}
82 | local number = settings.number or 0
83 | local decimal = settings.decimal or 1
84 | local mult = 10 ^ decimal
85 | return math.floor(number * mult + 0.5) / mult
86 |
87 | end
88 |
89 | --
90 | -- Comat number
91 | --
92 | function CommaValue(settings)
93 |
94 | settings = settings or {}
95 | local number = settings.number or ""
96 | local separator = settings.separator or " "
97 |
98 | if settings.decimal ~= nil then
99 | number = Round({ number = number, decimal = settings.decimal })
100 | end
101 |
102 | while true do
103 | number, k = string.gsub(number, "^(-?%d+)(%d%d%d)", '%1' .. separator .. '%2')
104 | if k==0 then
105 | break
106 | end
107 | end
108 | return number
109 |
110 | end
111 |
112 | --
113 | -- Copy table
114 | --
115 | function Copy(t)
116 |
117 | if type(t) ~= "table" then
118 | return t
119 | end
120 | local meta = getmetatable(t)
121 | local target = {}
122 | for k, v in pairs(t) do
123 | target[k] = v
124 | end
125 | setmetatable(target, meta)
126 | return target
127 | end
128 |
129 | --
130 | -- Clone table
131 | --
132 | function Clone(t)
133 |
134 | if type(t) ~= "table" then
135 | return t
136 | end
137 | local meta = getmetatable(t)
138 | local target = {}
139 | for k, v in pairs(t) do
140 | if type(v) == "table" then
141 | target[k] = Clone(v)
142 | else
143 | target[k] = v
144 | end
145 | end
146 | setmetatable(target, meta)
147 | return target
148 |
149 | end
150 |
151 | --
152 | -- Debug print
153 | --
154 |
155 | debugMode = false
156 |
157 | --
158 | --
159 | --
160 | function SetDebug(status)
161 |
162 | assert(type(status) == "boolean" or boolean == 1 or boolean == 0, "SetDebug : status must be boolean or number")
163 |
164 | if status == 1 then
165 | status = true
166 | elseif status == 0 then
167 | status = false
168 | end
169 | debugMode = status
170 |
171 | end
172 |
173 | --
174 | --
175 | --
176 | function DebugPrint(...)
177 |
178 | if debugMode then
179 | local args = {...}
180 | local count = #args
181 |
182 | if count > 1 then
183 | print("------[ " .. args[2].. " ]------")
184 | PrintTable(args[1])
185 | print("-----[ END " .. args[2].. " ]-----")
186 | else
187 | print("------[ FT_DEBUG ]------")
188 | PrintTable(args[1])
189 | print("-----[ END FT_DEBUG ]-----")
190 | end
191 |
192 | end
193 |
194 | end
195 |
196 | --
197 | --
198 | --
199 | function TableContainsValue(table, data)
200 |
201 | for key, value in pairs(table) do
202 | if value == data then
203 | return key
204 | end
205 | end
206 | return false
207 |
208 | end
209 |
210 | --
211 | --
212 | --
213 | function GetLastContentValue(table)
214 |
215 | local total = #table
216 | return table[total]
217 |
218 | end
219 |
220 | --
221 | --
222 | --
223 | local charset = {}
224 | for i = 48, 57 do table.insert(charset, string.char(i)) end
225 | for i = 65, 90 do table.insert(charset, string.char(i)) end
226 | for i = 97, 122 do table.insert(charset, string.char(i)) end
227 |
228 | function GetRandomString(length)
229 |
230 | math.randomseed(GetGameTimer())
231 | if length > 0 then
232 | return GetRandomString(length - 1) .. charset[math.random(1, #charset)]
233 | else
234 | return ""
235 | end
236 |
237 | end
238 |
239 | --
240 | --
241 | --
242 | function GetDistanceBetween3DCoords(x1, y1, z1, x2, y2, z2)
243 |
244 | if x1 ~= nil and y1 ~= nil and z1 ~= nil and x2 ~= nil and y2 ~= nil and z2 ~= nil then
245 | return math.sqrt((x1 - x2) ^ 2 + (y1 - y2) ^ 2 + (z1 - z2) ^ 2)
246 | end
247 | return -1
248 |
249 | end
250 |
--------------------------------------------------------------------------------
/src/utils/utils.server.lua:
--------------------------------------------------------------------------------
1 | --
2 | -- @Project: FiveM Tools
3 | -- @Author: Samuelds
4 | -- @License: GNU General Public License v3.0
5 | -- @Source: https://github.com/FivemTools/ft_libs
6 | --
7 |
8 | --
9 | -- Get SeamID
10 | --
11 | function GetSteamIDFormSource(source)
12 |
13 | assert(type(source) == "number", "source must be number")
14 |
15 | local identifier = GetPlayerIdentifiers(source)
16 | if identifier[1] ~= nil and string.find(identifier[1], "steam") then
17 | return identifier[1]
18 | end
19 | return false
20 |
21 | end
22 |
23 | --
24 | -- Get IP
25 | --
26 | function GetIpFormSource(source)
27 |
28 | assert(type(source) == "number", "source must be number")
29 |
30 | local ip = GetPlayerEP(source)
31 | if ip ~= nil then
32 | return ip
33 | end
34 | return false
35 |
36 | end
37 |
38 | --
39 | -- PrintTable event
40 | --
41 | RegisterServerEvent("ft_libs:PrintTable")
42 | AddEventHandler('ft_libs:PrintTable', function(value)
43 |
44 | print("---------[ft_libs : Debug]---------")
45 | PrintTable(value)
46 | print("-------------------------")
47 |
48 | end)
49 |
50 | --
51 | --
52 | --
53 | AddEventHandler('onServerResourceStart', function(resource)
54 |
55 | if resource == 'ft_libs' then
56 | debugMode = GetConvar("ft_debug", "false")
57 |
58 | if debugMode == "true" then
59 | print("[FT_LIBS] DEBUG MODE ENABLE")
60 | debugMode = true
61 | else
62 | debugMode = false
63 | end
64 | end
65 |
66 | end)
67 |
68 | --
69 | --
70 | --
71 | RegisterServerEvent("ft_libs:OnClientReady")
72 | AddEventHandler('ft_libs:OnClientReady', function()
73 |
74 | TriggerClientEvent("ft_libs:DebugMode", source, debugMode)
75 |
76 | end)
77 |
78 | --
79 | -- Rcon comand
80 | --
81 | RegisterServerEvent("rconCommand")
82 | AddEventHandler("rconCommand", function(command, args)
83 |
84 | if command == "ft_debugMode" then
85 |
86 | local count = #args
87 | if count == 0 then
88 |
89 | if debugMode == true then
90 | debugMode = false
91 | else
92 | debugMode = true
93 | end
94 |
95 | elseif count == 1 then
96 |
97 | local arg = args[1]
98 | if arg == "true" or arg == "1" then
99 | debugMode = true
100 | elseif arg == "false" or arg == "0" then
101 | debugMode = false
102 | end
103 |
104 | end
105 |
106 | -- Print to console
107 | if debugMode == true then
108 | print("[FT_LIBS] DEBUG MODE ENABLE")
109 | else
110 | print("[FT_LIBS] DEBUG MODE DISABLE")
111 | end
112 |
113 | TriggerClientEvent("ft_libs:DebugMode", -1, debugMode)
114 | CancelEvent()
115 |
116 | end
117 |
118 | end)
119 |
120 |
--------------------------------------------------------------------------------