├── .gitattributes ├── LICENSE ├── bridge ├── client │ ├── framework.lua │ └── utilities.lua ├── server │ ├── framework.lua │ └── utilities.lua └── shared │ └── logging.lua ├── client ├── commands.lua ├── functions.lua ├── gui.lua └── main.lua ├── config.lua ├── fxmanifest.lua ├── language.lua └── server └── main.lua /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /bridge/client/framework.lua: -------------------------------------------------------------------------------- 1 | ESX = nil 2 | QBCore = nil 3 | 4 | if Framework == 'ESX' then 5 | ESX = exports['es_extended']:getSharedObject() 6 | elseif Framework == 'QB' then 7 | QBCore = exports['qb-core']:GetCoreObject() 8 | end 9 | 10 | local resourceName = GetCurrentResourceName() 11 | 12 | local currentLine = "BRDG>CLNT>FRAME #" 13 | 14 | SS_Core = { 15 | 16 | PlayerData = {}, 17 | PlayerJob = {}, 18 | 19 | FrameworkReady = function() 20 | if Framework == 'ESX' then 21 | while not ESX do Wait(500); end 22 | while ESX.GetPlayerData().job == nil do 23 | Wait(500) 24 | end 25 | SS_Core.PlayerData = SS_Core.GetPlayerData() 26 | return true 27 | elseif Framework == 'QB' then 28 | while not QBCore do Wait(500); end 29 | while not QBCore.Functions.GetPlayerData().job do Wait(500); end 30 | SS_Core.PlayerData = SS_Core.GetPlayerData() 31 | return true 32 | end 33 | return true 34 | end, 35 | 36 | SpawnVehicle = function(model, coords, heading, cb, networked) 37 | if Framework == 'ESX' then 38 | ESX.Game.SpawnVehicle(model, coords, heading, cb, networked) 39 | elseif Framework == 'QB' then 40 | QBCore.Functions.SpawnVehicle(model, cb, coords, networked) 41 | end 42 | SS_Log("debug","^4SpawnVehicle "..tostring(model), resourceName, currentLine.."42") 43 | end, 44 | 45 | DeleteVehicle = function(vehicle) 46 | if Framework == 'ESX' then 47 | ESX.Game.DeleteVehicle(vehicle) 48 | elseif Framework == 'QB' then 49 | QBCore.Functions.DeleteVehicle(vehicle) 50 | end 51 | SS_Log("debug","^4DeleteVehicle "..tostring(vehicle), resourceName, currentLine.."51") 52 | end, 53 | 54 | TriggerCallback = function(name, cb, ...) 55 | SS_Log("debug","^4TriggerCallback ^0[^3"..name.."^0", resourceName, currentLine.."55") 56 | if Framework == 'ESX' then 57 | ESX.TriggerServerCallback(name, cb, ...) 58 | elseif Framework == 'QB' then 59 | QBCore.Functions.TriggerCallback(name, cb, ...) 60 | end 61 | SS_Log("debug","^4TriggerCallback Finished ^0[^3"..name.."^0", resourceName, currentLine.."61") 62 | end, 63 | 64 | SetPlayerJob = function() 65 | local table = {} 66 | while not SS_Core.PlayerData.job do 67 | Wait(200) 68 | end 69 | if Framework == 'ESX' then 70 | table.name = SS_Core.PlayerData.job.name 71 | table.label = SS_Core.PlayerData.job.label 72 | table.grade = SS_Core.PlayerData.job.grade 73 | table.gradeLabel = SS_Core.PlayerData.job.grade_label 74 | table.onDuty = "N/A" 75 | --table.isPolice = Config.PoliceJobs[SS_Core.PlayerData.job.name] or false 76 | elseif Framework == 'QB' then 77 | table.name = SS_Core.PlayerData.job.name 78 | table.label = SS_Core.PlayerData.job.label 79 | table.grade = SS_Core.PlayerData.job.grade.level 80 | table.rank = SS_Core.PlayerData.job.grade.name 81 | table.onDuty = SS_Core.PlayerData.job.onduty or false 82 | --table.isPolice = Config.PoliceJobs[SS_Core.PlayerData.job.name] or false 83 | end 84 | --TriggerEvent('ss-bridge:onJobUpdate', SS_Core.PlayerJob) 85 | SS_Log("debug","^4Your Job: [^0"..table.label.."^4] Title: [^0"..table.name.."^4] Duty: [^0"..tostring(table.onDuty).."^4] Grade: [^0"..table.grade.."^4]^0", resourceName, currentLine.."85") 86 | SS_Core.PlayerJob = table 87 | end, 88 | 89 | GetPlayerData = function() 90 | if Framework == 'ESX' then 91 | SS_Core.PlayerData = ESX.GetPlayerData() 92 | SS_Core.SetPlayerJob() 93 | return ESX.GetPlayerData() 94 | elseif Framework == 'QB' then 95 | SS_Core.PlayerData = QBCore.Functions.GetPlayerData() 96 | SS_Core.SetPlayerJob() 97 | return QBCore.Functions.GetPlayerData() 98 | end 99 | end, 100 | 101 | GetJob = function() 102 | return SS_Core.PlayerJob 103 | end, 104 | 105 | Notification = function(data) 106 | if Config.Notification.enable then 107 | if Config.Notification.notifytype == 'qb' or Config.Notification.notifytype == 'esx' then 108 | if ESX ~= nil then 109 | ESX.ShowNotification(data.message, false, true, nil) 110 | elseif QBCore ~= nil then 111 | QBCore.Functions.Notify(data.message) 112 | end 113 | elseif Config.Notification.notifytype == 'ox' then 114 | SS_Utils.Notification(data) 115 | elseif Config.Notification.notifytype == 'okok' then 116 | SS_Utils.Notification(data) 117 | end 118 | end 119 | end, 120 | } 121 | 122 | RegisterNetEvent(Config.Triggers[Framework].job) 123 | AddEventHandler(Config.Triggers[Framework].job, function(job) 124 | SS_Core.PlayerData.job = job 125 | SS_Core.SetPlayerJob() 126 | end) -------------------------------------------------------------------------------- /bridge/client/utilities.lua: -------------------------------------------------------------------------------- 1 | if Framework == 'ESX' then 2 | ESX = exports['es_extended']:getSharedObject() 3 | elseif Framework == 'QB' then 4 | QBCore = exports['qb-core']:GetCoreObject() 5 | end 6 | 7 | local resourceName = GetCurrentResourceName() 8 | 9 | local currentLine = "BRDG>CLNT>UTIL #" 10 | 11 | 12 | SS_Utils = { 13 | 14 | Notification = function(data) 15 | if Config.Notification.notifytype == 'ox' then 16 | lib.notify({ 17 | title = data.title, 18 | description = data.message, 19 | type = data.type, 20 | position = 'top-right', 21 | }) 22 | elseif Config.Notification.notifytype == 'okok' then 23 | exports['okokNotify']:Alert(data.title, data.message, 6000, data.type) 24 | elseif Config.Notification.notifytype == 't-notify' then 25 | exports['t-notify']:Custom({title = data.title, style = data.type, message = data.message, sound = true}) 26 | end 27 | end, 28 | 29 | EmailNotification = function(id,data) 30 | if Config.Notification.email.type == "qb-phone" then 31 | TriggerServerEvent("qb-phone:server:sendNewMail", data,id) 32 | elseif Config.Notification.email.type == "qs-phone" then 33 | TriggerServerEvent('qs-smartphone:server:sendNewMail', data) 34 | elseif Config.Notification.email.type == "gks-phone" then 35 | exports["gksphone"]:SendNewMail(data) 36 | elseif Config.Notification.email.type == "lb-phone" then 37 | TriggerServerEvent("ss-knowledge:server:lb-phone:sendMail", data) 38 | end 39 | end, 40 | 41 | GetIdentification = function(data) 42 | SS_Log("id_debug","^4GetIdentification ^0[^3"..PlayerPedId().."^0]", resourceName, currentLine.."59") 43 | if Framework == "QB" then 44 | return QBCore.Functions.GetPlayerData().citizenid 45 | elseif Framework == "ESX" then 46 | return ESX.PlayerData.identifier 47 | end 48 | end, 49 | 50 | CustomJsonTable = function(tbl) 51 | local result = "\n" 52 | for key, value in pairs(tbl) do 53 | if next(tbl, key) == nil then 54 | result = result.."[^5"..key.."^0] [^3" .. tostring(value) .. "^0" 55 | else 56 | result = result.."[^5"..key.."^0] [^3" .. tostring(value) .. "^0]\n" 57 | end 58 | end 59 | return result 60 | end, 61 | } 62 | 63 | RegisterNetEvent('ss-knowledge:bridge:utilities:notification', function(msg) 64 | SS_Utils.Notification(msg) 65 | end) -------------------------------------------------------------------------------- /bridge/server/framework.lua: -------------------------------------------------------------------------------- 1 | ESX = nil 2 | QBCore = nil 3 | 4 | if Framework == 'ESX' then 5 | ESX = exports['es_extended']:getSharedObject() 6 | elseif Framework == 'QB' then 7 | QBCore = exports['qb-core']:GetCoreObject() 8 | end 9 | 10 | local resourceName = GetCurrentResourceName() 11 | 12 | local currentLine = "BRDG>SRVR>FRAME #" 13 | 14 | SS_Core = { 15 | 16 | Notification = function(src, data) 17 | if Config.Notification.enable then 18 | if Framework == 'ESX' then 19 | TriggerClientEvent('esx:showNotification', src, data.message) 20 | elseif Framework == 'QB' then 21 | TriggerClientEvent('QBCore:Notify', src, data.message) 22 | end 23 | else 24 | TriggerClientEvent('ss-knowledge:bridge:utilities:notification', src, data) 25 | end 26 | end, 27 | 28 | RegisterCallback = function(name, cb) 29 | SS_Log("debug", "^4RegisterCallback ^0[^3"..name.."^0", resourceName, currentLine.."29") 30 | if Framework == 'ESX' then 31 | ESX.RegisterServerCallback(name, cb) 32 | elseif Framework == 'QB' then 33 | QBCore.Functions.CreateCallback(name, cb) 34 | end 35 | end, 36 | } 37 | 38 | SS_Core.Player = { 39 | 40 | GetSource = function(src) 41 | local xPlayer = SS_Core.Player.GetFromId(tonumber(src)) 42 | while xPlayer == nil do 43 | Wait(500) 44 | xPlayer = SS_Core.Player.GetFromId(tonumber(src)) 45 | end 46 | SS_Log("id_debug", "^4Server Side - GetSource ^0[^3"..tonumber(src).."^0]", resourceName, currentLine.."46") 47 | if Framework == 'ESX' then 48 | return xPlayer.source 49 | elseif Framework == 'QB' then 50 | return xPlayer.PlayerData.source 51 | end 52 | end, 53 | 54 | GetFromId = function(src) 55 | SS_Log("id_debug", "^4Server Side - GetFromId ^0[^3"..(src).."^0]", resourceName, currentLine.."55") 56 | if Framework == 'ESX' then 57 | return ESX.GetPlayerFromId(src) 58 | elseif Framework == 'QB' then 59 | return QBCore.Functions.GetPlayer(src) 60 | end 61 | end, 62 | 63 | GetIdentifier = function(src) 64 | SS_Log("id_debug", "^4Server Side - GetIdentifier ^0[^3"..tonumber(src).."^0]", resourceName, currentLine.."64") 65 | local Player = SS_Core.Player.GetFromId(tonumber(src)) 66 | if Player == nil then return end 67 | if Framework == 'ESX' then 68 | return Player.identifier 69 | elseif Framework == 'QB' then 70 | return Player.PlayerData.citizenid 71 | end 72 | end, 73 | 74 | GetCitizenName = function(src) 75 | SS_Log("id_debug", "^4Server Side - GetCitizenName ^0[^3"..tonumber(src).."^0]", resourceName, currentLine.."75") 76 | local Player = SS_Core.Player.GetFromId(tonumber(src)) 77 | if Framework == 'ESX' then 78 | return Player.getName() 79 | elseif Framework == 'QB' then 80 | return Player.PlayerData.charinfo.firstname.. " "..Player.PlayerData.charinfo.lastname 81 | end 82 | end, 83 | IsAdmin = function(src) 84 | local permissions = Config.AdminOptions.ranks 85 | SS_Log("debug", "^4Admin command ranks^0] [^3"..table.concat(permissions, "^0,^3").."^0", resourceName, currentLine.."85") 86 | for k,v in pairs(permissions) do 87 | if IsPlayerAceAllowed(src, v) then 88 | SS_Log("debug", "^4Command perm granted to ^0[^3"..src.."^0] ^4Perm level^0 [^3"..v.."^0", resourceName, currentLine.."88") 89 | return true 90 | end 91 | end 92 | return false 93 | end, 94 | 95 | } 96 | 97 | SS_Core.RegisterCallback("ss-knowledge:server:fetchBranches", function(source, cb, otherID) 98 | local branches = {} 99 | if otherID == nil then 100 | branches = FetchDBBranches(source) 101 | else 102 | branches = FetchDBBranches(otherID) 103 | end 104 | if branches ~= nil then 105 | SS_Log("debug", "^4Fetch Branches^0] "..SS_Utils.CustomJsonEncode(branches).."^0", resourceName, currentLine.."103") 106 | end 107 | cb(branches) 108 | end) 109 | 110 | SS_Core.RegisterCallback("ss-knowledge:server:CheckAdminCommands", function(source, cb) 111 | cb(SS_Core.Player.IsAdmin(source)) 112 | end) 113 | 114 | SS_Core.RegisterCallback("ss-knowledge:server:getPlayerName", function(source, cb, oID) 115 | local name = nil 116 | if oID == nil then 117 | name = SS_Core.Player.GetCitizenName(source) 118 | else 119 | name = SS_Core.Player.GetCitizenName(oID) 120 | end 121 | cb(tostring(name.." ["..(oID or source).."]")) 122 | end) -------------------------------------------------------------------------------- /bridge/server/utilities.lua: -------------------------------------------------------------------------------- 1 | local ResourceName = GetCurrentResourceName() 2 | 3 | SS_Utils = { 4 | 5 | VersionCheck = function(resource,repository, paid) 6 | local currentVersion = GetResourceMetadata(resource, 'version', 0) 7 | if not currentVersion then 8 | print("^4Please contact ^0[^5Sky's Scripts^0]^4 for support and reference this error:^0 ".."^3SS_Util.VersionCheck^0, ^1Can't find current resource version for '%s'^0[^3"..resource.."^0]") 9 | return 10 | end 11 | 12 | SetTimeout(1000, function() 13 | PerformHttpRequest(('https://api.github.com/repos/%s/releases/latest'):format(repository), function(status, response) 14 | if status ~= 200 then 15 | if status == 403 or status == 429 then 16 | print("[^5Sky's Scripts^0] ^1Update check for ^0[^3"..resource.."^0] ^1failed. ^0[^3Git API Limitations^0]\n^4You may still get this error for a while when restarting the script or server.^0") 17 | else 18 | print("^4Please contact ^0[^5Sky's Scripts^0]^4 for support and reference this error:^0 [^3SS_Util.VersionCheck^0]\n^1Check ^0[^3"..repository.."^0] ^4Status^0 [^3"..status.."^0]") 19 | end 20 | return end 21 | 22 | response = json.decode(response) 23 | if response.prerelease then return end 24 | 25 | local latestVersion = response.tag_name:match('%d+%.%d+%.%d+') or response.tag_name:match('%d+%.%d+') 26 | if not latestVersion then 27 | return 28 | elseif latestVersion == currentVersion then 29 | print("[^5Sky's Scripts^0] [^3"..string.upper(string.match(resource, "ss%_(.+)")).."^0] ^2is up to date^0 - ^4Your Version:^0 [^3"..currentVersion.."^0]") 30 | else 31 | local cv = { string.strsplit('.', currentVersion) } 32 | local lv = { string.strsplit('.', latestVersion) } 33 | 34 | local maxParts = math.min(#cv, #lv) 35 | for i = 1, maxParts do 36 | local current, minimum = tonumber(cv[i] or 0), tonumber(lv[i] or 0) 37 | if i == maxParts then 38 | if (#cv > i and current == minimum and tonumber(cv[i+1] or 0) > tonumber(lv[i+1] or 0)) or (#cv >= i and current > minimum) then 39 | if not paid then 40 | print("[^5Sky's Scripts^0] [^3"..string.upper(string.match(resource, "ss%_(.+)")).."^0] ^4is newer than expected. Your Version:^0 [^3"..currentVersion.."^0] ^4Latest Version:^0 [^3"..latestVersion.."^0]\n^1Please downgrade to latest release through the github or keymaster for ^0[^3"..resource.."^0]\n[^5https://github.com/"..repository.."/releases/latest^0]") 41 | elseif paid then 42 | print("[^5Sky's Scripts^0] [^3"..string.upper(string.match(resource, "ss%_(.+)")).."^0] ^4is newer than expected. Your Version:^0 [^3"..currentVersion.."^0] ^4Latest Version:^0 [^3"..latestVersion.."^0]\n^1Please downgrade to latest release for ^0[^3"..resource.."^0] through the keymaster.") 43 | end 44 | end 45 | end 46 | if current ~= minimum then 47 | if current < minimum then 48 | if not paid then 49 | print("[^5Sky's Scripts^0] [^3"..string.upper(string.match(resource, "ss%_(.+)")).."^0] ^4is outdated. Your Version:^0 [^3"..currentVersion.."^0] ^4Latest Version:^0 [^3"..latestVersion.."^0]\n^1Please update ^0[^3"..resource.."^0]^4 through the github or keymaster.^0\n[^5https://github.com/"..repository.."/releases/latest^0]") 50 | else 51 | print("[^5Sky's Scripts^0] [^3"..string.upper(string.match(resource, "ss%_(.+)")).."^0] ^4is outdated. Your Version:^0 [^3"..currentVersion.."^0] ^4Latest Version:^0 [^3"..latestVersion.."^0]\n^1Please update ^0[^3"..resource.."^0]^4 through keymaster.^0") 52 | end 53 | end 54 | end 55 | end 56 | end 57 | end, 'GET') 58 | end) 59 | end, 60 | 61 | CheckForDBColumn = function(table,identifier) 62 | MySQL.query("SHOW COLUMNS FROM "..table.." LIKE '"..identifier.."';", {}, function(result) 63 | if #result == 0 then 64 | SS_Log("warn", "^4Database table column ^0[^3"..string.upper(identifier).."^0]^4 has not been found in ^0[^3"..string.upper(table).."^0]^4 Inserting column into correct table.",ResourceName) 65 | MySQL.query("ALTER TABLE "..table.." ADD COLUMN "..identifier.." LONGTEXT") 66 | SS_Log("success", "^4Database table column ^0[^3"..string.upper(identifier).."^0]^4 has now been created in ^0[^3"..string.upper(table).."^0",ResourceName) 67 | end 68 | if result and #result > 0 then 69 | SS_Log("success", "^4Database table column ^0[^3"..string.upper(identifier).."^0]^4 has already been created in ^0[^3"..string.upper(table).."^0",ResourceName) 70 | return 71 | end 72 | end) 73 | end, 74 | 75 | CheckForDBTable = function(table) 76 | MySQL.query("SHOW TABLES LIKE '"..table.."';", {}, function(result) 77 | if result and #result > 0 then 78 | SS_Log("success", "^4Database Table ^0[^3"..string.upper(table).."^0]^4 has already been created",ResourceName) 79 | return 80 | else 81 | SS_Log("warn", "^4Database Table ^0[^3"..string.upper(table).."^0]^4 has not been created. Inserting table into database",ResourceName) 82 | MySQL.query("CREATE TABLE IF NOT EXISTS "..table.." (id INT AUTO_INCREMENT, PRIMARY KEY(id));") 83 | SS_Log("success", "^4Database Table ^0[^3"..string.upper(table).."^0]^4 has now been created",ResourceName) 84 | end 85 | end) 86 | end, 87 | 88 | CustomJsonEncode = function(tbl) 89 | local result = "\n" 90 | for key, value in pairs(tbl) do 91 | if next(tbl, key) == nil then 92 | result = result.."[^5"..key.."^0] [^3" .. tostring(value) .. "^0" 93 | else 94 | result = result.."[^5"..key.."^0] [^3" .. tostring(value) .. "^0]\n" 95 | end 96 | end 97 | return result 98 | end, 99 | } -------------------------------------------------------------------------------- /bridge/shared/logging.lua: -------------------------------------------------------------------------------- 1 | local colorCodes = { 2 | error = "^1ERROR^0", 3 | debug = "^3DEBUG^0", 4 | warn = "^5WARN^0", 5 | info = "^2INFO^0", 6 | success = "^2SUCCESS^0", 7 | id_debug = "^3ID DEBUG^0", 8 | } 9 | 10 | SS_Log = function(warntype, message, asset, isClient, location, ...) 11 | local timestamp, logFormat, extraInfo = nil, nil, "" 12 | if not colorCodes[warntype] then 13 | warntype = "info" 14 | end 15 | if (warntype == "id_debug" and not (Config.Debug.enable and Config.Debug.idType)) or (warntype == "debug" and not Config.Debug.enable) then 16 | return 17 | end 18 | if os and type(os.date) == "function" then 19 | timestamp = os.date("^6%H:%M:%S^0] [^6%d-%m-%Y") 20 | logFormat = "^0["..timestamp.."^0] [^5Sky's Scripts^0] [^3"..asset.."^0] ["..colorCodes[warntype].."^0]\n[^3"..message.."^0]" 21 | else 22 | logFormat = "[^5Sky's Scripts^0] [^3"..asset.."^0] [^3"..colorCodes[warntype].."^0]\n[^3"..message.."^0]" 23 | end 24 | if (warntype == "debug" or warntype == "id_debug") and location then 25 | extraInfo = " [^3"..location.."^0]" 26 | end 27 | if ... then 28 | extraInfo = extraInfo.." [^3%s^0]" 29 | end 30 | local formattedMessage = string.format(logFormat..extraInfo, table.concat({...}, ", ") or "") 31 | print(formattedMessage) 32 | end -------------------------------------------------------------------------------- /client/commands.lua: -------------------------------------------------------------------------------- 1 | local resourceName = GetCurrentResourceName() 2 | 3 | local currentLine = "CLNT>COMMS #" 4 | 5 | if Config.AdminOptions.enable then 6 | RegisterNetEvent(Config.Triggers[Framework].load, function() 7 | SS_Core.TriggerCallback("ss-knowledge:server:CheckAdminCommands", function(results) 8 | TriggerEvent("ss-knowledge:client:debug", "^4Admin permission results: ^0 ^3"..tostring(results)) 9 | if results then 10 | GiveAdminCommands() 11 | end 12 | end) 13 | end) 14 | end 15 | 16 | if Config.ChatCommand.enable then 17 | RegisterCommand(Config.ChatCommand.commandname, function() 18 | CreateKnowledgeBranchList() 19 | end, false) 20 | TriggerEvent("chat:addSuggestion", "/"..Config.ChatCommand.commandname, Lang['commandname_desc']) 21 | end 22 | 23 | GiveAdminCommands = function() 24 | RegisterCommand(Config.AdminOptions.commands.addxp, function(source,args,rawCommand) 25 | if args[1] == nil or args[2] == nil or args[3] == nil then 26 | return SS_Core.Notification({title = Lang['missing_args_title'], message = Lang['missing_args_message']:format(Config.AdminOptions.commands.addxp)}) 27 | end 28 | SS_Core.TriggerCallback("ss-knowledge:server:fetchBranches", function(data) 29 | local PlayerBranches = data 30 | if type(PlayerBranches[args[2]]) ~= "number" then 31 | PlayerBranches[args[2]] = tonumber(PlayerBranches[args[2]].Current) or 0 32 | end 33 | SS_Log("debug","^4Before adding xp: ^3"..PlayerBranches[args[2]], resourceName, currentLine.."30") 34 | PlayerBranches[args[2]] = PlayerBranches[args[2]] + args[3] 35 | local Levels = Config.Branches[args[2]].customLevels or Config.DefaultLevels 36 | if PlayerBranches[args[2]] < 0 then 37 | PlayerBranches[args[2]] = 0 38 | end 39 | if PlayerBranches[args[2]] > Levels[#Levels].maxxp then 40 | PlayerBranches[args[2]] = Levels[#Levels].maxxp 41 | end 42 | SS_Log("debug","^4After adding xp: ^3"..PlayerBranches[args[2]], resourceName, currentLine.."39") 43 | TriggerServerEvent("ss-knowledge:server:updateBranches", json.encode(PlayerBranches), args[1]) 44 | end, args[1]) 45 | end) 46 | TriggerEvent("chat:addSuggestion", "/"..Config.AdminOptions.commands.addxp, Lang['addxp_help_arg_1'],{{ name = Lang['addxp_name_arg_2'], help = Lang['addxp_help_arg_2'] }, { name = Lang['addxp_name_arg_3'], help = Lang['addxp_help_arg_3'] }, { name = Lang['addxp_name_arg_4'], help = Lang['addxp_help_arg_4']}}) 47 | 48 | RegisterCommand(Config.AdminOptions.commands.removexp, function(source,args,rawCommand) 49 | if args[1] == nil or args[2] == nil or args[3] == nil then 50 | return SS_Core.Notification({title = Lang['missing_args_title'], message = Lang['missing_args_message']:format(Config.AdminOptions.commands.removexp)}) 51 | end 52 | SS_Core.TriggerCallback("ss-knowledge:server:fetchBranches", function(data) 53 | local PlayerBranches = data 54 | SS_Log("debug","^4Before removing xp: ^3"..PlayerBranches[args[2]], resourceName, currentLine.."51") 55 | PlayerBranches[args[2]] = PlayerBranches[args[2]] - args[3] 56 | local Levels = Config.Branches[args[2]].customLevels or Config.DefaultLevels 57 | if PlayerBranches[args[2]] < 0 then 58 | PlayerBranches[args[2]] = 0 59 | end 60 | if PlayerBranches[args[2]] > Levels[#Levels].maxxp then 61 | PlayerBranches[args[2]] = Levels[#Levels].maxxp 62 | end 63 | SS_Log("debug","^4After removing xp: ^3"..PlayerBranches[args[2]], resourceName, currentLine.."60") 64 | TriggerServerEvent("ss-knowledge:server:updateBranches", json.encode(PlayerBranches), args[1]) 65 | end, args[1]) 66 | end) 67 | TriggerEvent("chat:addSuggestion", "/"..Config.AdminOptions.commands.removexp, Lang['removexp_help_arg_1'],{{ name = Lang['removexp_name_arg_2'], help = Lang['removexp_help_arg_2'] }, { name = Lang['removexp_name_arg_3'], help = Lang['removexp_help_arg_3'] }, { name = Lang['removexp_name_arg_4'], help = Lang['removexp_help_arg_4']}}) 68 | 69 | RegisterCommand(Config.AdminOptions.commands.checkplayerbranch, function(source,args,rawCommand) 70 | if args[1] == nil or args[2] == nil then 71 | return SS_Core.Notification({title = Lang['missing_args_title'], message = Lang['missing_args_message']:format(Config.AdminOptions.commands.checkplayerbranch)}) 72 | end 73 | SS_Core.TriggerCallback("ss-knowledge:server:fetchBranches", function(data) 74 | local PlayerBranches = data 75 | SS_Core.TriggerCallback("ss-knowledge:server:getPlayerName", function(name) 76 | SS_Core.Notification({title = Lang['check_player_branch_title'], message = name.." "..Lang['check_player_branch_message']:format(PlayerBranches[args[2]],args[2])}) 77 | end, tonumber(args[1])) 78 | end, tonumber(args[1])) 79 | end) 80 | TriggerEvent("chat:addSuggestion", "/"..Config.AdminOptions.commands.checkplayerbranch, Lang['checkxp_help_arg_1'],{{ name = Lang['checkxp_name_arg_2'], help = Lang['checkxp_help_arg_2'] }, { name = Lang['checkxp_name_arg_3'], help = Lang['checkxp_help_arg_3'] }}) 81 | end -------------------------------------------------------------------------------- /client/functions.lua: -------------------------------------------------------------------------------- 1 | local resourceName = GetCurrentResourceName() 2 | 3 | local currentLine = "CLNT>FUNC #" 4 | 5 | 6 | GetKnowledgeBranch = function(currentBranch, branch) 7 | local tier = 0 8 | if type(currentBranch) ~= "number" then 9 | currentBranch = tonumber(currentBranch.Current) or 0 10 | end 11 | SS_Log("debug","^4Branch^0] [^3"..branch.. "^0] [^4XP^0] [^3"..tostring(currentBranch).."^0", resourceName, currentLine.."8") 12 | if Config.Branches[branch] == nil then 13 | SS_Log("warn","^1Branch is missing from config's branch list. Missing branch: ^0[^3"..tostring(branch).."^0", resourceName) 14 | end 15 | local tiers = Config.Branches[branch].customLevels or Config.DefaultLevels 16 | local tierLimits = tiers[1] 17 | for _, branchData in ipairs(tiers) do 18 | if currentBranch > branchData.minxp and currentBranch <= branchData.maxxp then 19 | if branchData.title then 20 | return branchData.title, branchData 21 | end 22 | return tier, branchData 23 | end 24 | if currentBranch > branchData.maxxp then 25 | tier = tier+1 26 | tierLimits = branchData 27 | end 28 | end 29 | if #tiers == tier then 30 | tier = #tiers 31 | end 32 | if tierLimits.title then 33 | return tierLimits.title, tierLimits 34 | end 35 | return tier, tierLimits 36 | end 37 | exports('GetKnowledgeBranch', GetKnowledgeBranch) 38 | 39 | GetBranchTier = function(currentBranch, branch) 40 | local tier = 1 41 | local tiers = Config.Branches[branch].customLevels or Config.DefaultLevels 42 | for Tier, branchData in ipairs(tiers) do 43 | if currentBranch >= branchData.minxp and currentBranch < branchData.maxxp then 44 | return Tier 45 | end 46 | if currentBranch > branchData.maxxp then 47 | tier = tier+1 48 | end 49 | if #tiers == tier then 50 | tier = #tiers 51 | return tier 52 | end 53 | end 54 | end 55 | exports('GetBranchTier', GetBranchTier) 56 | 57 | GetCurrentKnowledgeBranch = function(branch) 58 | if Config.Branches[branch] then 59 | if CurrentBranches[branch] then 60 | return GetKnowledgeBranch(CurrentBranches[branch],branch) 61 | else 62 | SS_Log("warn","^1User missing branch from config list. Missing branch: ^0[^3"..tostring(branch).."^0]", resourceName, currentLine.."59") 63 | return 0 64 | end 65 | else 66 | SS_Log("warn","^1No branch found in config. Missing branch: ^0[^3"..tostring(branch).."^0]", resourceName, currentLine.."63") 67 | return 0 68 | end 69 | end 70 | exports('GetCurrentKnowledgeBranch', GetCurrentKnowledgeBranch) 71 | 72 | FetchKnowledgeBranch = function() 73 | SS_Core.TriggerCallback("ss-knowledge:server:fetchBranches", function(data) 74 | if data then 75 | SS_Log("debug","^4Knowledge Branches^0] "..SS_Utils.CustomJsonTable(data).."^0", resourceName, currentLine.."72") 76 | CurrentBranches = data 77 | else 78 | SS_Log("warn",'^1If you were logging out or not fully loaded in city please ignore.\n^1If not branches found on load of FetchKnowledgeBranch.^0', resourceName, currentLine.."75") 79 | end 80 | end) 81 | end 82 | 83 | UpdateKnowledgeBranch = function(branch, amount, LoseBranchKnowledge) 84 | if not CurrentBranches[branch] then 85 | SS_Log("warn","^4"..Lang['branch_doesnt_exist']:format(branch).."^0", resourceName, currentLine.."82") 86 | return 87 | end 88 | local id = SS_Utils.GetIdentification() 89 | local BranchXP = CurrentBranches[branch] 90 | local Tier = 0 91 | if type(BranchXP) == "table" then 92 | BranchXP = BranchXP.Current 93 | Tier = GetBranchTier(BranchXP,branch) 94 | else 95 | Tier = GetBranchTier(BranchXP,branch) 96 | end 97 | local Levels = Config.Branches[branch].customLevels or Config.DefaultLevels 98 | if BranchXP + tonumber(amount) < 0 then 99 | CurrentBranches[branch] = 0 100 | elseif Levels ~= {} or nil then 101 | if BranchXP + tonumber(amount) > Levels[#Levels].maxxp then 102 | CurrentBranches[branch] = Levels[#Levels].maxxp 103 | if Config.Notification.enable then 104 | SS_Core.Notification({title = Lang["notification_max_knowledge_title"], message = Lang["notification_max_knowledge_message"]:format(branch)}) 105 | end 106 | else 107 | CurrentBranches[branch] = CurrentBranches[branch] + amount 108 | end 109 | elseif BranchXP + tonumber(amount) > Levels[#Levels].maxxp then 110 | CurrentBranches[branch] = Levels[#Levels].maxxp 111 | if Config.Notification.enable then 112 | SS_Core.Notification({title = Lang["notification_max_knowledge_title"], message = Lang["notification_max_knowledge_message"]:format(branch)}) 113 | end 114 | else 115 | CurrentBranches[branch] = CurrentBranches[branch] + amount 116 | end 117 | if Config.Branches[branch].messages.enable then 118 | if tonumber(amount) > 0 then 119 | for k, v in pairs(Config.Branches[branch].messages.positive) do 120 | if CurrentBranches[branch] > v.xp and BranchXP < v.xp then 121 | if Config.Branches[branch].messages.notifytype == "notification" then 122 | SS_Core.Notification({title = v.subject, message = v.message}) 123 | elseif Config.Branches[branch].messages.notifytype == "email" then 124 | SS_Utils.EmailNotification(id,{message = v.message, sender = v.sender, subject = v.subject}) 125 | end 126 | end 127 | end 128 | elseif tonumber(amount) < 0 then 129 | for k, v in pairs(Config.Branches[branch].messages.negative) do 130 | if CurrentBranches[branch] < v.xp and BranchXP > v.xp then 131 | if Config.Branches[branch].messages.notifytype == "notification" then 132 | SS_Core.Notification({title = v.subject, message = v.message}) 133 | elseif Config.Branches[branch].messages.notifytype == "email" then 134 | SS_Utils.EmailNotification(id,{message = v.message, sender = v.sender, subject = v.subject}) 135 | end 136 | end 137 | end 138 | elseif tonumber(amount) == 0 then 139 | end 140 | end 141 | if Config.Notification.enable and tonumber(amount) > 0 then 142 | SS_Core.Notification({title = Lang["notification_add_knowledge_title"], message = Lang["notification_add_knowledge_to_branch"]:format(amount, branch)}) 143 | if Config.Notification.email.enable and (Levels ~= {} or nil) then 144 | if Levels[tonumber(Tier+1)] ~= nil then 145 | if CurrentBranches[branch] > Levels[Tier].maxxp and BranchXP < Levels[tonumber(Tier+1)].minxp then 146 | SS_Utils.EmailNotification(id,{message = Lang['level_up_email_message']:format(branch, tonumber(Tier+1)), sender = Lang['level_up_email_sender'], subject = Lang['level_up_email_subject']}) 147 | end 148 | end 149 | end 150 | elseif Config.Notification.enable and tonumber(amount) < 0 and BranchXP ~= 0 and LoseBranchKnowledge and Config.LoseBranchKnowledge.notification then 151 | SS_Core.Notification({title = Lang["notification_remove_knowledge_title"], message = Lang["notification_remove_knowledge_from_all_branches"]:format(amount, branch)}) 152 | elseif Config.Notification.enable and tonumber(amount) < 0 and BranchXP ~= 0 and (LoseBranchKnowledge == false or nil) then 153 | elseif Config.Notification.enable and tonumber(amount) < 0 and BranchXP ~= 0 then 154 | SS_Core.Notification({title = Lang["notification_remove_knowledge_title"], message = Lang["notification_remove_knowledge_to_branch"]:format(amount, branch)}) 155 | end 156 | TriggerServerEvent("ss-knowledge:server:updateBranches", json.encode(CurrentBranches)) 157 | end 158 | exports('UpdateKnowledgeBranch', UpdateKnowledgeBranch) 159 | 160 | CheckKnowledgeBranch = function(branch, value) 161 | if CurrentBranches[branch] then 162 | if CurrentBranches[branch] >= tonumber(value) then 163 | return true 164 | else 165 | return false 166 | end 167 | else 168 | SS_Log("warn","^4"..Lang['branch_doesnt_exist']:format(branch).."^0", resourceName, currentLine.."165") 169 | return false 170 | end 171 | end 172 | exports('CheckKnowledgeBranch', CheckKnowledgeBranch) 173 | 174 | CheckKnowledgeTier = function(branch, value) 175 | if CurrentBranches[branch] then 176 | if GetBranchTier(CurrentBranches[branch],branch) >= value then 177 | return true 178 | else 179 | return false 180 | end 181 | else 182 | SS_Log("warn","^4"..Lang['branch_doesnt_exist']:format(branch).."^0", resourceName, currentLine.."179") 183 | return false 184 | end 185 | end 186 | exports('CheckKnowledgeTier', CheckKnowledgeTier) 187 | 188 | GetCurrentSkill = function(skill) 189 | local branch, branchInfo = GetCurrentKnowledgeBranch(skill) 190 | if branchInfo ~= nil then 191 | return {Name = branchInfo.title, Max = branchInfo.maxxp, Min = branchInfo.minxp, Current = tonumber(CurrentBranches[branch])} 192 | else 193 | SS_Log("warn","^4GetCurrentSkill is causing errors for branchInfo. Please turn on debug^0", resourceName, currentLine.."190", branch, branchInfo) 194 | end 195 | end 196 | exports('GetCurrentSkill',GetCurrentSkill) 197 | 198 | UpdateSkill = function(skill, amount) 199 | return UpdateKnowledgeBranch(skill, amount) 200 | end 201 | exports('UpdateSkill',UpdateSkill) 202 | 203 | CheckSkill = function(skill, value, cb) 204 | return cb(CheckKnowledgeBranch(skill, value)) 205 | end 206 | exports('CheckSkill',CheckSkill) 207 | 208 | -- mz skill system bridge maybe b1 skills too? 209 | 210 | local function exportHandler(exportName, func) 211 | AddEventHandler(('__cfx_export_mz-skills_%s'):format(exportName) or ('__cfx_export_b1-skill_%s'):format(exportName), function(setCB) 212 | setCB(func) 213 | end) 214 | end 215 | 216 | exportHandler('GetCurrentSkill', function(branch) 217 | local branchName, branchInfo = GetCurrentKnowledgeBranch(string.lower(branch)) 218 | local current = 0 or CurrentBranches[branchName] 219 | if branchInfo ~= nil then 220 | return {Name = branchInfo.title, Max = branchInfo.maxxp, Min = branchInfo.minxp, Current = current} 221 | else 222 | SS_Log("warn","^4GetCurrentSkill is causing errors for branchInfo^0", resourceName, currentLine.."219") 223 | end 224 | end) 225 | 226 | exportHandler('UpdateSkill', function(branch, amount) 227 | SS_Log("debug","^4UpdateSkill [branch = ^3"..string.lower(branch).."^4amount = ^3"..tonumber(amount).."^0", resourceName, currentLine.."224") 228 | UpdateKnowledgeBranch(string.lower(branch), amount) 229 | end) 230 | 231 | exportHandler('CheckSkill', function(branch, value, cb) 232 | return cb(CheckKnowledgeBranch(string.lower(branch), value)) 233 | end) 234 | 235 | AddEventHandler(Config.Triggers[Framework].load, function() 236 | Wait(2000) 237 | SS_Log("debug",Lang['loading_player_branches'], resourceName, currentLine.."234") 238 | FetchKnowledgeBranch() 239 | end) 240 | 241 | AddEventHandler('onResourceStart', function (resource) 242 | if resource == resourceName then 243 | Wait(500) 244 | FetchKnowledgeBranch() 245 | end 246 | end) 247 | 248 | RegisterNetEvent('ss-knowledge:client:updateBranches', function(skill, amount) 249 | UpdateKnowledgeBranch(skill, amount) 250 | end) 251 | 252 | RegisterNetEvent('ss-knowledge:client:updateBranchesCommand', function() 253 | FetchKnowledgeBranch() 254 | end) -------------------------------------------------------------------------------- /client/gui.lua: -------------------------------------------------------------------------------- 1 | CreateKnowledgeBranchList = function() 2 | local options = {} 3 | if Config.Menu.type == 'qb'then 4 | options[#options + 1] = { 5 | title = '.', 6 | isHeader = true, 7 | header = Config.KnowledgeTitle, 8 | isMenuHeader = true, 9 | args = { 10 | "header" 11 | }, 12 | icon = 'fas fa-chart-simple' 13 | } 14 | end 15 | for k,v in pairs(CurrentBranches) do 16 | local branchInfo = Config.Branches[k] 17 | local branchTierTitle, branchXP = nil, {} 18 | if branchInfo.enable then 19 | branchTierTitle, branchXP = GetKnowledgeBranch(v,k) 20 | local min = branchXP.minxp 21 | local max = branchXP.maxxp 22 | local current = CurrentBranches[k] or 0 23 | if type(CurrentBranches[k]) ~= "number" then 24 | current = tonumber(CurrentBranches[k].Current) or 0 25 | end 26 | 27 | local range = max - min 28 | local progress = current - min 29 | 30 | local percentage = math.floor(progress / range * 100) 31 | 32 | local desc = Lang['knowledge_branch_desc']:format(branchTierTitle,math.ceil(current)) 33 | 34 | if Config.Menu.type == 'ox' and Config.Menu.ox.type ~= 'context' then 35 | desc = '' 36 | if Config.Menu.ox.branchxpinfo then 37 | desc = Lang['knowledge_branch_desc_total_info']:format(math.ceil(current)) 38 | end 39 | end 40 | 41 | local currentIcon = Config.Menu.defaulticon 42 | if branchInfo.icon == '' or branchInfo.icon == nil then 43 | currentIcon = Config.Menu.defaulticon 44 | else 45 | currentIcon = branchInfo.icon 46 | end 47 | 48 | local head = Config.KnowledgeTitle 49 | if Config.Menu.type == 'qb' then 50 | head = branchInfo.title 51 | end 52 | options[#options + 1] = { 53 | title = branchInfo.title, 54 | label = Lang['knowledge_branch_label']:format(branchInfo.title, branchTierTitle), 55 | header = head, 56 | txt = desc, 57 | description = desc, 58 | icon = currentIcon, 59 | args = { 60 | v 61 | }, 62 | progress = percentage, 63 | colorScheme = Config.Menu.ox.colour, 64 | } 65 | end 66 | end 67 | 68 | if Config.Menu.sort == 'alphabetically' then 69 | table.sort(options, function(a, b) 70 | return a.title < b.title 71 | end) 72 | elseif Config.Menu.sort == 'xp' then 73 | table.sort(options, function(a, b) 74 | if type(b.args[1]) == "string" then 75 | return false 76 | elseif a.args[1] == 0 and b.args[1] ~= 0 then 77 | return false 78 | elseif a.args[1] ~= 0 and b.args[1] == 0 then 79 | return true 80 | elseif a.args[1] < b.args[1] then 81 | return false 82 | elseif a.args[1] > b.args[1] then 83 | return true 84 | else 85 | return a.title < b.title 86 | end 87 | end) 88 | end 89 | 90 | if Config.Menu.type == 'ox' and Config.Menu.ox.type == 'menu' then 91 | lib.registerMenu({ 92 | id = 'branches_list', 93 | title = Config.KnowledgeTitle, 94 | position = Config.Menu.ox.position, 95 | options = options 96 | }) 97 | lib.showMenu('branches_list') 98 | elseif Config.Menu.type == 'ox' and Config.Menu.ox.type == 'context' then 99 | lib.registerContext({ 100 | id = 'branches_list', 101 | title = Config.KnowledgeTitle, 102 | options = options 103 | }) 104 | lib.showContext('branches_list') 105 | elseif Config.Menu.type == 'qb'then 106 | exports['qb-menu']:openMenu(options) 107 | end 108 | end 109 | 110 | RegisterNetEvent("ss-knowledge:client:checkKnowledge", function() 111 | CreateKnowledgeBranchList() 112 | end) -------------------------------------------------------------------------------- /client/main.lua: -------------------------------------------------------------------------------- 1 | CurrentBranches = {} 2 | 3 | local resourceName = GetCurrentResourceName() 4 | 5 | local currentLine = "CLNT>MAIN #" 6 | 7 | if Config.LoseBranchKnowledge.enable then 8 | RegisterNetEvent(Config.Triggers[Framework].load, function() 9 | CreateThread(function() 10 | while true do 11 | if LocalPlayer.state.isLoggedIn then 12 | Wait(Config.LoseBranchKnowledge.update * 60000) 13 | for branches, value in pairs(Config.Branches) do 14 | SS_Log("debug","^4Branch^0] [^3"..string.lower(branches), resourceName, currentLine.."14") 15 | local nextKey, _ = next(Config.Branches, branches) 16 | if not nextKey then 17 | UpdateKnowledgeBranch(branches, (0 - (math.random(Config.LoseBranchKnowledge.min,Config.LoseBranchKnowledge.max))),true) 18 | else 19 | UpdateKnowledgeBranch(branches, (0 - (math.random(Config.LoseBranchKnowledge.min,Config.LoseBranchKnowledge.max))),false) 20 | end 21 | end 22 | Wait(1000) 23 | else 24 | Wait(5000) 25 | end 26 | end 27 | end) 28 | end) 29 | end -------------------------------------------------------------------------------- /config.lua: -------------------------------------------------------------------------------- 1 | Config = { 2 | -- Any Lang options can be found in the language.lua file as what is in the square brackets i.e [example] = "test this later", 3 | Triggers = { 4 | ['ESX'] = { -- update your triggers or event-names here if you've changed them from default values: 5 | resource = 'es_extended', -- esx resource name 6 | obj = 'esx:getSharedObject', 7 | load = 'esx:playerLoaded', 8 | job = 'esx:setJob', 9 | playerdatabase = 'users', -- This is the table that is used for for your player's indentifier or citizenid 10 | playerid = 'identifier' 11 | }, 12 | ['QB'] = { -- update your triggers or event-names here if you've changed them from default values 13 | resource = 'qb-core', -- qb-core resource name 14 | obj = 'QBCore:GetObject', 15 | load = 'QBCore:Client:OnPlayerLoaded', 16 | job = 'QBCore:Client:OnJobUpdate', 17 | uObjCL = 'QBCore:Client:UpdateObject', 18 | uObjSV = 'QBCore:Server:UpdateObject', 19 | dutyToggle = 'QBCore:ToggleDuty', 20 | playerdatabase = 'players', -- This is the table that is used for for your player's indentifier or citizenid 21 | playerid = 'citizenid' 22 | }, 23 | }, 24 | 25 | AdminOptions = { 26 | enable = true,-- This is used for allowing commands through admin perms to be run (set by ace permmissions) 27 | ranks = {"admin","superadmin","command","group.admin","qbcore.god"}, -- Ace permission ranks allowed to use the admin commands for altering xp amounts of players. 28 | inputType = "command", -- only inputType == "command" available currently. It requires you to add command args (will require player indentifier (server/state id) used for character). 29 | commands = { 30 | addxp = "addxp", 31 | removexp = "removexp", 32 | checkplayerbranch = "checkplayerbranch", 33 | }, 34 | }, 35 | 36 | Debug = { 37 | enable = true, -- To enable standard debug prints set to true. 38 | idType = false, -- For ID debug prints (getting source or identifier etc). This requires Debug.enable to be set to true. 39 | }, 40 | 41 | DefaultLevels = { -- Level system to check xp amount modify to change xp per level. 42 | {title = Lang['default_level_1'], minxp = 00, maxxp = 200}, 43 | {title = Lang['default_level_2'], minxp = 201, maxxp = 400}, 44 | {title = Lang['default_level_3'], minxp = 401, maxxp = 800}, 45 | {title = Lang['default_level_4'], minxp = 801, maxxp = 1600}, 46 | {title = Lang['default_level_5'], minxp = 1601, maxxp = 3200}, 47 | {title = Lang['default_level_6'], minxp = 3201, maxxp = 6400}, 48 | {title = Lang['default_level_7'], minxp = 6401, maxxp = 12800}, 49 | {title = Lang['default_level_8'], minxp = 12801, maxxp = 25000}, 50 | }, 51 | 52 | LoseBranchKnowledge = { 53 | enable = true,-- if set to true over time you will loose a little of your branches xp. 54 | notification = true, -- if set to true and enabled is true players will get a notification telling them they lost some xp 55 | update = 15, --Update every x minutes to database. 56 | min = 1, -- Minimum lost when enabled. 57 | max = 10, -- Maximum lost when enabled. 58 | }, 59 | 60 | Menu = { 61 | type = 'ox', -- menu options are: 'ox' using ox_lib's menu and 'qb' using qb-menu 62 | sort = 'alphabetically', -- 'alphabetically' makes the list alphabetical. If you want it sorted by total xp then 'xp' 63 | defaulticon = 'fas fa-book', -- Default icon when no icon is used in a branch. 64 | ox = { -- Only affects ox_lib users. 65 | type = 'context', -- choose 'context' or 'menu' for different styling of ox options 66 | colour = 'cyan', -- This is for the colour of the progress bar 67 | position = 'bottom-right', -- This is for the position of the generated list using 'context' type 'top-center','bottom-center','top-left','bottom-left','top-right','bottom-right' 68 | branchxpinfo = true, -- If type is 'menu' and branchxpinfo is true you will get more data shown above the menu. 69 | }, 70 | }, 71 | 72 | KnowledgeTitle = "Knowledge Branches", -- Title label for the menu/list of branches. 73 | 74 | ChatCommand = { -- when enabled this will allow a slash chat commmand 75 | enable = true, 76 | commandname = "branches" 77 | }, 78 | 79 | 80 | Notification = { 81 | enable = true,-- If enabled you can send nofitications when xp is added, removed/spent. 82 | notifytype = "qb", --'qb', 'ox', 'okok', 'esx' 83 | email = { -- If enabled emails will be triggered when you level up or down a skill. 84 | enable = true, 85 | type = 'qb-phone', -- 'lb-phone', 'qb-phone', 'qs-phone'. if a phone is used it will send an email else if 'nil' it will be a standard Notification 86 | }, 87 | }, 88 | 89 | Branches = { 90 | crafting = { 91 | enable = true, 92 | title = 'Crafting', 93 | icon = '', 94 | --[[customLevels = { -- This is how you disable custom levels and use default levels 95 | {title = 'Beginner', minxp = 00, maxxp = 200}, 96 | {title = 'Unpolished', minxp = 201, maxxp = 400}, 97 | {title = 'Trainee', minxp = 401, maxxp = 800}, 98 | {title = 'Advanced', minxp = 801, maxxp = 1600}, 99 | {title = 'Instructor', minxp = 1601, maxxp = 3200}, 100 | {title = 'Leader', minxp = 3201, maxxp = 6400}, 101 | {title = 'Specialist', minxp = 6401, maxxp = 12800}, 102 | {title = 'Mythical', minxp = 12801, maxxp = 15000}, 103 | },]] 104 | messages = { -- If enabled then if notify = 'notification' messages and subject (is used as title for compatible notify systems) are needed. 105 | --if notify = 'email' then it will use subject,message and sender. change these to what you wish 106 | enable = true, 107 | notifytype = 'notification', 108 | positive = { 109 | { xp = 50, message = "You've really improved with your crafting ability.", sender = 'Arthur', subject = 'Update to branch'}, 110 | { xp = 100, message = "You’re starting to handle crafting with more ease.", sender = 'Arthur', subject = 'Update to branch'}, 111 | { xp = 200, message = "You’re feeling more assured with your crafting ability.", sender = 'Arthur', subject = 'Update to branch'}, 112 | { xp = 300, message = "You sense that you're excelling at crafting now.", sender = 'Arthur', subject = 'Update to branch'}, 113 | { xp = 350, message = "You're unstoppable with your versitile hands. You're becoming a crafting legend!", sender = 'Arthur', subject = 'Update to branch'}, 114 | }, 115 | negative = { 116 | { xp = 50, message = "You've loosing your touch with your crafting ability.", sender = 'Arthur', subject = 'Update to branch'}, 117 | { xp = 100, message = "You’re starting to handle crafting with more difficulty.", sender = 'Arthur', subject = 'Update to branch'}, 118 | { xp = 200, message = "You’re feeling more insecure with your hands when crafting.", sender = 'Arthur', subject = 'Update to branch'}, 119 | { xp = 300, message = "You sense that you're struggling at crafting now.", sender = 'Arthur', subject = 'Update to branch'}, 120 | { xp = 350, message = "You're floundering with crafting reciepes you know. You're becoming less adept with your crafting skill.", sender = 'Arthur', subject = 'Update to branch'}, 121 | } 122 | } 123 | }, 124 | drug_sales = { 125 | enable = true, 126 | title = 'Drug Sales', 127 | icon = 'fas fa-pills', 128 | customLevels = { 129 | {title = 'Beginner', minxp = 00, maxxp = 200}, 130 | {title = 'Unpolished', minxp = 201, maxxp = 400}, 131 | {title = 'Trainee', minxp = 401, maxxp = 800}, 132 | {title = 'Advanced', minxp = 801, maxxp = 1600}, 133 | {title = 'Instructor', minxp = 1601, maxxp = 3200}, 134 | {title = 'Leader', minxp = 3201, maxxp = 6400}, 135 | {title = 'Specialist', minxp = 6401, maxxp = 12800}, 136 | {title = 'Mythical', minxp = 12801, maxxp = 15000}, 137 | }, 138 | messages = { -- If enabled then if notify = 'notification' messages and subject (is used as title for compatible notify systems) are needed. 139 | --if notify = 'email' then it will use subject,message and sender. change these to what you wish 140 | enable = true, 141 | notifytype = 'notification', 142 | positive = { 143 | { xp = 50, message = "You've really improved with your sales ability.", sender = 'Escocar', subject = 'Update to branch'}, 144 | { xp = 100, message = "You’re starting to handle drug selling with more ease.", sender = 'Escocar', subject = 'Update to branch'}, 145 | { xp = 200, message = "You’re feeling more assured with your drug selling ability.", sender = 'Escocar', subject = 'Update to branch'}, 146 | { xp = 300, message = "You sense that you're excelling at selling now.", sender = 'Escocar', subject = 'Update to branch'}, 147 | { xp = 350, message = "You're unstoppable with your versitile hands. You're becoming a superb drug seller!", sender = 'Escocar', subject = 'Update to branch'}, 148 | }, 149 | negative = { 150 | { xp = 50, message = "You've loosing your touch with your drug selling ability", sender = 'Escocar', subject = 'Update to branch'}, 151 | { xp = 100, message = "You’re starting to handle 'customers' with more difficulty.", sender = 'Escocar', subject = 'Update to branch'}, 152 | { xp = 200, message = "You’re feeling more insecure with your hands when drug selling.", sender = 'Escocar', subject = 'Update to branch'}, 153 | { xp = 300, message = "You sense that you're struggling at peddling drugs now.", sender = 'Escocar', subject = 'Update to branch'}, 154 | { xp = 350, message = "You're floundering with selling in your areas. You're becoming less adept with your selling skill.", sender = 'Escocar', subject = 'Update to branch'}, 155 | } 156 | } 157 | }, 158 | heistreputation = { 159 | enable = true, 160 | title = 'Heist Reputation', 161 | icon = 'fas fa-pills', 162 | customLevels = { 163 | {title = 'Beginner', minxp = 00, maxxp = 200}, 164 | {title = 'Unpolished', minxp = 201, maxxp = 400}, 165 | {title = 'Trainee', minxp = 401, maxxp = 800}, 166 | {title = 'Advanced', minxp = 801, maxxp = 1600}, 167 | {title = 'Instructor', minxp = 1601, maxxp = 3200}, 168 | {title = 'Leader', minxp = 3201, maxxp = 6400}, 169 | {title = 'Specialist', minxp = 6401, maxxp = 12800}, 170 | {title = 'Mythical', minxp = 12801, maxxp = 15000}, 171 | }, 172 | messages = { -- If enabled then if notify = 'notification' messages and subject (is used as title for compatible notify systems) are needed. 173 | --if notify = 'email' then it will use subject,message and sender. change these to what you wish 174 | enable = true, 175 | notifytype = 'notification', 176 | positive = { 177 | { xp = 50, message = "You've really improved with your heisting ability.", sender = 'Jesse', subject = 'Update to branch'}, 178 | { xp = 100, message = "You’re starting to handle heisting with more ease.", sender = 'Jesse', subject = 'Update to branch'}, 179 | { xp = 200, message = "You’re feeling more assured with your heisting rep on the rise.", sender = 'Jesse', subject = 'Update to branch'}, 180 | { xp = 300, message = "You sense that you're excelling at heists now.", sender = 'Jesse', subject = 'Update to branch'}, 181 | { xp = 350, message = "You're unstoppable with your versitile hands. You're like a heisting legend!", sender = 'Jesse', subject = 'Update to branch'}, 182 | }, 183 | negative = { 184 | { xp = 50, message = "You've loosing your touch with your heist skill.", sender = 'Jesse', subject = 'Update to branch'}, 185 | { xp = 100, message = "You’re starting to handle heisting with more difficulty.", sender = 'Jesse', subject = 'Update to branch'}, 186 | { xp = 200, message = "You’re feeling more insecure with heisting.", sender = 'Jesse', subject = 'Update to branch'}, 187 | { xp = 300, message = "You sense that you're struggling with heisting now.", sender = 'Jesse', subject = 'Update to branch'}, 188 | { xp = 350, message = "You're floundering with heisting skills you know. You're becoming less adept with your heisting ability.", sender = 'Jesse', subject = 'Update to branch'}, 189 | } 190 | } 191 | }, 192 | hacking = { 193 | enable = true, 194 | title = 'Hacking', 195 | icon = 'fas fa-laptop-code', 196 | customLevels = { 197 | {title = 'Beginner', minxp = 00, maxxp = 200}, 198 | {title = 'Unpolished', minxp = 201, maxxp = 400}, 199 | {title = 'Trainee', minxp = 401, maxxp = 800}, 200 | {title = 'Advanced', minxp = 801, maxxp = 1600}, 201 | {title = 'Instructor', minxp = 1601, maxxp = 3200}, 202 | {title = 'Leader', minxp = 3201, maxxp = 6400}, 203 | {title = 'Specialist', minxp = 6401, maxxp = 12800}, 204 | {title = 'Mythical', minxp = 12801, maxxp = 15000}, 205 | }, 206 | messages = { -- If enabled then if notify = 'notification' messages and subject (is used as title for compatible notify systems) are needed. 207 | --if notify = 'email' then it will use subject,message and sender. change these to what you wish 208 | enable = true, 209 | notifytype = 'email', 210 | positive = { 211 | { xp = 50, message = "You've really improved with your hacking ability.", sender = 'Sky', subject = 'Update to branch'}, 212 | { xp = 100, message = "You’re starting to handle hacks with more ease.", sender = 'Sky', subject = 'Update to branch'}, 213 | { xp = 200, message = "You’re feeling more assured with your hacking knowledge.", sender = 'Sky', subject = 'Update to branch'}, 214 | { xp = 300, message = "You sense that you're excelling at hacking now.", sender = 'Sky', subject = 'Update to branch'}, 215 | { xp = 350, message = "You're unstoppable with your versitile hands. You're becoming a hacking god!", sender = 'Sky', subject = 'Update to branch'}, 216 | }, 217 | negative = { 218 | { xp = 50, message = "You've loosing your touch with your hacking ability.", sender = 'Sky', subject = 'Update to branch'}, 219 | { xp = 100, message = "You’re starting to handle hacking with more difficulty.", sender = 'Sky', subject = 'Update to branch'}, 220 | { xp = 200, message = "You’re feeling more insecure with your hands during hacking sessions.", sender = 'Sky', subject = 'Update to branch'}, 221 | { xp = 300, message = "You sense that you're struggling at hacking now.", sender = 'Sky', subject = 'Update to branch'}, 222 | { xp = 350, message = "You're floundering with craking software. You're becoming less adept with your hacking skill.", sender = 'Sky', subject = 'Update to branch'}, 223 | } 224 | } 225 | }, 226 | fishing = { 227 | enable = true, 228 | title = 'Fishing', 229 | icon = 'fas fa-fish-fins', 230 | customLevels = { 231 | {title = 'Beginner', minxp = 00, maxxp = 200}, 232 | {title = 'Unpolished', minxp = 201, maxxp = 400}, 233 | {title = 'Trainee', minxp = 401, maxxp = 800}, 234 | {title = 'Advanced', minxp = 801, maxxp = 1600}, 235 | {title = 'Instructor', minxp = 1601, maxxp = 3200}, 236 | {title = 'Leader', minxp = 3201, maxxp = 6400}, 237 | {title = 'Specialist', minxp = 6401, maxxp = 12800}, 238 | {title = 'Mythical', minxp = 12801, maxxp = 15000}, 239 | }, 240 | messages = { -- If enabled then if notify = 'notification' messages and subject (is used as title for compatible notify systems) are needed. 241 | --if notify = 'email' then it will use subject,message and sender. change these to what you wish 242 | enable = true, 243 | notifytype = 'notification', 244 | positive = { 245 | { xp = 50, message = "You've really improved with your fishing ability.", sender = 'Michael', subject = 'Update to branch'}, 246 | { xp = 100, message = "You’re starting to handle your fishing rod with more ease.", sender = 'Michael', subject = 'Update to branch'}, 247 | { xp = 200, message = "You’re feeling more assured with catching fish.", sender = 'Michael', subject = 'Update to branch'}, 248 | { xp = 300, message = "You sense that you're excelling at being a fisher now.", sender = 'Michael', subject = 'Update to branch'}, 249 | { xp = 350, message = "You're unstoppable with your versitile rod. You're becoming a fishing legend!", sender = 'Michael', subject = 'Update to branch'}, 250 | }, 251 | negative = { 252 | { xp = 50, message = "You've loosing your touch with your fishing rod.", sender = 'Michael', subject = 'Update to branch'}, 253 | { xp = 100, message = "You’re starting handling your fishing rod with more difficulty.", sender = 'Michael', subject = 'Update to branch'}, 254 | { xp = 200, message = "You’re feeling more insecure with your hands when fishing.", sender = 'Michael', subject = 'Update to branch'}, 255 | { xp = 300, message = "You sense that you're struggling at fishing now.", sender = 'Michael', subject = 'Update to branch'}, 256 | { xp = 350, message = "You're floundering with fishing techniques you know. You're becoming less adept with your fishing skill.", sender = 'Michael', subject = 'Update to branch'}, 257 | } 258 | } 259 | }, 260 | garbage = { 261 | enable = true, 262 | title = 'Garbage', 263 | icon = 'fas fa-trash-can', 264 | --[[customLevels = { 265 | {title = 'Beginner', minxp = 00, maxxp = 200}, 266 | {title = 'Unpolished', minxp = 201, maxxp = 400}, 267 | {title = 'Trainee', minxp = 401, maxxp = 800}, 268 | {title = 'Advanced', minxp = 801, maxxp = 1600}, 269 | {title = 'Instructor', minxp = 1601, maxxp = 3200}, 270 | {title = 'Leader', minxp = 3201, maxxp = 6400}, 271 | {title = 'Specialist', minxp = 6401, maxxp = 12800}, 272 | {title = 'Mythical', minxp = 12801, maxxp = 15000}, 273 | },]] 274 | messages = { -- If enabled then if notify = 'notification' messages and subject (is used as title for compatible notify systems) are needed. 275 | --if notify = 'email' then it will use subject,message and sender. change these to what you wish 276 | enable = true, 277 | notifytype = 'notification', 278 | positive = { 279 | { xp = 50, message = "You've really improved with your garbage ability.", sender = 'Derf', subject = 'Update to branch'}, 280 | { xp = 100, message = "You’re starting to handle garbage runs with more ease.", sender = 'Derf', subject = 'Update to branch'}, 281 | { xp = 200, message = "You’re feeling more assured with the garbage you grab.", sender = 'Derf', subject = 'Update to branch'}, 282 | { xp = 300, message = "You sense that you're excelling at garbage collection now.", sender = 'Derf', subject = 'Update to branch'}, 283 | { xp = 350, message = "You're unstoppable with your versitile hands. You're becoming the best garbage collector around!", sender = 'Derf', subject = 'Update to branch'}, 284 | }, 285 | negative = { 286 | { xp = 50, message = "You've loosing your touch with your garbage ability.", sender = 'Derf', subject = 'Update to branch'}, 287 | { xp = 100, message = "You’re starting to handle garbage with more difficulty.", sender = 'Derf', subject = 'Update to branch'}, 288 | { xp = 200, message = "You’re feeling more insecure with your hands when garbage collecting.", sender = 'Derf', subject = 'Update to branch'}, 289 | { xp = 300, message = "You sense that you're struggling at garbage collection now.", sender = 'Derf', subject = 'Update to branch'}, 290 | { xp = 350, message = "You're floundering with garbage your known to be able to handle. You're becoming less adept with your garbage skill.", sender = 'Derf', subject = 'Update to branch'}, 291 | } 292 | } 293 | }, 294 | weapon_crafting = { 295 | enable = true, 296 | title = 'Weapon Crafting', 297 | icon = 'fas fa-person-rifle', 298 | customLevels = { 299 | {title = 'Beginner', minxp = 00, maxxp = 200}, 300 | {title = 'Unpolished', minxp = 201, maxxp = 400}, 301 | {title = 'Trainee', minxp = 401, maxxp = 800}, 302 | {title = 'Advanced', minxp = 801, maxxp = 1600}, 303 | {title = 'Instructor', minxp = 1601, maxxp = 3200}, 304 | {title = 'Leader', minxp = 3201, maxxp = 6400}, 305 | {title = 'Specialist', minxp = 6401, maxxp = 12800}, 306 | {title = 'Mythical', minxp = 12801, maxxp = 15000}, 307 | }, 308 | messages = { -- If enabled then if notify = 'notification' messages and subject (is used as title for compatible notify systems) are needed. 309 | --if notify = 'email' then it will use subject,message and sender. change these to what you wish 310 | enable = true, 311 | notifytype = 'notification', 312 | positive = { 313 | { xp = 50, message = "You've really improved with your weapon smithing ability.", sender = 'Masamune', subject = 'Update to branch'}, 314 | { xp = 100, message = "You’re starting to handle weapon smithing with more ease.", sender = 'Masamune', subject = 'Update to branch'}, 315 | { xp = 200, message = "You’re feeling more assured with your weapon crafting ability.", sender = 'Masamune', subject = 'Update to branch'}, 316 | { xp = 300, message = "You sense that you're excelling at weapon making now.", sender = 'Masamune', subject = 'Update to branch'}, 317 | { xp = 350, message = "You're unstoppable with your versitile hands. You're becoming a weapon smithing god!", sender = 'Masamune', subject = 'Update to branch'}, 318 | }, 319 | negative = { 320 | { xp = 50, message = "You've loosing your touch with your weapon crafting ability.", sender = 'Masamune', subject = 'Update to branch'}, 321 | { xp = 100, message = "You’re starting to handle weapons with more difficulty.", sender = 'Masamune', subject = 'Update to branch'}, 322 | { xp = 200, message = "You’re feeling more insecure with your hands when weapon smithing.", sender = 'Masamune', subject = 'Update to branch'}, 323 | { xp = 300, message = "You sense that you're struggling at weapon crafting now.", sender = 'Masamune', subject = 'Update to branch'}, 324 | { xp = 350, message = "You're floundering with weapon smithing reciepes you know. You're becoming less adept with your weapon smithing skill.", sender = 'Masamune', subject = 'Update to branch'}, 325 | } 326 | } 327 | }, 328 | hotdog = { 329 | enable = true, 330 | title = 'Hotdog Vending', 331 | icon = 'fas fa-hotdog', 332 | customLevels = { 333 | {title = 'Beginner', minxp = 00, maxxp = 200}, 334 | {title = 'Unpolished', minxp = 201, maxxp = 400}, 335 | {title = 'Trainee', minxp = 401, maxxp = 800}, 336 | {title = 'Advanced', minxp = 801, maxxp = 1600}, 337 | {title = 'Instructor', minxp = 1601, maxxp = 3200}, 338 | {title = 'Leader', minxp = 3201, maxxp = 6400}, 339 | {title = 'Specialist', minxp = 6401, maxxp = 12800}, 340 | {title = 'Mythical', minxp = 12801, maxxp = 15000}, 341 | }, 342 | messages = { -- If enabled then if notify = 'notification' messages and subject (is used as title for compatible notify systems) are needed. 343 | --if notify = 'email' then it will use subject,message and sender. change these to what you wish 344 | enable = true, 345 | notifytype = 'notification', 346 | positive = { 347 | { xp = 50, message = "You've really improved with your hotdog selling ability.", sender = 'Beztu ', subject = 'Update to branch'}, 348 | { xp = 100, message = "You’re starting to handle hotdog selling with more ease.", sender = 'Beztu ', subject = 'Update to branch'}, 349 | { xp = 200, message = "You’re feeling more assured with your hotdog selling ability.", sender = 'Beztu ', subject = 'Update to branch'}, 350 | { xp = 300, message = "You sense that you're excelling at hotdog selling now.", sender = 'Beztu ', subject = 'Update to branch'}, 351 | { xp = 350, message = "You're unstoppable with your versitile hands. You're becoming a famous hotdog seller!", sender = 'Beztu ', subject = 'Update to branch'}, 352 | }, 353 | negative = { 354 | { xp = 50, message = "You've loosing your touch with your hotdog selling ability.", sender = 'Beztu ', subject = 'Update to branch'}, 355 | { xp = 100, message = "You’re starting to handle hotdogs with more difficulty.", sender = 'Beztu ', subject = 'Update to branch'}, 356 | { xp = 200, message = "You’re feeling more insecure about your hotdog selling skills.", sender = 'Beztu ', subject = 'Update to branch'}, 357 | { xp = 300, message = "You sense that you're struggling at hotdog selling now.", sender = 'Beztu ', subject = 'Update to branch'}, 358 | { xp = 350, message = "You're floundering with the hotdog reciepes you know. You're becoming less known for your hotdog selling.", sender = 'Beztu ', subject = 'Update to branch'}, 359 | } 360 | } 361 | }, 362 | lockpicking = { 363 | enable = true, 364 | title = 'Lockpicking and Hotwiring', 365 | icon = 'fas fa-location-pin-lock', 366 | customLevels = { 367 | {title = 'Beginner', minxp = 00, maxxp = 200}, 368 | {title = 'Unpolished', minxp = 201, maxxp = 400}, 369 | {title = 'Trainee', minxp = 401, maxxp = 800}, 370 | {title = 'Advanced', minxp = 801, maxxp = 1600}, 371 | {title = 'Instructor', minxp = 1601, maxxp = 3200}, 372 | {title = 'Leader', minxp = 3201, maxxp = 6400}, 373 | {title = 'Specialist', minxp = 6401, maxxp = 12800}, 374 | {title = 'Mythical', minxp = 12801, maxxp = 15000}, 375 | }, 376 | messages = { -- If enabled then if notify = 'notification' messages and subject (is used as title for compatible notify systems) are needed. 377 | --if notify = 'email' then it will use subject,message and sender. change these to what you wish 378 | enable = true, 379 | notifytype = 'notification', 380 | positive = { 381 | { xp = 50, message = "You've really improved with your lockpicking ability.", sender = 'Loius', subject = 'Update to branch'}, 382 | { xp = 100, message = "You’re starting to handle lockpicking with more ease.", sender = 'Loius', subject = 'Update to branch'}, 383 | { xp = 200, message = "You’re feeling more assured with your lockpicking ability.", sender = 'Loius', subject = 'Update to branch'}, 384 | { xp = 300, message = "You sense that you're excelling at unlocking some of the most difficult tumblers now.", sender = 'Loius', subject = 'Update to branch'}, 385 | { xp = 350, message = "You're unstoppable with your agile hands. You're becoming a lockpicking legend!", sender = 'Loius', subject = 'Update to branch'}, 386 | }, 387 | negative = { 388 | { xp = 50, message = "You've loosing your touch with your lockpicking ability.", sender = 'Loius', subject = 'Update to branch'}, 389 | { xp = 100, message = "You’re starting to handle tumblers with more difficulty.", sender = 'Loius', subject = 'Update to branch'}, 390 | { xp = 200, message = "You’re feeling more insecure with your hands when lockpicking.", sender = 'Loius', subject = 'Update to branch'}, 391 | { xp = 300, message = "You sense that you're struggling at lockpicking now.", sender = 'Loius', subject = 'Update to branch'}, 392 | { xp = 350, message = "You're floundering with lockpicking of tumblers you know. You're becoming less adept with your lockpicking skill.", sender = 'Loius', subject = 'Update to branch'}, 393 | } 394 | } 395 | }, 396 | robbing = { 397 | enable = true, 398 | title = 'Robbing [All types]', 399 | icon = 'fas fa-people-robbery', 400 | customLevels = { 401 | {title = 'Beginner', minxp = 00, maxxp = 200}, 402 | {title = 'Unpolished', minxp = 201, maxxp = 400}, 403 | {title = 'Trainee', minxp = 401, maxxp = 800}, 404 | {title = 'Advanced', minxp = 801, maxxp = 1600}, 405 | {title = 'Instructor', minxp = 1601, maxxp = 3200}, 406 | {title = 'Leader', minxp = 3201, maxxp = 6400}, 407 | {title = 'Specialist', minxp = 6401, maxxp = 12800}, 408 | {title = 'Mythical', minxp = 12801, maxxp = 15000}, 409 | }, 410 | messages = { -- If enabled then if notify = 'notification' messages and subject (is used as title for compatible notify systems) are needed. 411 | --if notify = 'email' then it will use subject,message and sender. change these to what you wish 412 | enable = true, 413 | notifytype = 'notification', 414 | positive = { 415 | { xp = 50, message = "You've really improved with your robbing ability.", sender = 'Squizzy', subject = 'Update to branch'}, 416 | { xp = 100, message = "You’re starting to handle robbing with more ease.", sender = 'Squizzy', subject = 'Update to branch'}, 417 | { xp = 200, message = "You’re feeling more assured with your robbing ability.", sender = 'Squizzy', subject = 'Update to branch'}, 418 | { xp = 300, message = "You sense that you're excelling at robbing now.", sender = 'Squizzy', subject = 'Update to branch'}, 419 | { xp = 350, message = "You're unstoppable with your versitile hands. You're becoming a robbing legend!", sender = 'Squizzy', subject = 'Update to branch'}, 420 | }, 421 | negative = { 422 | { xp = 50, message = "You've loosing your touch with your robbing ability.", sender = 'Squizzy', subject = 'Update to branch'}, 423 | { xp = 100, message = "You’re starting to handle robbing with more difficulty.", sender = 'Squizzy', subject = 'Update to branch'}, 424 | { xp = 200, message = "You’re feeling more insecure with your hands when robbing.", sender = 'Squizzy', subject = 'Update to branch'}, 425 | { xp = 300, message = "You sense that you're struggling at robbing now.", sender = 'Squizzy', subject = 'Update to branch'}, 426 | { xp = 350, message = "You're floundering with robbing reciepes you know. You're becoming less adept with your robbing skill.", sender = 'Squizzy', subject = 'Update to branch'}, 427 | } 428 | } 429 | }, 430 | scrapping = { 431 | enable = true, 432 | title = 'Scrapping', 433 | icon = 'fas fa-screwdriver-wrench', 434 | customLevels = { 435 | {title = 'Beginner', minxp = 00, maxxp = 200}, 436 | {title = 'Unpolished', minxp = 201, maxxp = 400}, 437 | {title = 'Trainee', minxp = 401, maxxp = 800}, 438 | {title = 'Advanced', minxp = 801, maxxp = 1600}, 439 | {title = 'Instructor', minxp = 1601, maxxp = 3200}, 440 | {title = 'Leader', minxp = 3201, maxxp = 6400}, 441 | {title = 'Specialist', minxp = 6401, maxxp = 12800}, 442 | {title = 'Mythical', minxp = 12801, maxxp = 15000}, 443 | }, 444 | messages = { -- If enabled then if notify = 'notification' messages and subject (is used as title for compatible notify systems) are needed. 445 | --if notify = 'email' then it will use subject,message and sender. change these to what you wish 446 | enable = true, 447 | notifytype = 'notification', 448 | positive = { 449 | { xp = 50, message = "You've really improved with your scrapping ability.", sender = 'Charles', subject = 'Update to branch'}, 450 | { xp = 100, message = "You’re starting to handle scrapping with more ease.", sender = 'Charles', subject = 'Update to branch'}, 451 | { xp = 200, message = "You’re feeling more assured with your scrapping ability.", sender = 'Charles', subject = 'Update to branch'}, 452 | { xp = 300, message = "You sense that you're excelling at scrapping now.", sender = 'Charles', subject = 'Update to branch'}, 453 | { xp = 350, message = "You're unstoppable with your versitile hands. You're becoming a scrapping legend!", sender = 'Charles', subject = 'Update to branch'}, 454 | }, 455 | negative = { 456 | { xp = 50, message = "You've loosing your touch with your scrapping ability.", sender = 'Charles', subject = 'Update to branch'}, 457 | { xp = 100, message = "You’re starting to handle scrapping with more difficulty.", sender = 'Charles', subject = 'Update to branch'}, 458 | { xp = 200, message = "You’re feeling more insecure with your hands when scrapping.", sender = 'Charles', subject = 'Update to branch'}, 459 | { xp = 300, message = "You sense that you're struggling at scrapping now.", sender = 'Charles', subject = 'Update to branch'}, 460 | { xp = 350, message = "You're floundering with scrapping reciepes you know. You're becoming less adept with your scrapping skill.", sender = 'Charles', subject = 'Update to branch'}, 461 | } 462 | } 463 | }, 464 | street_rep = { 465 | enable = true, 466 | title = 'Street Rep', 467 | icon = 'fas fa-person-military-to-person', 468 | customLevels = { 469 | {title = 'Beginner', minxp = 00, maxxp = 200}, 470 | {title = 'Unpolished', minxp = 201, maxxp = 400}, 471 | {title = 'Trainee', minxp = 401, maxxp = 800}, 472 | {title = 'Advanced', minxp = 801, maxxp = 1600}, 473 | {title = 'Instructor', minxp = 1601, maxxp = 3200}, 474 | {title = 'Leader', minxp = 3201, maxxp = 6400}, 475 | {title = 'Specialist', minxp = 6401, maxxp = 12800}, 476 | {title = 'Mythical', minxp = 12801, maxxp = 15000}, 477 | }, 478 | messages = { -- If enabled then if notify = 'notification' messages and subject (is used as title for compatible notify systems) are needed. 479 | --if notify = 'email' then it will use subject,message and sender. change these to what you wish 480 | enable = true, 481 | notifytype = 'notification', 482 | positive = { 483 | { xp = 50, message = "You've really improved your street rep.", sender = 'Paul', subject = 'Update to branch'}, 484 | { xp = 100, message = "You’re starting to handle being more populuar from gaining street rep.", sender = 'Paul', subject = 'Update to branch'}, 485 | { xp = 200, message = "You’re feeling more assured with your street rep populuarity.", sender = 'Paul', subject = 'Update to branch'}, 486 | { xp = 300, message = "You sense that you're excelling at street rep based tasks now.", sender = 'Paul', subject = 'Update to branch'}, 487 | { xp = 350, message = "You're unstoppable with your versitile hands. You're becoming a known name on the streets!", sender = 'Paul', subject = 'Update to branch'}, 488 | }, 489 | negative = { 490 | { xp = 50, message = "You've loosing your touch your street rep.", sender = 'Paul', subject = 'Update to branch'}, 491 | { xp = 100, message = "You’re handling losing street rep with more difficulty.", sender = 'Paul', subject = 'Update to branch'}, 492 | { xp = 200, message = "You’re feeling more insecure with the lose of your street rep.", sender = 'Paul', subject = 'Update to branch'}, 493 | { xp = 300, message = "You sense that you're struggling at keeping your current street rep now.", sender = 'Paul', subject = 'Update to branch'}, 494 | { xp = 350, message = "You're floundering with keeping your street rep. You're becoming less adept within your street rep community.", sender = 'Paul', subject = 'Update to branch'}, 495 | } 496 | } 497 | }, 498 | taxi = { 499 | enable = true, 500 | title = 'Taxi Working', 501 | icon = 'fas fa-taxi', 502 | customLevels = { 503 | {title = 'Beginner', minxp = 00, maxxp = 200}, 504 | {title = 'Unpolished', minxp = 201, maxxp = 400}, 505 | {title = 'Trainee', minxp = 401, maxxp = 800}, 506 | {title = 'Advanced', minxp = 801, maxxp = 1600}, 507 | {title = 'Instructor', minxp = 1601, maxxp = 3200}, 508 | {title = 'Leader', minxp = 3201, maxxp = 6400}, 509 | {title = 'Specialist', minxp = 6401, maxxp = 12800}, 510 | {title = 'Mythical', minxp = 12801, maxxp = 15000}, 511 | }, 512 | messages = { -- If enabled then if notify = 'notification' messages and subject (is used as title for compatible notify systems) are needed. 513 | --if notify = 'email' then it will use subject,message and sender. change these to what you wish 514 | enable = true, 515 | notifytype = 'notification', 516 | positive = { 517 | { xp = 50, message = "You've really improved with your taxi ability.", sender = 'Arnold', subject = 'Update to branch'}, 518 | { xp = 100, message = "You’re starting to handle taxi with more ease.", sender = 'Arnold', subject = 'Update to branch'}, 519 | { xp = 200, message = "You’re feeling more assured with your taxi ability.", sender = 'Arnold', subject = 'Update to branch'}, 520 | { xp = 300, message = "You sense that you're excelling at taxi now.", sender = 'Arnold', subject = 'Update to branch'}, 521 | { xp = 350, message = "You're unstoppable with your versitile hands. You're becoming known in the taxi ranks!", sender = 'Arnold', subject = 'Update to branch'}, 522 | }, 523 | negative = { 524 | { xp = 50, message = "You've loosing your touch with your taxi ability.", sender = 'Arnold', subject = 'Update to branch'}, 525 | { xp = 100, message = "You’re starting to handle taxing with more difficulty.", sender = 'Arnold', subject = 'Update to branch'}, 526 | { xp = 200, message = "You’re feeling more insecure with your hands when taxing.", sender = 'Arnold', subject = 'Update to branch'}, 527 | { xp = 300, message = "You sense that you're struggling at taxing now.", sender = 'Arnold', subject = 'Update to branch'}, 528 | { xp = 350, message = "You're floundering with customers when taxing now. You're becoming less adept with your taxi skills.", sender = 'Arnold', subject = 'Update to branch'}, 529 | } 530 | } 531 | }, 532 | truck = { 533 | enable = true, 534 | title = 'Truck Driving', 535 | icon = 'fas fa-truck-ramp-box', 536 | customLevels = { 537 | {title = 'Beginner', minxp = 00, maxxp = 200}, 538 | {title = 'Unpolished', minxp = 201, maxxp = 400}, 539 | {title = 'Trainee', minxp = 401, maxxp = 800}, 540 | {title = 'Advanced', minxp = 801, maxxp = 1600}, 541 | {title = 'Instructor', minxp = 1601, maxxp = 3200}, 542 | {title = 'Leader', minxp = 3201, maxxp = 6400}, 543 | {title = 'Specialist', minxp = 6401, maxxp = 12800}, 544 | {title = 'Mythical', minxp = 12801, maxxp = 15000}, 545 | }, 546 | messages = { -- If enabled then if notify = 'notification' messages and subject (is used as title for compatible notify systems) are needed. 547 | --if notify = 'email' then it will use subject,message and sender. change these to what you wish 548 | enable = true, 549 | notifytype = 'notification', 550 | positive = { 551 | { xp = 50, message = "You've really improved with your truck driving ability.", sender = 'Elvis', subject = 'Update to branch'}, 552 | { xp = 100, message = "You’re starting to handle truck driving with more ease.", sender = 'Elvis', subject = 'Update to branch'}, 553 | { xp = 200, message = "You’re feeling more assured with your truck driving ability.", sender = 'Elvis', subject = 'Update to branch'}, 554 | { xp = 300, message = "You sense that you're excelling at truck driving now.", sender = 'Elvis', subject = 'Update to branch'}, 555 | { xp = 350, message = "You're unstoppable with your versitile hands. You're becoming a truck legend!", sender = 'Elvis', subject = 'Update to branch'}, 556 | }, 557 | negative = { 558 | { xp = 50, message = "You've loosing your touch with your truck driving ability.", sender = 'Elvis', subject = 'Update to branch'}, 559 | { xp = 100, message = "You’re starting to handle trucks with more difficulty.", sender = 'Elvis', subject = 'Update to branch'}, 560 | { xp = 200, message = "You’re feeling more insecure with your hands when truck driving.", sender = 'Elvis', subject = 'Update to branch'}, 561 | { xp = 300, message = "You sense that you're struggling at truck driving now.", sender = 'Elvis', subject = 'Update to branch'}, 562 | { xp = 350, message = "You're floundering when truck driving. You're becoming less adept with your truck driving skill.", sender = 'Elvis', subject = 'Update to branch'}, 563 | } 564 | } 565 | }, 566 | bus = { 567 | enable = true, 568 | title = 'Bus Driver', 569 | icon = 'fas fa-bus', 570 | customLevels = { 571 | {title = 'Beginner', minxp = 00, maxxp = 200}, 572 | {title = 'Unpolished', minxp = 201, maxxp = 400}, 573 | {title = 'Trainee', minxp = 401, maxxp = 800}, 574 | {title = 'Advanced', minxp = 801, maxxp = 1600}, 575 | {title = 'Instructor', minxp = 1601, maxxp = 3200}, 576 | {title = 'Leader', minxp = 3201, maxxp = 6400}, 577 | {title = 'Specialist', minxp = 6401, maxxp = 12800}, 578 | {title = 'Mythical', minxp = 12801, maxxp = 15000}, 579 | }, 580 | messages = { -- If enabled then if notify = 'notification' messages and subject (is used as title for compatible notify systems) are needed. 581 | --if notify = 'email' then it will use subject,message and sender. change these to what you wish 582 | enable = true, 583 | notifytype = 'email', 584 | positive = { 585 | { xp = 50, message = "You've really improved with your bus driving ability.", sender = 'Dave', subject = 'Update to branch'}, 586 | { xp = 100, message = "You’re starting to handle buses with more ease.", sender = 'Dave', subject = 'Update to branch'}, 587 | { xp = 200, message = "You’re feeling more assured with your bus driving ability.", sender = 'Dave', subject = 'Update to branch'}, 588 | { xp = 300, message = "You sense that you're excelling at bus driving now.", sender = 'Dave', subject = 'Update to branch'}, 589 | { xp = 350, message = "You're unstoppable with your versitile hands. You're becoming a bus driving legend!", sender = 'Dave', subject = 'Update to branch'}, 590 | }, 591 | negative = { 592 | { xp = 50, message = "You've loosing your touch with your bus driving ability.", sender = 'Dave', subject = 'Update to branch'}, 593 | { xp = 100, message = "You’re starting to handle buses with more difficulty.", sender = 'Dave', subject = 'Update to branch'}, 594 | { xp = 200, message = "You’re feeling more insecure with your hands when in control of the bus.", sender = 'Dave', subject = 'Update to branch'}, 595 | { xp = 300, message = "You sense that you're struggling at bus driving now.", sender = 'Dave', subject = 'Update to branch'}, 596 | { xp = 350, message = "You're floundering round the roads when driving the bus. You're becoming less adept with your bus driving skill.", sender = 'Dave', subject = 'Update to branch'}, 597 | } 598 | } 599 | }, 600 | mining = { 601 | enable = true, 602 | title = 'Miner', 603 | icon = 'fas fa-person-digging', 604 | customLevels = { 605 | {title = 'Beginner', minxp = 00, maxxp = 200}, 606 | {title = 'Unpolished', minxp = 201, maxxp = 400}, 607 | {title = 'Trainee', minxp = 401, maxxp = 800}, 608 | {title = 'Advanced', minxp = 801, maxxp = 1600}, 609 | {title = 'Instructor', minxp = 1601, maxxp = 3200}, 610 | {title = 'Leader', minxp = 3201, maxxp = 6400}, 611 | {title = 'Specialist', minxp = 6401, maxxp = 12800}, 612 | {title = 'Mythical', minxp = 12801, maxxp = 15000}, 613 | }, 614 | messages = { -- If enabled then if notify = 'notification' messages and subject (is used as title for compatible notify systems) are needed. 615 | --if notify = 'email' then it will use subject,message and sender. change these to what you wish 616 | enable = true, 617 | notifytype = 'email', 618 | positive = { 619 | { xp = 50, message = "You've really improved with your mining ability.", sender = 'George', subject = 'Update to branch'}, 620 | { xp = 100, message = "You’re starting to handle mining with more ease.", sender = 'George', subject = 'Update to branch'}, 621 | { xp = 200, message = "You’re feeling more assured with your mining ability.", sender = 'George', subject = 'Update to branch'}, 622 | { xp = 300, message = "You sense that you're excelling at mining now.", sender = 'George', subject = 'Update to branch'}, 623 | { xp = 350, message = "You're unstoppable with your versitile hands. You're becoming a mining legend!", sender = 'George', subject = 'Update to branch'}, 624 | }, 625 | negative = { 626 | { xp = 50, message = "You've loosing your touch with your mining ability.", sender = 'George', subject = 'Update to branch'}, 627 | { xp = 100, message = "You’re starting to handle pickaxes with more difficulty.", sender = 'George', subject = 'Update to branch'}, 628 | { xp = 200, message = "You’re feeling more insecure with your hands when in control of a pickaxe.", sender = 'George', subject = 'Update to branch'}, 629 | { xp = 300, message = "You sense that you're struggling at mining now.", sender = 'George', subject = 'Update to branch'}, 630 | { xp = 350, message = "You're floundering round the caves when mining. You're becoming less adept with your mining skill.", sender = 'George', subject = 'Update to branch'}, 631 | } 632 | } 633 | }, 634 | } 635 | } 636 | 637 | Framework = GetResourceState(Config.Triggers["QB"].resource):find('started') and 'QB' or GetResourceState(Config.Triggers["ESX"].resource):find('started') and 'ESX' -- Credit to t1ger for the framework config. -------------------------------------------------------------------------------- /fxmanifest.lua: -------------------------------------------------------------------------------- 1 | fx_version 'cerulean' 2 | game 'gta5' 3 | 4 | author 'Sky\'s Scripts' 5 | description 'Multi use knowledge/rep/xp resource' 6 | 7 | version '1.2.5' 8 | 9 | shared_scripts { 10 | '@ox_lib/init.lua', -- if not using ox_lib options please mark this out with the 2 -'s like i have to write this comment 11 | 'language.lua', 12 | 'config.lua', 13 | 'bridge/shared/logging.lua', 14 | } 15 | 16 | server_scripts { 17 | '@oxmysql/lib/MySQL.lua', 18 | 'server/*.lua', 19 | 'bridge/server/*.lua', 20 | 'bridge/shared/logging.lua', 21 | } 22 | 23 | client_scripts { 24 | 'client/*.lua', 25 | 'bridge/client/*.lua', 26 | 'bridge/shared/logging.lua', 27 | } 28 | 29 | escrow_ignore { 30 | 'client/*.lua', 31 | 'server/*.lua', 32 | 'language.lua', 33 | 'config.lua', 34 | 'bridge/*/*.lua', 35 | } 36 | 37 | lua54 'yes' 38 | -------------------------------------------------------------------------------- /language.lua: -------------------------------------------------------------------------------- 1 | Lang = { -- PLEASE NOTE %s is used for added varaibles from the script itself. This can range from the name of the branch to the amount of xp added. 2 | -- Default level names 3 | ['default_level_1'] = 'Initiate', 4 | ['default_level_2'] = 'Hobbyist', 5 | ['default_level_3'] = 'Mediocre', 6 | ['default_level_4'] = 'Qualified', 7 | ['default_level_5'] = 'Accomplished', 8 | ['default_level_6'] = 'Versatile', 9 | ['default_level_7'] = 'Sage', 10 | ['default_level_8'] = 'Maestro', 11 | 12 | --Debug options 13 | ['branch_doesnt_exist'] = "^1This branch doesn't exist in your current list. Missing branch: ^0[^3 %s ^0]", -- Branch name 14 | ['loading_player_branches'] = '^4Grabbing player knowledge branches^0', 15 | 16 | -- Notification languages 17 | ["notification_add_knowledge_title"] = 'Knowledge Collected', 18 | ["notification_add_knowledge_to_branch"] = 'You have gained %s XP in your %s knowledge branch', -- 1. amount of xp 2.Branch name 19 | ["notification_remove_knowledge_title"] = 'Knowledge Used', 20 | ["notification_remove_knowledge_to_branch"] = 'You have lost %s XP in your %s knowledge branch', -- 1. amount of xp 2.Branch name 21 | ["notification_max_knowledge_title"] = "Maxed Knowledge Branch", 22 | ["notification_max_knowledge_message"] = "You have maxed out your %s branch",-- 1. Branch name 23 | ["notification_remove_knowledge_from_all_branches"] = 'You have lost some XP in your known knowledge branches', 24 | 25 | --menu stuffs 26 | ['knowledge_branch_label'] = "%s - [ %s ]", -- 1. Branch name 2. Branch level 27 | ['knowledge_branch_desc'] = '[ %s ] - Total Knowledge: [ %s ]', -- 1. amount of xp 2.Branch name 28 | ['knowledge_branch_desc_total_info'] = 'Total Knowledge: [ %s ]', -- 1. amount of xp 29 | 30 | -- email level up 31 | ['level_up_email_message'] = 'Well done for increasing your %s knowledge branch to level %s', -- 1. amount of xp 2.Branch name 32 | ['level_up_email_sender'] = 'Knowledge Agency', 33 | ['level_up_email_subject'] = 'You\'ve Improved', 34 | 35 | -- command description / args help 36 | ['commandname_desc'] = 'Show your current knowledge branches', 37 | ['addxp_help_arg_1'] = 'Add xp to an online player\'s knowledge branch (Allowed Staff Only)', 38 | ['addxp_help_arg_2'] = 'Server ID', 39 | ['addxp_name_arg_2'] = 'ID', 40 | ['addxp_help_arg_3'] = 'Branch Name', 41 | ['addxp_name_arg_3'] = 'Branch', 42 | ['addxp_help_arg_4'] = 'Amount of xp to add', 43 | ['addxp_name_arg_4'] = 'XP', 44 | ['removexp_help_arg_1'] = 'Remove xp from an online player\'s knowledge branch (Allowed Staff Only)', 45 | ['removexp_name_arg_2'] = 'Server ID', 46 | ['removexp_help_arg_2'] = 'ID', 47 | ['removexp_name_arg_3'] = 'Branch Name', 48 | ['removexp_help_arg_3'] = 'Branch', 49 | ['removexp_name_arg_4'] = 'Amount of xp to remove', 50 | ['removexp_help_arg_4'] = 'XP', 51 | ['checkxp_help_arg_1'] = 'Check a knowledge branch of an online player (Allowed Staff Only)', 52 | ['checkxp_name_arg_2'] = 'Server ID', 53 | ['checkxp_help_arg_2'] = 'ID', 54 | ['checkxp_name_arg_3'] = 'Branch Name', 55 | ['checkxp_help_arg_3'] = 'Branch', 56 | ['check_player_branch_title'] = 'Checking Player Branch', 57 | ['check_player_branch_message'] = ' has a total of [%s] xp in [%s] branch', -- 1. amount of xp 2.Branch name 58 | 59 | -- Missing args in command 60 | ['missing_args_title'] = 'Missing args', 61 | ['missing_args_message'] = 'Your missing some data for command [%s]', -- 1. Name of command 62 | } -------------------------------------------------------------------------------- /server/main.lua: -------------------------------------------------------------------------------- 1 | local resourceName = GetCurrentResourceName() 2 | local PlayerBranches = {} 3 | local currentLine = "SRVR>MAIN #" 4 | 5 | --- @param source integer, The source player ID 6 | --- @returns branches table (via SortBranches function) 7 | FetchDBBranches = function(source) 8 | SS_Log("debug", "^4FetchDBBranches^0] [^3"..tonumber(source).."^0", resourceName, currentLine.."7") 9 | local Player = SS_Core.Player.GetIdentifier(source) 10 | if Player ~= nil then 11 | local branches = MySQL.scalar.await('SELECT skills FROM '..Config.Triggers[Framework].playerdatabase..' WHERE '..Config.Triggers[Framework].playerid..' = ?', {Player}) 12 | if branches == nil or branches == "NULL" then 13 | branches = SetupBranches() 14 | UpdateDBBranches(source, json.encode(branches)) 15 | return SortBranches(Player,branches) 16 | elseif branches ~= nil then 17 | if string.len(branches) > 3 then 18 | return SortBranches(Player,json.decode(branches)) 19 | end 20 | end 21 | end 22 | end 23 | 24 | --- @param Player integer, Player Identifier 25 | --- @param data table, The branches table to be sorted 26 | --- @returns sortedBranches table 27 | SortBranches = function(Player,data) 28 | local sortedBranches = {} 29 | if data ~= nil then 30 | for branch, value in pairs(data) do 31 | local str = string.lower(branch) 32 | str = str:gsub("%s+", "") 33 | if Config.Branches[str] ~= nil then 34 | if Config.Branches[str].enable then 35 | local xp = value 36 | if type(xp) == "table" then 37 | xp = tonumber(value.Current) 38 | end 39 | SS_Log("debug","^4SortBranch branch^0] [^3"..str.."^0] [^3"..json.encode(xp).."^0", resourceName, currentLine.."36") 40 | sortedBranches[str] = xp 41 | end 42 | else 43 | SS_Log("debug","^4SortBranch^0] [^3branch name - "..str.."^0", resourceName, currentLine.."40") 44 | SS_Log("warn","^4SortBranch^0] [^3Please add this branch to config and restart^0] [^1branch name - "..str.."^0", resourceName, currentLine.."41") 45 | end 46 | end 47 | for branch, _ in pairs(Config.Branches) do 48 | if sortedBranches[branch] == nil and Config.Branches[branch].enable then 49 | sortedBranches[branch] = 0 50 | end 51 | end 52 | end 53 | 54 | if PlayerBranches[Player] and next(PlayerBranches[Player]) then 55 | PlayerBranches[Player] = {} 56 | end 57 | PlayerBranches[Player] = sortedBranches 58 | return sortedBranches 59 | end 60 | 61 | --- @returns sortedBranches, table A table containing the sorted branches 62 | SetupBranches = function() 63 | local sortedBranches = {} 64 | for branch, _ in pairs(Config.Branches) do 65 | sortedBranches[branch] = 0 66 | end 67 | SS_Log("debug","^0[^4SetupBranches Branch Table^0] [^3 "..json.encode(sortedBranches), resourceName, currentLine.."53") 68 | return sortedBranches 69 | end 70 | 71 | 72 | AddEventHandler('onResourceStart', function(resource) 73 | if resource == resourceName then 74 | SS_Utils.VersionCheck("ss_knowledge","skys-scripts/ss_knowledge",false) 75 | SS_Utils.CheckForDBColumn(Config.Triggers[Framework].playerdatabase,"skills") 76 | end 77 | end) 78 | 79 | CheckArgs = function(id,branch,functionName) 80 | if id == nil or id == 0 then 81 | SS_Log("error", "^4"..functionName.."^0] [^3ID is invalid^0", resourceName) 82 | return false 83 | elseif branch == nil and type(branch) ~= "string" then 84 | SS_Log("error", "^4"..functionName.."^0] [^3Branch is invalid^0", resourceName) 85 | return false 86 | else 87 | SS_Log("debug","^4"..functionName.."^0] [^3ID = "..id.."^0] [^3Branch = "..tostring(branch).."^0", resourceName, currentLine.."92") 88 | end 89 | local playerId = tonumber(id) 90 | if playerId == nil then 91 | SS_Log("error", "^4"..functionName.."^0] [^3ID is not a number^0", resourceName) 92 | return false 93 | end 94 | local playerIdentifier = SS_Core.Player.GetIdentifier(playerId) 95 | if playerIdentifier == nil then 96 | SS_Log("error", "^4"..functionName.."^0] [^3Player identifier not found^0", resourceName) 97 | return false 98 | end 99 | if Config.Branches[branch] == nil then 100 | SS_Log("error", "^4"..functionName.."^0] [^3Branch does not exist in config^0", resourceName) 101 | return false 102 | end 103 | return true, playerIdentifier 104 | end 105 | 106 | --- @param ID integer, The player ID 107 | --- @param data string, Full branches table to be pushed into the database. 108 | UpdateDBBranches = function(ID,data) 109 | local PID = SS_Core.Player.GetIdentifier(ID) 110 | MySQL.query('UPDATE '..Config.Triggers[Framework].playerdatabase..' SET skills = @branches WHERE '..Config.Triggers[Framework].playerid..' = @id', { --It is set to a branch column to not cause conflictions with mz/ b1/ cw xp branch systems. 111 | ['@branches'] = data, 112 | ['@id'] = PID 113 | }) 114 | end 115 | 116 | --- @param data table, Full branches table 117 | --- @param otherID integer, The other player ID if nil implies the ID is the player that triggered net event. 118 | RegisterNetEvent('ss-knowledge:server:updateBranches', function (data, otherID) 119 | if otherID == nil then 120 | UpdateDBBranches(source, tostring(data)) 121 | else 122 | UpdateDBBranches(otherID, tostring(data)) 123 | TriggerClientEvent("ss-knowledge:client:updateBranchesCommand", otherID) 124 | end 125 | end) 126 | 127 | --- @param data table email data table 128 | --- @param data.subject string, the subject of the email 129 | --- @param data.message string, the message of the email 130 | --- @param returns boolean (true if mail was sent, false if mail was not sent) and string (the id of the mail or the error message) 131 | RegisterNetEvent("ss-knowledge:server:lb-phone:sendMail", function(data) 132 | local phoneNumber = exports["lb-phone"]:GetEquippedPhoneNumber(source) -- phonenumber from source 133 | 134 | local playerMail = exports["lb-phone"]:GetEmailAddress(phoneNumber) -- mail from phonenumber 135 | local success, id = exports["lb-phone"]:SendMail({ 136 | to = playerMail, 137 | subject = data.subject, 138 | message = data.message, 139 | attachments = { 140 | }, 141 | actions = { 142 | } 143 | }) 144 | end) 145 | 146 | -- Export functions 147 | 148 | --- @param id number The player ID 149 | --- @param branch string The branch to get knowledge for 150 | GetKnowledgeBranchByServer = function(id, branch) 151 | local check, playerIdentifier = CheckArgs(id,branch,"GetKnowledgeBranchByServer") 152 | if not check then 153 | return 154 | end 155 | if PlayerBranches[playerIdentifier] ~= nil then 156 | local tier = 0 157 | local currentBranch = PlayerBranches[playerIdentifier][branch] 158 | local tiers = Config.Branches[branch].customLevels or Config.DefaultLevels 159 | local tierLimits = tiers[1] 160 | for _, branchData in ipairs(tiers) do 161 | if currentBranch > branchData.minxp and currentBranch <= branchData.maxxp then 162 | if branchData.title then 163 | return branchData.title, branchData 164 | end 165 | return tier, branchData 166 | end 167 | if currentBranch > branchData.maxxp then 168 | tier = tier+1 169 | tierLimits = branchData 170 | end 171 | end 172 | if #tiers == tier then 173 | tier = #tiers 174 | end 175 | if tierLimits.title then 176 | return tierLimits.title, tierLimits 177 | end 178 | return tier, tierLimits 179 | end 180 | end 181 | exports("GetKnowledgeBranchByServer", GetKnowledgeBranchByServer) 182 | 183 | --- @param id number The player ID 184 | --- @param branch string which branch you wish to check 185 | GetBranchTierByServer = function(id, branch) 186 | local check, playerIdentifier = CheckArgs(id,branch,"GetBranchTierByServer") 187 | if not check then 188 | return 189 | end 190 | local tier = 1 191 | local tiers = Config.Branches[branch].customLevels or Config.DefaultLevels 192 | local currentBranch = PlayerBranches[playerIdentifier][branch] 193 | for Tier, branchData in ipairs(tiers) do 194 | if currentBranch >= branchData.minxp and currentBranch < branchData.maxxp then 195 | return Tier 196 | end 197 | if currentBranch > branchData.maxxp then 198 | tier = tier+1 199 | end 200 | if #tiers == tier then 201 | tier = #tiers 202 | return tier 203 | end 204 | end 205 | end 206 | exports('GetBranchTierByServer', GetBranchTierByServer) 207 | 208 | --- @param id number The player ID 209 | --- @param branch string which branch you wish to check. 210 | --- @param amount integer the amount of xp you wish to check against. 211 | CheckKnowledgeTierByServer = function(id,branch,amount) 212 | local check, playerIdentifier = CheckArgs(id,branch,"CheckKnowledgeTierByServer") 213 | if not check then 214 | return 215 | end 216 | if PlayerBranches[playerIdentifier][branch] then 217 | if GetBranchTierByServer(PlayerBranches[playerIdentifier][branch],branch) >= amount then 218 | return true 219 | else 220 | return false 221 | end 222 | else 223 | SS_Log("warn","^4"..Lang['branch_doesnt_exist']:format(branch).."^0", resourceName, currentLine.."174") 224 | return false 225 | end 226 | end 227 | exports('CheckKnowledgeTierByServer', CheckKnowledgeTierByServer) 228 | 229 | --- @param id number The player ID 230 | --- @param branch string which branch you wish to check. 231 | --- @param amount integer the amount of xp you wish to check against. 232 | CheckKnowledgeBranchByServer = function(id, branch, amount) 233 | local check, playerIdentifier = CheckArgs(id,branch,"CheckKnowledgeBranchByServer") 234 | if not check then 235 | return 236 | end 237 | if PlayerBranches[playerIdentifier][branch] then 238 | if PlayerBranches[playerIdentifier][branch] >= tonumber(amount) then 239 | return true 240 | else 241 | return false 242 | end 243 | else 244 | SS_Log("warn","^4"..Lang['branch_doesnt_exist']:format(branch).."^0", resourceName, currentLine.."160") 245 | return false 246 | end 247 | end 248 | exports('CheckKnowledgeBranchByServer', CheckKnowledgeBranchByServer) 249 | 250 | 251 | --- @param id number The player ID 252 | --- @param branch string which branch you wish to check. 253 | --- @param amount integer the amount of xp you wish to check against. 254 | UpdateKnowledgeBranchByServer = function(id, branch, amount) 255 | local check, _ = CheckArgs(id,branch,"UpdateKnowledgeBranchByServer") 256 | if not check then 257 | return 258 | end 259 | TriggerClientEvent("ss-knowledge:client:updateBranches", id, branch, amount) 260 | end 261 | exports('UpdateKnowledgeBranchByServer', UpdateKnowledgeBranchByServer) --------------------------------------------------------------------------------