├── .github └── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── LICENSE ├── README.md ├── client ├── dispatch.lua ├── fire.lua ├── main.lua └── utils.lua ├── config.lua ├── data ├── firescript_alarm.dat54.rel └── firescript_alarm.dat54.rel.xml ├── fxmanifest.lua ├── server ├── dispatch.lua ├── fire.lua ├── main.lua ├── utils.lua └── whitelist.lua └── toneaudio ├── firescript_alarm.awc └── firescript_alarm.awc.xml /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help me improve the script! 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Server (please complete the following information):** 27 | - Artifact: [e.g. 3184] 28 | - Script version: [e.g. 1.7.4] 29 | 30 | **Additional context** 31 | Add any other context about the problem here. 32 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Logo](https://i.imgur.com/cfPLDVh.png) 2 | 3 | [![License GNU-GPL v3](https://img.shields.io/github/license/gimicze/firescript?style=for-the-badge)](https://github.com/gimicze/firescript/blob/master/LICENSE "License") 4 | [![Latest release](https://img.shields.io/github/v/release/gimicze/firescript?style=for-the-badge)](https://github.com/gimicze/firescript/releases/latest "Latest release") 5 | [![Total downloads](https://img.shields.io/github/downloads/gimicze/firescript/total?style=for-the-badge)](https://github.com/gimicze/firescript/releases/latest "Total downloads") 6 | 7 | A FiveM resource enabling whitelisted users to create a (*somewhat*) realistic fires. As far as I am aware, the only fire script compatible with OneSync Infinity / Beyond. 8 | 9 |
10 | In-game screenshots 11 | 12 | ![Example fire](https://i.imgur.com/XOLJN7v.png "Example fire") 13 | ![Example fire](https://i.imgur.com/IYmE6qn.png) 14 |
15 | 16 | # Instalation 17 | 18 | 1. Extract the contents into folder called `firescript` into your resources folder. 19 | 2. Start the script: **a)** in the `server.cfg` file; **b)** through the console 20 | 21 | ## Starting a resource through console 22 | 23 | 1. In a server console, or client console (F8), type in `refresh` and confirm using ENTER 24 | 2. Type in `start firescript` and confirm using ENTER 25 | 26 | ## Starting a resource in `server.cfg` 27 | 1. Add this line to your server.cfg 28 | ``` 29 | start firescript 30 | ``` 31 | 2. Save the file and restart the server. 32 | 33 | # Usage & Commands 34 | 35 | *Tutorial moved to [the wiki](https://github.com/gimicze/firescript/wiki).* 36 | 37 | # Known bugs 38 | *None! Feel free to open issue when you find any!* 39 | 40 | # Credits 41 | - Albo1125 and foregz - I borrowed some particles from their fire scripts. Thanks! 42 | - MadMick#0773, Mickey#2590 and MadLadClip for testing and help with the script. 43 | 44 | # Contributing 45 | Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. 46 | 47 | # License 48 | [GNU GPL 3.0](https://github.com/gimicze/firescript/blob/main/LICENSE) 49 | -------------------------------------------------------------------------------- /client/dispatch.lua: -------------------------------------------------------------------------------- 1 | --================================-- 2 | -- FIRE SCRIPT v1.6.3 -- 3 | -- by GIMI (+ foregz, Albo1125) -- 4 | -- License: GNU GPL 3.0 -- 5 | --================================-- 6 | 7 | Dispatch = { 8 | lastCall = nil, 9 | blips = {}, 10 | playingTone = nil, 11 | __index = self, 12 | init = function(o) 13 | o = o or {lastCall = {}, blips = {}, playingTone = nil} 14 | setmetatable(o, self) 15 | self.__index = self 16 | return o 17 | end 18 | } 19 | 20 | function Dispatch:renderRoute(coords) 21 | ClearGpsMultiRoute() 22 | 23 | StartGpsMultiRoute(6, true, true) 24 | AddPointToGpsMultiRoute(table.unpack(coords)) 25 | SetGpsMultiRouteRender(true) 26 | end 27 | 28 | function Dispatch:create(dispatchNumber, coords) 29 | if not (dispatchNumber and coords) then 30 | return 31 | end 32 | 33 | -- Create a fire blip 34 | local blip = AddBlipForCoord(table.unpack(coords)) 35 | SetBlipSprite(blip, 436) 36 | SetBlipDisplay(blip, 4) 37 | SetBlipScale(blip, 1.5) 38 | SetBlipColour(blip, 1) 39 | SetBlipAsShortRange(blip, false) 40 | BeginTextCommandSetBlipName("STRING") 41 | AddTextComponentString("Fire #" .. dispatchNumber) 42 | EndTextCommandSetBlipName(blip) 43 | 44 | self.blips[dispatchNumber] = { 45 | coords = coords, 46 | blip = blip 47 | } 48 | 49 | self:renderRoute(coords) 50 | 51 | if Config.Dispatch.playSound then 52 | Citizen.CreateThread( 53 | function() 54 | for i = 1, 3 do 55 | PlaySoundFromEntity(-1, "IDLE_BEEP", PlayerPedId(), "EPSILONISM_04_SOUNDSET", 0) 56 | Citizen.Wait(300) 57 | end 58 | end 59 | ) 60 | end 61 | 62 | FlashMinimapDisplay() 63 | 64 | Citizen.SetTimeout( 65 | Config.Dispatch.removeBlipTimeout, 66 | function() 67 | if self.blips[dispatchNumber] and self.blips[dispatchNumber].blip then 68 | RemoveBlip(blip) 69 | self.blips[dispatchNumber].blip = false 70 | end 71 | if self.lastCall == dispatchNumber then 72 | ClearGpsMultiRoute() 73 | end 74 | end 75 | ) 76 | 77 | -- Only store the last 'Config.Dispatch.storeLast' dispatches' data. 78 | if countElements(self.blips) > Config.Dispatch.storeLast then 79 | local order = {} 80 | 81 | for k, v in pairs(self.blips) do 82 | table.insert(order, k) 83 | end 84 | 85 | table.sort(order) 86 | self.blips[order[1]] = nil 87 | end 88 | 89 | self.lastCall = dispatchNumber 90 | end 91 | 92 | function Dispatch:playTone() 93 | if self.playingTone or not (Config.Dispatch.toneSources and type(Config.Dispatch.toneSources) == "table") then 94 | return false 95 | end 96 | 97 | self.playingTone = true 98 | 99 | for k, v in ipairs(Config.Dispatch.toneSources) do 100 | local soundID = GetSoundId() -- The databank gets loaded when the script launches 101 | 102 | Citizen.CreateThread( 103 | function() 104 | PlaySoundFromCoord(soundID, "long_beeps", v.x, v.y, v.z, "firescript_alarm", 0, 150, 0) 105 | 106 | Citizen.Wait(8000) 107 | 108 | PlaySoundFromCoord(soundID, "short_beeps", v.x, v.y, v.z, "firescript_alarm", 0, 150, 0) 109 | 110 | Citizen.Wait(5000) 111 | 112 | ReleaseSoundId(soundID) 113 | end 114 | ) 115 | end 116 | 117 | Citizen.SetTimeout( 118 | 13000, 119 | function() 120 | self.playingTone = nil 121 | end 122 | ) 123 | 124 | return true 125 | end 126 | 127 | function Dispatch:clear(dispatchNumber) 128 | ClearGpsMultiRoute() 129 | 130 | if dispatchNumber and self.blips[dispatchNumber] and self.blips[dispatchNumber].blip then 131 | RemoveBlip(self.blips[dispatchNumber].blip) 132 | self.blips[dispatchNumber].blip = false 133 | elseif dispatchNumber == 0 then 134 | for k, v in pairs(self.blips) do 135 | if self.blips[k].blip then 136 | RemoveBlip(self.blips[k].blip) 137 | self.blips[k].blip = false 138 | end 139 | end 140 | end 141 | end 142 | 143 | function Dispatch:remind(dispatchNumber) 144 | if self.blips[dispatchNumber] then 145 | SetNewWaypoint(table.unpack(self.blips[dispatchNumber].coords.xy)) 146 | return true 147 | else 148 | return false 149 | end 150 | end 151 | 152 | --================================-- 153 | -- DISPATCH ROUTE REMOVAL -- 154 | --================================-- 155 | 156 | if Config.Dispatch.clearGpsRadius and tonumber(Config.Dispatch.clearGpsRadius) then 157 | Citizen.CreateThread( 158 | function() 159 | while true do 160 | Citizen.Wait(5000) 161 | if Dispatch.lastCall and Dispatch.blips[Dispatch.lastCall] and Dispatch.blips[Dispatch.lastCall].blip and #(Dispatch.blips[Dispatch.lastCall].coords - GetEntityCoords(PlayerPedId())) < Config.Dispatch.clearGpsRadius then 162 | ClearGpsMultiRoute() 163 | end 164 | end 165 | end 166 | ) 167 | end -------------------------------------------------------------------------------- /client/fire.lua: -------------------------------------------------------------------------------- 1 | --================================-- 2 | -- FIRE SCRIPT v2.0.2 -- 3 | -- by GIMI (+ foregz, Albo1125) -- 4 | -- License: GNU GPL 3.0 -- 5 | --================================-- 6 | 7 | Fire = { 8 | active = {}, 9 | removed = {}, 10 | __index = self, 11 | init = function(o) 12 | o = o or {active = {}, removed = {}} 13 | setmetatable(o, self) 14 | self.__index = self 15 | return o 16 | end 17 | } 18 | 19 | function Fire:createFlame(fireIndex, flameIndex, coords) 20 | if not self.removed[fireIndex] then 21 | if self.active[fireIndex] == nil then 22 | self.active[fireIndex] = { 23 | flameCoords = {}, 24 | flames = {}, 25 | particles = {}, 26 | flameParticles = {}, 27 | sound = {} 28 | } 29 | end 30 | self.active[fireIndex].flameCoords[flameIndex] = coords 31 | end 32 | end 33 | 34 | function Fire:removeFlame(fireIndex, flameIndex) 35 | if not (fireIndex and flameIndex and self.active[fireIndex]) then 36 | return 37 | end 38 | 39 | if self.active[fireIndex].flames[flameIndex] and self.active[fireIndex].flames[flameIndex] > -1 then 40 | RemoveScriptFire(self.active[fireIndex].flames[flameIndex]) 41 | self.active[fireIndex].flames[flameIndex] = nil 42 | end 43 | 44 | if self.active[fireIndex].particles[flameIndex] and self.active[fireIndex].particles[flameIndex] ~= 0 then 45 | local particles = self.active[fireIndex].particles[flameIndex] 46 | Citizen.SetTimeout( 47 | 5000, 48 | function() 49 | StopParticleFxLooped(particles, false) 50 | Citizen.Wait(1500) 51 | RemoveParticleFx(particles, true) 52 | end 53 | ) 54 | self.active[fireIndex].particles[flameIndex] = nil 55 | end 56 | 57 | if self.active[fireIndex].flameParticles[flameIndex] then 58 | local flameParticles = self.active[fireIndex].flameParticles[flameIndex] 59 | local soundID = self.active[fireIndex].sound[flameIndex] 60 | 61 | Citizen.SetTimeout( 62 | 1000, 63 | function() 64 | local scale = 1.0 65 | while scale > 0.3 do 66 | scale = scale - 0.01 67 | SetParticleFxLoopedScale(flameParticles, scale) 68 | Citizen.Wait(60) 69 | end 70 | 71 | StopSound(soundID) 72 | ReleaseSoundId(soundID) 73 | 74 | StopParticleFxLooped(flameParticles, false) 75 | RemoveParticleFx(flameParticles, true) 76 | end 77 | ) 78 | self.active[fireIndex].flameParticles[flameIndex] = nil 79 | end 80 | 81 | self.active[fireIndex].flameCoords[flameIndex] = nil 82 | 83 | if self.active[fireIndex] ~= nil and countElements(self.active[fireIndex].flames) < 1 then 84 | self.active[fireIndex] = nil 85 | self.removed[fireIndex] = true 86 | end 87 | end 88 | 89 | function Fire:remove(fireIndex, callback) 90 | if not (self.active[fireIndex] and self.active[fireIndex].particles) then 91 | return 92 | end 93 | 94 | for k, v in pairs(self.active[fireIndex].flameCoords) do 95 | self:removeFlame(fireIndex, k) 96 | Citizen.Wait(20) 97 | end 98 | 99 | Citizen.SetTimeout( 100 | 200, 101 | function() 102 | if self.active[fireIndex] and next(self.active[fireIndex].flames) ~= nil then 103 | print("WARNING: A fire persisted!") 104 | self:remove(fireIndex) 105 | elseif callback then 106 | callback(fireIndex) 107 | end 108 | end 109 | ) 110 | end 111 | 112 | function Fire:removeAll(callback) 113 | for k, v in pairs(self.active) do 114 | self:remove(k) 115 | Citizen.Wait(20) 116 | end 117 | 118 | self.active = {} 119 | self.removed = {} 120 | 121 | if callback then 122 | callback() 123 | end 124 | end 125 | 126 | --================================-- 127 | -- PARTICLES & FIRE EXTINGUISHING -- 128 | --================================-- 129 | 130 | Citizen.CreateThread( 131 | function() 132 | while true do 133 | Citizen.Wait(1500) 134 | while syncInProgress do 135 | Citizen.Wait(10) 136 | end 137 | for fireIndex, v in pairs(Fire.active) do 138 | if countElements(v.particles) ~= 0 then 139 | for flameIndex, _v in pairs(v.particles) do 140 | if v.flameCoords[flameIndex] ~= nil then 141 | local isFirePresent = GetNumberOfFiresInRange( 142 | v.flameCoords[flameIndex].x, 143 | v.flameCoords[flameIndex].y, 144 | v.flameCoords[flameIndex].z, 145 | 0.05 146 | ) 147 | if isFirePresent == 0 then 148 | RemoveScriptFire(v.flames[flameIndex]) 149 | v.flames[flameIndex] = StartScriptFire(v.flameCoords[flameIndex].x, v.flameCoords[flameIndex].y, v.flameCoords[flameIndex].z, 0, false) 150 | TriggerServerEvent('fireManager:removeFlame', fireIndex, flameIndex) 151 | end 152 | end 153 | end 154 | end 155 | end 156 | end 157 | end 158 | ) 159 | 160 | Citizen.CreateThread( 161 | function() 162 | while true do 163 | while syncInProgress do 164 | Citizen.Wait(10) 165 | end 166 | local pedCoords = GetEntityCoords(PlayerPedId()) 167 | syncInProgress = true 168 | for fireIndex, v in pairs(Fire.active) do 169 | for flameIndex, coords in pairs(Fire.active[fireIndex].flameCoords) do 170 | Citizen.Wait(10) 171 | 172 | if Fire.active[fireIndex] and Fire.active[fireIndex].flameCoords[flameIndex] and not Fire.active[fireIndex].particles[flameIndex] and #(coords - pedCoords) < 300.0 then 173 | local z = coords.z 174 | 175 | repeat 176 | Wait(0) 177 | ground, newZ = GetGroundZFor_3dCoord(coords.x, coords.y, z) 178 | if not ground then 179 | z = z + 0.1 180 | end 181 | until ground 182 | z = newZ 183 | 184 | Fire.active[fireIndex].flames[flameIndex] = StartScriptFire(coords.x, coords.y, z, 0, false) 185 | 186 | if Fire.active[fireIndex].flames[flameIndex] then -- Make sure the fire has been spawned properly 187 | if not HasNamedPtfxAssetLoaded("scr_agencyheistb") then 188 | RequestNamedPtfxAsset("scr_agencyheistb") 189 | while not HasNamedPtfxAssetLoaded("scr_agencyheistb") do 190 | Wait(10) 191 | end 192 | end 193 | 194 | if not HasNamedPtfxAssetLoaded("scr_trevor3") then 195 | RequestNamedPtfxAsset("scr_trevor3") 196 | while not HasNamedPtfxAssetLoaded("scr_trevor3") do 197 | Wait(10) 198 | end 199 | end 200 | 201 | Fire.active[fireIndex].flameCoords[flameIndex] = vector3(coords.x, coords.y, z) 202 | 203 | Fire.active[fireIndex].sound[flameIndex] = GetSoundId() 204 | PlaySoundFromCoord(Fire.active[fireIndex].sound[flameIndex], "LAMAR1_WAREHOUSE_FIRE", coords.x, coords.y, z, 0, 0, 0, 0) 205 | 206 | SetPtfxAssetNextCall("scr_agencyheistb") 207 | 208 | Fire.active[fireIndex].particles[flameIndex] = StartParticleFxLoopedAtCoord( 209 | "scr_env_agency3b_smoke", 210 | Fire.active[fireIndex].flameCoords[flameIndex].x, 211 | Fire.active[fireIndex].flameCoords[flameIndex].y, 212 | Fire.active[fireIndex].flameCoords[flameIndex].z + 1.0, 213 | 0.0, 214 | 0.0, 215 | 0.0, 216 | 1.0, 217 | false, 218 | false, 219 | false, 220 | false 221 | ) 222 | 223 | SetPtfxAssetNextCall("scr_trevor3") 224 | 225 | Fire.active[fireIndex].flameParticles[flameIndex] = StartParticleFxLoopedAtCoord( 226 | "scr_trev3_trailer_plume", 227 | Fire.active[fireIndex].flameCoords[flameIndex].x, 228 | Fire.active[fireIndex].flameCoords[flameIndex].y, 229 | Fire.active[fireIndex].flameCoords[flameIndex].z + 1.2, 230 | 0.0, 231 | 0.0, 232 | 0.0, 233 | 1.0, 234 | false, 235 | false, 236 | false, 237 | false 238 | ) 239 | 240 | else 241 | Fire.active[fireIndex].flames[flameIndex] = nil 242 | end 243 | end 244 | end 245 | end 246 | syncInProgress = false 247 | Citizen.Wait(1500) 248 | end 249 | end 250 | ) -------------------------------------------------------------------------------- /client/main.lua: -------------------------------------------------------------------------------- 1 | --================================-- 2 | -- FIRE SCRIPT v1.7.6 -- 3 | -- by GIMI (+ foregz, Albo1125) -- 4 | -- License: GNU GPL 3.0 -- 5 | --================================-- 6 | 7 | Version = GetResourceMetadata(GetCurrentResourceName(), "version") 8 | 9 | --================================-- 10 | -- CHAT -- 11 | --================================-- 12 | 13 | TriggerEvent("chat:addTemplate", "firescript", '
{0} {1}
') 14 | 15 | TriggerEvent('chat:addSuggestion', '/startfire', 'Creates a fire', { 16 | { 17 | name = "spread", 18 | help = "How many times can the fire spread?" 19 | }, 20 | { 21 | name = "chance", 22 | help = "0 - 100; How quickly the fire spreads?" 23 | }, 24 | { 25 | name = "dispatch", 26 | help = "true or false (default false)" 27 | }, 28 | { 29 | name = "dispatchMessage", 30 | help = "Sets a custom dispatch message (leave empty to generate automatically)" 31 | } 32 | }) 33 | 34 | TriggerEvent('chat:addSuggestion', '/stopfire', 'Stops the fire', { 35 | { 36 | name = "index", 37 | help = "The fire's index" 38 | } 39 | }) 40 | 41 | TriggerEvent('chat:addSuggestion', '/stopallfires', 'Stops all fires') 42 | 43 | TriggerEvent('chat:addSuggestion', '/registerscenario', 'Registers a new fire configuration') 44 | 45 | TriggerEvent('chat:addSuggestion', '/addflame', 'Adds a flame to a scenario', { 46 | { 47 | name = "scenarioID", 48 | help = "The scenario" 49 | }, 50 | { 51 | name = "spread", 52 | help = "How many times can the flame spread?" 53 | }, 54 | { 55 | name = "chance", 56 | help = "How many out of 100 chances should the fire spread? (0-100)" 57 | } 58 | }) 59 | 60 | TriggerEvent('chat:addSuggestion', '/removeflame', 'Removes a flame from a scenario', { 61 | { 62 | name = "scenarioID", 63 | help = "The fire ID" 64 | }, 65 | { 66 | name = "flameID", 67 | help = "The flame ID" 68 | } 69 | }) 70 | 71 | TriggerEvent('chat:addSuggestion', '/removescenario', 'Removes a scenario', { 72 | { 73 | name = "scenarioID", 74 | help = "The fire ID" 75 | } 76 | }) 77 | 78 | TriggerEvent('chat:addSuggestion', '/startscenario', 'Starts a scenario', { 79 | { 80 | name = "scenarioID", 81 | help = "The fire ID" 82 | }, 83 | { 84 | name = "triggerDispatch", 85 | help = "true / false - should the script trigger dispatch after spawning the fire? (default false)" 86 | } 87 | }) 88 | 89 | TriggerEvent('chat:addSuggestion', '/stopscenario', 'Stops a scenario', { 90 | { 91 | name = "scenarioID", 92 | help = "The fire ID" 93 | } 94 | }) 95 | 96 | TriggerEvent('chat:addSuggestion', '/firewl', 'Manages the fire script whitelist', { 97 | { 98 | name = "action", 99 | help = "add / remove" 100 | }, 101 | { 102 | name = "playerID", 103 | help = "The player's server ID" 104 | } 105 | }) 106 | 107 | TriggerEvent('chat:addSuggestion', '/firewlreload', 'Reloads the whitelist from the config') 108 | 109 | TriggerEvent('chat:addSuggestion', '/firedispatch', 'Manages the fire script dispatch subscribers', { 110 | { 111 | name = "action", 112 | help = "add / remove / scenario (scenario = sets the scenario's dispatch message)" 113 | }, 114 | { 115 | name = "playerID / scenarioID", 116 | help = "The player's server ID / the scenario's ID" 117 | }, 118 | { 119 | name = "dispatchMessage", 120 | help = "(optional) Sets a custom dispatch message for the scenario (use only with par. #1 scenario; leave empty to remove previous custom message)" 121 | } 122 | }) 123 | 124 | TriggerEvent('chat:addSuggestion', '/remindme', 'Sets the GPS waypoint to the specified dispatch call.', { 125 | { 126 | name = "dispatchID", 127 | help = "The dispatch identifier (number)" 128 | } 129 | }) 130 | 131 | TriggerEvent('chat:addSuggestion', '/cleardispatch', 'Clears navigation to the last dispatch call.', { 132 | { 133 | name = "dispatchID", 134 | help = "(optional) The dispatch identifier, if filled in, the call's blip will be removed. Set to 0 to remove all dispatch blips." 135 | } 136 | }) 137 | 138 | TriggerEvent('chat:addSuggestion', '/randomfires', 'Manages the random fire spawner', { 139 | { 140 | name = "action", 141 | help = "add / remove / enable / disable" 142 | }, 143 | { 144 | name = "p2", 145 | help = "(optional) For add / remove action, fill in the scenario ID." 146 | } 147 | }) 148 | 149 | TriggerEvent('chat:addSuggestion', '/setscenariodifficulty', 'Sets a difficulty specifically for one scenario', { 150 | { 151 | name = "scenarioID", 152 | help = "The scenario identifier" 153 | }, 154 | { 155 | name = "difficulty", 156 | help = "Difficulty to be assigned to the scenario (leave empty or 0 to set to default)" 157 | } 158 | }) 159 | 160 | --================================-- 161 | -- SYNC ON CONNECT -- 162 | --================================-- 163 | 164 | RegisterNetEvent('playerSpawned') 165 | AddEventHandler( 166 | 'playerSpawned', 167 | function() 168 | print("Requested synchronization..") 169 | TriggerServerEvent('fireManager:requestSync') 170 | end 171 | ) 172 | 173 | RegisterNetEvent('onClientResourceStart') 174 | AddEventHandler( 175 | 'onClientResourceStart', 176 | function(resourceName) 177 | if resourceName == GetCurrentResourceName() then 178 | -- Check the command whitelist 179 | TriggerServerEvent('fireManager:checkWhitelist') 180 | 181 | if Config.Dispatch.toneSources then 182 | while not RequestScriptAudioBank('toneaudio/firescript_alarm', false) do 183 | Citizen.Wait(10) 184 | end 185 | end 186 | end 187 | end 188 | ) 189 | 190 | --================================-- 191 | -- CLEAN UP -- 192 | --================================-- 193 | 194 | AddEventHandler( 195 | 'onClientResourceStop', 196 | function(resourceName) 197 | if resourceName == GetCurrentResourceName() then 198 | ReleaseScriptAudioBank('toneaudio/firescript_alarm') 199 | end 200 | end 201 | ) 202 | 203 | --================================-- 204 | -- COMMANDS -- 205 | --================================-- 206 | 207 | RegisterCommand( 208 | 'remindme', 209 | function(source, args, rawCommand) 210 | local dispatchNumber = tonumber(args[1]) 211 | if not dispatchNumber then 212 | sendMessage("Invalid argument.") 213 | return 214 | end 215 | 216 | local success = Dispatch:remind(dispatchNumber) 217 | 218 | if not success then 219 | sendMessage("Couldn't find the specified dispatch.") 220 | return 221 | end 222 | end, 223 | false 224 | ) 225 | 226 | RegisterCommand( 227 | 'cleardispatch', 228 | function(source, args, rawCommand) 229 | Dispatch:clear(tonumber(args[1])) 230 | end, 231 | false 232 | ) 233 | 234 | RegisterCommand( 235 | 'startfire', 236 | function(source, args, rawCommand) 237 | local maxSpread = tonumber(args[1]) 238 | local probability = tonumber(args[2]) 239 | local triggerDispatch = args[3] == "true" 240 | 241 | table.remove(args, 1) 242 | table.remove(args, 1) 243 | table.remove(args, 1) 244 | 245 | local dispatchMessage = next(args) and table.concat(args, " ") or nil 246 | 247 | TriggerServerEvent('fireManager:command:startfire', GetEntityCoords(PlayerPedId()), maxSpread, probability, triggerDispatch, dispatchMessage) 248 | end, 249 | false 250 | ) 251 | 252 | RegisterCommand( 253 | 'registerscenario', 254 | function(source, args, rawCommand) 255 | local coords = nil 256 | 257 | local x = tonumber(args[1]) 258 | local y = tonumber(args[2]) 259 | local z = tonumber(args[3]) 260 | 261 | if x and y and z then 262 | coords = vector3(x, y, z) 263 | end 264 | 265 | TriggerServerEvent('fireManager:command:registerscenario', coords or GetEntityCoords(PlayerPedId())) 266 | end, 267 | false 268 | ) 269 | 270 | RegisterCommand( 271 | 'addflame', 272 | function(source, args, rawCommand) 273 | local scenarioID = tonumber(args[1]) 274 | local spread = tonumber(args[2]) 275 | local chance = tonumber(args[3]) 276 | 277 | local coords = nil 278 | 279 | local x = tonumber(args[4]) 280 | local y = tonumber(args[5]) 281 | local z = tonumber(args[6]) 282 | 283 | if x and y and z then 284 | coords = vector3(x, y, z) 285 | end 286 | 287 | if scenarioID and spread and chance then 288 | TriggerServerEvent('fireManager:command:addflame', scenarioID, coords or GetEntityCoords(PlayerPedId()), spread, chance) 289 | end 290 | end, 291 | false 292 | ) 293 | 294 | -- Aliases 295 | 296 | RegisterCommand( 297 | 'registerfire', 298 | function(source, args, rawCommand) 299 | ExecuteCommand("registerscenario" .. rawCommand:sub(13)) 300 | end, 301 | false 302 | ) 303 | 304 | RegisterCommand( 305 | 'removeregisteredfire', 306 | function(source, args, rawCommand) 307 | ExecuteCommand("removescenario" .. rawCommand:sub(21)) 308 | end, 309 | false 310 | ) 311 | 312 | RegisterCommand( 313 | 'startregisteredfire', 314 | function(source, args, rawCommand) 315 | ExecuteCommand("startscenario" .. rawCommand:sub(20)) 316 | end, 317 | false 318 | ) 319 | 320 | RegisterCommand( 321 | 'stopregisteredfire', 322 | function(source, args, rawCommand) 323 | ExecuteCommand("stopscenario" .. rawCommand:sub(19)) 324 | end, 325 | false 326 | ) 327 | 328 | --================================-- 329 | -- EVENTS -- 330 | --================================-- 331 | 332 | RegisterNetEvent('fireClient:synchronizeFlames') 333 | AddEventHandler( 334 | 'fireClient:synchronizeFlames', 335 | function(fires) 336 | syncInProgress = true 337 | Fire:removeAll( 338 | function() 339 | for k, v in pairs(fires) do 340 | for _k, _v in ipairs(v) do 341 | Fire:createFlame(k, _k, _v.c) 342 | end 343 | end 344 | syncInProgress = false 345 | end 346 | ) 347 | end 348 | ) 349 | 350 | RegisterNetEvent('fireClient:removeFire') 351 | AddEventHandler( 352 | 'fireClient:removeFire', 353 | function(fireIndex) 354 | while syncInProgress do 355 | Citizen.Wait(10) 356 | end 357 | syncInProgress = true 358 | Fire:remove(fireIndex) 359 | syncInProgress = false 360 | end 361 | ) 362 | 363 | RegisterNetEvent('fireClient:removeAllFires') 364 | AddEventHandler( 365 | 'fireClient:removeAllFires', 366 | function() 367 | while syncInProgress do 368 | Citizen.Wait(10) 369 | end 370 | syncInProgress = true 371 | Fire:removeAll( 372 | function() 373 | syncInProgress = false 374 | end 375 | ) 376 | end 377 | ) 378 | 379 | RegisterNetEvent("fireClient:removeFlame") 380 | AddEventHandler( 381 | "fireClient:removeFlame", 382 | function(fireIndex, flameIndex) 383 | while syncInProgress do 384 | Citizen.Wait(10) 385 | end 386 | syncInProgress = true 387 | Fire:removeFlame(fireIndex, flameIndex) 388 | syncInProgress = false 389 | end 390 | ) 391 | 392 | RegisterNetEvent("fireClient:createFlame") 393 | AddEventHandler( 394 | "fireClient:createFlame", 395 | function(fireIndex, flameIndex, coords) 396 | while syncInProgress do 397 | Citizen.Wait(10) 398 | end 399 | syncInProgress = true 400 | Fire:createFlame(fireIndex, flameIndex, coords) 401 | syncInProgress = false 402 | end 403 | ) 404 | 405 | -- Dispatch 406 | 407 | if Config.Dispatch.enabled == true then 408 | RegisterNetEvent('fd:dispatch') 409 | AddEventHandler( 410 | 'fd:dispatch', 411 | function(coords) 412 | local streetName, crossingRoad = GetStreetNameAtCoord(coords.x, coords.y, coords.z) 413 | local streetName = GetStreetNameFromHashKey(streetName) 414 | local text = ("Fire near %s."):format((crossingRoad > 0) and streetName .. " / " .. GetStreetNameFromHashKey(crossingRoad) or streetName) 415 | TriggerServerEvent('fireDispatch:create', text, coords) 416 | end 417 | ) 418 | end 419 | 420 | RegisterNetEvent('fireClient:createDispatch') 421 | AddEventHandler( 422 | 'fireClient:createDispatch', 423 | function(dispatchNumber, coords) 424 | Dispatch:create(dispatchNumber, coords) 425 | end 426 | ) 427 | 428 | RegisterNetEvent('fireClient:playTone') 429 | AddEventHandler( 430 | 'fireClient:playTone', 431 | function() 432 | Dispatch:playTone() 433 | end 434 | ) 435 | -------------------------------------------------------------------------------- /client/utils.lua: -------------------------------------------------------------------------------- 1 | --================================-- 2 | -- FIRE SCRIPT v1.7.6 -- 3 | -- by GIMI (+ foregz, Albo1125) -- 4 | -- License: GNU GPL 3.0 -- 5 | --================================-- 6 | 7 | -- Chat 8 | 9 | function sendMessage(text) 10 | TriggerEvent( 11 | "chat:addMessage", 12 | { 13 | templateId = "firescript", 14 | args = { 15 | ("FireScript v%s"):format(Version), 16 | text 17 | } 18 | } 19 | ) 20 | end 21 | 22 | -- Table functions 23 | 24 | function countElements(table) 25 | local count = 0 26 | if type(table) == "table" then 27 | for k, v in pairs(table) do 28 | count = count + 1 29 | end 30 | end 31 | return count 32 | end 33 | 34 | syncInProgress = false -------------------------------------------------------------------------------- /config.lua: -------------------------------------------------------------------------------- 1 | --================================-- 2 | -- FIRE SCRIPT v2.0.0 -- 3 | -- by GIMI (+ foregz, Albo1125) -- 4 | -- License: GNU GPL 3.0 -- 5 | --================================-- 6 | 7 | Config = {} 8 | 9 | Config.Fire = { 10 | fireSpreadChance = 5, -- Out of 100 chances, how many lead to fire spreading? (not exactly percents) 11 | maximumSpreads = 5, 12 | difficulty = 3, -- 1 to 10; sets how hard (lengthy) it will be to extinguish a fire (set nil as default or a whole number larger than 0, e.g. 2, to increase difficulty; try how it works, probably don't go higher than 10) 13 | spawner = { -- Requires the use of the built-in dispatch system 14 | enableOnStartup = true, 15 | interval = 1800000, -- Random fire spawn interval (set to nil or false if you don't want to spawn random fires) in ms 16 | chance = 50, -- Fire spawn chance (out of 100 chances, how many lead to spawning a fire?); Set to values between 1-100 17 | players = 3, -- Sets the minimum number of players subscribed to dispatch for the spawner to spawn fires. 18 | firefighterJobs = { -- If using a framework (Config.Dispatch.enableFramework), you can specify which players will count as firefighters in Config.Fire.spawner.players above; If set to nil, all jobs specified in Config.Dispatch.jobs will count as firefighters 19 | ["fd"] = true -- Always set the job name in the key, value has to be true 20 | } 21 | } 22 | } 23 | 24 | Config.Dispatch = { 25 | enabled = true, -- Set this to false if you don't want to use the default dispatch system 26 | timeout = 15000, -- The amount of time in ms to delay the dispatch after the fire has been created 27 | storeLast = 5, -- The client will store the last five dispatch coordinates for use with /remindme 28 | clearGpsRadius = 20.0, -- If you don't want to automatically clear the route upon arrival, leave this to false 29 | removeBlipTimeout = 400000, -- The amount of time in ms after which the dispatch call blip will be automatically removed 30 | playSound = true, 31 | enableFramework = 1, -- Set to nil if you don't want to use any framework implementation. Set to 1 for ESX, 2 for QB-Core. 32 | jobs = { -- Set to a ESX job / jobs you want to be automatically subscribed to dispatch; Set to nil or false if you don't want to use this 33 | "fd" 34 | }, 35 | toneSources = { -- Here you can set coordinates of sound sources for the fire tones to go off at; Set to nil if you wish to disable this function. 36 | -- Fire Station 7 37 | vector3(1207.11, -1463.37, 36), 38 | vector3(1195, -1464, 36), 39 | vector3(1195, -1484, 36), 40 | vector3(1207.11, -1484, 36), 41 | -- Sandy Shores 42 | vector3(1691, 3586, 37) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /data/firescript_alarm.dat54.rel: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gimicze/firescript/cacbcce450247f06b73571f9db7c729933d552d0/data/firescript_alarm.dat54.rel -------------------------------------------------------------------------------- /data/firescript_alarm.dat54.rel.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | toneaudio\firescript_alarm 6 | 7 | 8 | 9 | 10 | long_beeps 11 |
12 | 13 | 14 | 15 | scripted 16 |
17 | toneaudio/firescript_alarm 18 | long_beeps 19 | 20 |
21 | 22 | short_beeps 23 |
24 | 25 | 26 | 27 | scripted 28 |
29 | toneaudio/firescript_alarm 30 | short_beeps 31 | 32 |
33 | 34 | 35 | 36 | firescript_alarm 37 |
38 | 39 |
40 | 41 | 42 | long_beeps 43 | long_beeps 44 | 45 | 46 | short_beeps 47 | short_beeps 48 | 49 | 50 |
51 |
52 |
53 | -------------------------------------------------------------------------------- /fxmanifest.lua: -------------------------------------------------------------------------------- 1 | fx_version 'adamant' 2 | 3 | games { 4 | 'gta5' 5 | } 6 | 7 | author 'GIMI, foregz, Albo1125' 8 | version '2.0.2' 9 | description 'Fire Script' 10 | 11 | client_scripts { 12 | "config.lua", 13 | "client/utils.lua", 14 | "client/fire.lua", 15 | "client/dispatch.lua", 16 | "client/main.lua", 17 | } 18 | 19 | server_scripts { 20 | "config.lua", 21 | "server/utils.lua", 22 | "server/whitelist.lua", 23 | "server/fire.lua", 24 | "server/dispatch.lua", 25 | "server/main.lua", 26 | } 27 | 28 | files { 29 | 'data/firescript_alarm.dat54.rel', 30 | 'toneaudio/firescript_alarm.awc', 31 | } 32 | 33 | data_file 'AUDIO_WAVEPACK' 'toneaudio' 34 | data_file 'AUDIO_SOUNDDATA' 'data/firescript_alarm.dat' 35 | -------------------------------------------------------------------------------- /server/dispatch.lua: -------------------------------------------------------------------------------- 1 | --================================-- 2 | -- FIRE SCRIPT v1.7.2 -- 3 | -- by GIMI (+ foregz, Albo1125) -- 4 | -- License: GNU GPL 3.0 -- 5 | --================================-- 6 | 7 | Dispatch = { 8 | _players = {}, 9 | _firefighters = {}, 10 | lastNumber = 0, 11 | expectingInfo = {}, 12 | __index = self, 13 | init = function(object) 14 | object = object or {_players = {}, _firefighters = {}, lastNumber = 0, expectingInfo = {}} 15 | setmetatable(object, self) 16 | return object 17 | end 18 | } 19 | 20 | function Dispatch:create(text, coords) 21 | text = tostring(text) 22 | 23 | if not (text and coords) then 24 | return 25 | end 26 | 27 | self.lastNumber = self.lastNumber + 1 28 | 29 | for k, v in pairs(self._players) do 30 | sendMessage(k, text, ("Dispatch (#%s)"):format(self.lastNumber)) 31 | TriggerClientEvent('fireClient:createDispatch', k, self.lastNumber, coords) 32 | end 33 | end 34 | 35 | function Dispatch:subscribe(serverId, isFirefighter) 36 | serverId = tonumber(serverId) 37 | self._players[serverId] = true 38 | if isFirefighter then 39 | self:addFirefighter(serverId) 40 | end 41 | end 42 | 43 | function Dispatch:unsubscribe(serverId) 44 | serverId = tonumber(serverId) 45 | self._players[serverId] = nil 46 | self:removeFirefighter(serverId) 47 | end 48 | 49 | function Dispatch:addFirefighter(serverId) 50 | serverId = tonumber(serverId) 51 | self._firefighters[serverId] = true 52 | end 53 | 54 | function Dispatch:removeFirefighter(serverId) 55 | serverId = tonumber(serverId) 56 | self._firefighters[serverId] = nil 57 | end 58 | 59 | function Dispatch:firefighters() 60 | return table.length(self._firefighters) 61 | end 62 | 63 | function Dispatch:players() 64 | return table.length(self._players) 65 | end 66 | 67 | function Dispatch:getRandomPlayer() 68 | if not next(self._players) then 69 | return next(GetPlayers()) or false 70 | end 71 | return table.random(self._players) 72 | end -------------------------------------------------------------------------------- /server/fire.lua: -------------------------------------------------------------------------------- 1 | --================================-- 2 | -- FIRE SCRIPT v2.0.2 -- 3 | -- by GIMI (+ foregz, Albo1125) -- 4 | -- License: GNU GPL 3.0 -- 5 | --================================-- 6 | 7 | Fire = { 8 | scenario = {}, 9 | random = {}, 10 | active = {}, 11 | binds = {}, 12 | activeBinds = {}, 13 | __index = self, 14 | init = function(o) 15 | o = o or {scenario = {}, random = {}, active = {}, binds = {}, activeBinds = {}} 16 | setmetatable(o, self) 17 | self.__index = self 18 | return o 19 | end 20 | } 21 | 22 | function Fire:create(coords, maximumSpread, spreadChance, difficulty) 23 | maximumSpread = maximumSpread and maximumSpread or Config.Fire.maximumSpreads 24 | spreadChance = spreadChance and spreadChance or Config.Fire.fireSpreadChance 25 | difficulty = difficulty and difficulty or Config.Fire.difficulty 26 | 27 | local fireIndex = highestIndex(self.active) 28 | fireIndex = fireIndex + 1 29 | 30 | self.active[fireIndex] = { 31 | maxSpread = maxSpread, 32 | spreadChance = spreadChance, 33 | difficulty = difficulty 34 | } 35 | 36 | self:createFlame(fireIndex, coords) 37 | 38 | local spread = true 39 | 40 | -- Spreading 41 | Citizen.CreateThread( 42 | function() 43 | while spread do 44 | Citizen.Wait(2000) 45 | local index, flames = highestIndex(self.active, fireIndex) 46 | if flames ~= 0 and flames <= maximumSpread and self.active[fireIndex] ~= nil then 47 | for k, v in ipairs(self.active[fireIndex]) do 48 | index, flames = highestIndex(self.active, fireIndex) 49 | local rndSpread = math.random(100) 50 | if flames <= maximumSpread and rndSpread <= spreadChance then 51 | local x = self.active[fireIndex][k].c.x 52 | local y = self.active[fireIndex][k].c.y 53 | local z = self.active[fireIndex][k].c.z 54 | 55 | local xSpread = math.random(-3, 3) 56 | local ySpread = math.random(-3, 3) 57 | 58 | coords = vector3(x + xSpread, y + ySpread, z) 59 | 60 | self:createFlame(fireIndex, coords) 61 | elseif flames > maximumSpread then 62 | spread = false 63 | break 64 | end 65 | end 66 | elseif flames == 0 or self.active[fireIndex] == nil then 67 | break 68 | end 69 | end 70 | end 71 | ) 72 | 73 | self.active[fireIndex].stopSpread = function() 74 | spread = false 75 | end 76 | 77 | return fireIndex 78 | end 79 | 80 | function Fire:createFlame(fireIndex, coords) 81 | local flameIndex = highestIndex(self.active, fireIndex) + 1 82 | self.active[fireIndex][flameIndex] = { 83 | c = coords 84 | } 85 | self.active[fireIndex][flameIndex].extinguished = self.active[fireIndex].difficulty and 1 or nil 86 | TriggerClientEvent('fireClient:createFlame', -1, fireIndex, flameIndex, coords) 87 | end 88 | 89 | function Fire:remove(fireIndex) 90 | if not (self.active[fireIndex] and next(self.active[fireIndex])) then 91 | return false 92 | end 93 | 94 | self.active[fireIndex].stopSpread() 95 | TriggerClientEvent('fireClient:removeFire', -1, fireIndex) 96 | 97 | if self.activeBinds[fireIndex] then 98 | self.binds[self.activeBinds[fireIndex]][fireIndex] = nil 99 | 100 | if self.activeBinds[fireIndex] == self.currentRandom and next(self.binds[self.activeBinds[fireIndex]]) == nil then 101 | self.currentRandom = nil 102 | end 103 | end 104 | 105 | self.active[fireIndex] = {} 106 | return true 107 | end 108 | 109 | function Fire:removeFlame(fireIndex, flameIndex, force) 110 | if self.active[fireIndex] and self.active[fireIndex][flameIndex] then 111 | if self.active[fireIndex][flameIndex].ignore and not force then 112 | return 113 | end 114 | 115 | self.active[fireIndex][flameIndex].ignore = true 116 | 117 | if not force and self.active[fireIndex].difficulty ~= nil and self.active[fireIndex][flameIndex].extinguished < self.active[fireIndex].difficulty then 118 | self.active[fireIndex][flameIndex].extinguished = self.active[fireIndex][flameIndex].extinguished + 1 119 | 120 | Citizen.SetTimeout(1500, 121 | function() 122 | self.active[fireIndex][flameIndex].ignore = nil 123 | end 124 | ) 125 | else 126 | self.active[fireIndex][flameIndex] = nil 127 | 128 | if type(next(self.active[fireIndex])) == "string" then 129 | self:remove(fireIndex) 130 | end 131 | 132 | TriggerClientEvent('fireClient:removeFlame', -1, fireIndex, flameIndex) 133 | end 134 | end 135 | end 136 | 137 | function Fire:removeAll() 138 | TriggerClientEvent('fireClient:removeAllFires', -1) 139 | for k, v in pairs(self.active) do 140 | if v.stopSpread then 141 | v.stopSpread() 142 | end 143 | end 144 | self.active = {} 145 | self.activeBinds = {} 146 | self.binds = {} 147 | self.currentRandom = nil 148 | end 149 | 150 | function Fire:register(coords, difficulty) 151 | local scenarioID = highestIndex(self.scenario) + 1 152 | 153 | self.scenario[scenarioID] = { 154 | flames = {} 155 | } 156 | 157 | if coords then 158 | self.scenario[scenarioID].dispatchCoords = coords 159 | end 160 | 161 | self:saveScenarios() 162 | 163 | return scenarioID 164 | end 165 | 166 | function Fire:startScenario(scenarioID, triggerDispatch, dispatchPlayer) 167 | if not self.scenario[scenarioID] then 168 | return false 169 | end 170 | 171 | if not self.binds[scenarioID] then 172 | self.binds[scenarioID] = {} 173 | end 174 | 175 | for k, v in pairs(self.scenario[scenarioID].flames) do 176 | local fireID = Fire:create(v.coords, v.spread, v.chance, self.scenario[scenarioID].difficulty) 177 | self.binds[scenarioID][fireID] = true 178 | self.activeBinds[fireID] = scenarioID 179 | Citizen.Wait(10) 180 | end 181 | 182 | if self.scenario[scenarioID].dispatchCoords and triggerDispatch and dispatchPlayer then 183 | if Config.Dispatch.toneSources and type(Config.Dispatch.toneSources) == "table" then 184 | TriggerClientEvent('fireClient:playTone', -1) 185 | end 186 | 187 | local dispatchCoords = self.scenario[scenarioID].dispatchCoords 188 | Citizen.SetTimeout( 189 | Config.Dispatch.timeout, 190 | function() 191 | if Config.Dispatch.enabled then 192 | if self.scenario[scenarioID].message ~= nil then 193 | Dispatch:create(self.scenario[scenarioID].message, dispatchCoords) 194 | else 195 | Dispatch.expectingInfo[dispatchPlayer] = true 196 | TriggerClientEvent('fd:dispatch', dispatchPlayer, dispatchCoords) 197 | end 198 | end 199 | end 200 | ) 201 | end 202 | 203 | return true 204 | end 205 | 206 | function Fire:stopScenario(scenarioID) 207 | if not self.binds[scenarioID] then 208 | return false 209 | end 210 | 211 | for k, v in pairs(self.binds[scenarioID]) do 212 | self.activeBinds[k] = nil 213 | Fire:remove(k) 214 | Citizen.Wait(10) 215 | end 216 | 217 | self.binds[scenarioID] = nil 218 | 219 | if self.currentRandom and self.currentRandom == scenarioID then 220 | self.currentRandom = nil 221 | end 222 | 223 | return true 224 | end 225 | 226 | function Fire:deleteScenario(scenarioID) 227 | if not self.scenario[scenarioID] then 228 | return false 229 | end 230 | 231 | if self.scenario[scenarioID].random then 232 | self:setRandom(scenarioID, false) 233 | end 234 | 235 | self.scenario[scenarioID] = nil 236 | 237 | self:saveScenarios() 238 | 239 | return true 240 | end 241 | 242 | function Fire:setScenarioDifficulty(scenarioID, difficulty) 243 | if not self.scenario[scenarioID] then 244 | return false 245 | end 246 | 247 | difficulty = difficulty < 1 and nil or difficulty 248 | 249 | self.scenario[scenarioID].difficulty = difficulty 250 | 251 | self:saveScenarios() 252 | 253 | return true 254 | end 255 | 256 | function Fire:addFlame(scenarioID, coords, spread, chance) 257 | if not (scenarioID and coords and spread and chance and self.scenario[scenarioID]) then 258 | return false 259 | end 260 | 261 | local flameID = highestIndex(self.scenario[scenarioID].flames) + 1 262 | 263 | self.scenario[scenarioID].flames[flameID] = {} 264 | self.scenario[scenarioID].flames[flameID].coords = coords 265 | self.scenario[scenarioID].flames[flameID].spread = spread 266 | self.scenario[scenarioID].flames[flameID].chance = chance 267 | 268 | self:saveScenarios() 269 | 270 | return flameID 271 | end 272 | 273 | function Fire:deleteFlame(scenarioID, flameID) 274 | if not (self.scenario[scenarioID] and self.scenario[scenarioID].flames[flameID]) then 275 | return false 276 | end 277 | 278 | table.remove(self.scenario[scenarioID].flames, flameID) 279 | 280 | self:saveScenarios() 281 | 282 | return true 283 | end 284 | 285 | function Fire:setRandom(scenarioID, random) 286 | random = random or nil 287 | scenarioID = tonumber(scenarioID) 288 | 289 | if not scenarioID or not self.scenario[scenarioID] then 290 | return false 291 | end 292 | 293 | self.scenario[scenarioID].random = random 294 | self.random[scenarioID] = random 295 | 296 | self:saveScenarios() 297 | 298 | return true 299 | end 300 | 301 | function Fire:startSpawner(frequency, chance) 302 | frequency = tonumber(frequency) or Config.Fire.spawner.interval 303 | chance = tonumber(chance) or Config.Fire.spawner.chance 304 | 305 | if self._stopSpawner or not self.random or not frequency then 306 | return false 307 | end 308 | 309 | local spawnerActive = true 310 | 311 | self._stopSpawner = function() 312 | spawnerActive = nil 313 | end 314 | 315 | Citizen.CreateThread( 316 | function() 317 | while spawnerActive do 318 | if next(self.random) and not self.currentRandom and Dispatch:firefighters() >= Config.Fire.spawner.players then 319 | if math.random(100) < chance then 320 | local randomscenarioID = table.random(self.random) 321 | local randomPlayer = Dispatch:getRandomPlayer() 322 | 323 | if randomscenarioID and randomPlayer then 324 | if self:startScenario(randomscenarioID, true, randomPlayer) then 325 | self.currentRandom = randomscenarioID 326 | end 327 | end 328 | end 329 | end 330 | 331 | Citizen.Wait(frequency) 332 | end 333 | end 334 | ) 335 | 336 | return true 337 | end 338 | 339 | function Fire:stopSpawner() 340 | if self._stopSpawner then 341 | self._stopSpawner() 342 | self._stopSpawner = nil 343 | end 344 | end 345 | 346 | -- Saving scenarios 347 | 348 | function Fire:saveScenarios() 349 | saveData(self.scenario, "fires") 350 | end 351 | 352 | function Fire:loadScenarios() 353 | local firesFile = loadData("fires") 354 | self.random = {} 355 | if firesFile ~= nil then 356 | self.scenario = firesFile 357 | for index, fire in pairs(self.scenario) do 358 | if fire.dispatchCoords then 359 | self.scenario[index].dispatchCoords = vector3(fire.dispatchCoords.x, fire.dispatchCoords.y, fire.dispatchCoords.z) 360 | end 361 | for _, flame in pairs(fire.flames) do 362 | self.scenario[index].flames[_].coords = vector3(flame.coords.x, flame.coords.y, flame.coords.z) 363 | end 364 | if fire.random == true then 365 | self.random[index] = true 366 | end 367 | end 368 | else 369 | self.scenario = {} 370 | saveData(self.scenario, "fires") 371 | end 372 | end -------------------------------------------------------------------------------- /server/main.lua: -------------------------------------------------------------------------------- 1 | --================================-- 2 | -- FIRE SCRIPT v2.0.0 -- 3 | -- by GIMI (+ foregz, Albo1125) -- 4 | -- License: GNU GPL 3.0 -- 5 | --================================-- 6 | 7 | --================================-- 8 | -- VERSION CHECK -- 9 | --================================-- 10 | 11 | Version = GetResourceMetadata(GetCurrentResourceName(), "version") 12 | LatestVersionFeed = "https://api.github.com/repos/gimicze/firescript/releases/latest" 13 | 14 | Citizen.CreateThread( 15 | checkVersion 16 | ) 17 | 18 | --================================-- 19 | -- INITIALIZE -- 20 | --================================-- 21 | 22 | function onResourceStart(resourceName) 23 | if (GetCurrentResourceName() == resourceName) then 24 | Whitelist:load() 25 | Fire:loadScenarios() 26 | if Config.Fire.spawner.enableOnStartup and Config.Fire.spawner.interval then 27 | if not Fire:startSpawner() then 28 | sendMessage(0, "Couldn't start fire spawner.") 29 | end 30 | end 31 | end 32 | end 33 | 34 | RegisterNetEvent('onResourceStart') 35 | AddEventHandler( 36 | 'onResourceStart', 37 | onResourceStart 38 | ) 39 | 40 | --================================-- 41 | -- CLEAN-UP -- 42 | --================================-- 43 | 44 | function onPlayerDropped() 45 | Whitelist:removePlayer(source) 46 | Dispatch:unsubscribe(source) 47 | end 48 | 49 | RegisterNetEvent('playerDropped') 50 | AddEventHandler( 51 | 'playerDropped', 52 | onPlayerDropped 53 | ) 54 | 55 | --================================-- 56 | -- COMMANDS -- 57 | --================================-- 58 | 59 | RegisterNetEvent('fireManager:command:startfire') 60 | AddEventHandler( 61 | 'fireManager:command:startfire', 62 | function(coords, maxSpread, chance, triggerDispatch, dispatchMessage) 63 | if not Whitelist:isWhitelisted(source, "firescript.start") then 64 | sendMessage(source, "Insufficient permissions.") 65 | return 66 | end 67 | 68 | local _source = source 69 | 70 | local maxSpread = (maxSpread ~= nil and tonumber(maxSpread) ~= nil) and tonumber(maxSpread) or Config.Fire.maximumSpreads 71 | local chance = (chance ~= nil and tonumber(chance) ~= nil) and tonumber(chance) or Config.Fire.fireSpreadChance 72 | 73 | local fireIndex = Fire:create(coords, maxSpread, chance) 74 | 75 | sendMessage(source, "Spawned fire #" .. fireIndex) 76 | 77 | if triggerDispatch then 78 | if Config.Dispatch.toneSources and type(Config.Dispatch.toneSources) == "table" then 79 | TriggerClientEvent('fireClient:playTone', -1) 80 | end 81 | 82 | Citizen.SetTimeout( 83 | Config.Dispatch.timeout, 84 | function() 85 | if Config.Dispatch.enabled and not Config.Dispatch.disableCalls then 86 | if dispatchMessage then 87 | Dispatch:create(dispatchMessage, coords) 88 | else 89 | Dispatch.expectingInfo[_source] = true 90 | TriggerClientEvent('fd:dispatch', _source, coords) 91 | end 92 | end 93 | end 94 | ) 95 | end 96 | end 97 | ) 98 | 99 | RegisterNetEvent('fireManager:command:registerscenario') 100 | AddEventHandler( 101 | 'fireManager:command:registerscenario', 102 | function(coords) 103 | if not Whitelist:isWhitelisted(source, "firescript.manage") then 104 | sendMessage(source, "Insufficient permissions.") 105 | return 106 | end 107 | 108 | local scenarioID = Fire:register(coords) 109 | 110 | sendMessage(source, "Created scenario #" .. scenarioID) 111 | end 112 | ) 113 | 114 | RegisterNetEvent('fireManager:command:addflame') 115 | AddEventHandler( 116 | 'fireManager:command:addflame', 117 | function(scenarioID, coords, spread, chance) 118 | if not Whitelist:isWhitelisted(source, "firescript.manage") then 119 | sendMessage(source, "Insufficient permissions.") 120 | return 121 | end 122 | 123 | local scenarioID = tonumber(scenarioID) 124 | local spread = tonumber(spread) 125 | local chance = tonumber(chance) 126 | 127 | if not (coords and scenarioID and spread and chance) then 128 | return 129 | end 130 | 131 | local flameID = Fire:addFlame(scenarioID, coords, spread, chance) 132 | 133 | if not flameID then 134 | sendMessage(source, "No such scenario.") 135 | return 136 | end 137 | 138 | sendMessage(source, "Added flame #" .. flameID) 139 | end 140 | ) 141 | 142 | RegisterCommand( 143 | 'stopfire', 144 | function(source, args, rawCommand) 145 | if not Whitelist:isWhitelisted(source, "firescript.stop") then 146 | sendMessage(source, "Insufficient permissions.") 147 | return 148 | end 149 | 150 | local fireIndex = tonumber(args[1]) 151 | 152 | if not fireIndex then 153 | return 154 | end 155 | 156 | if Fire:remove(fireIndex) then 157 | sendMessage(source, "Stopping fire #" .. fireIndex) 158 | TriggerClientEvent("pNotify:SendNotification", source, { 159 | text = "Fire " .. fireIndex .. " going out...", 160 | type = "info", 161 | timeout = 5000, 162 | layout = "centerRight", 163 | queue = "fire" 164 | }) 165 | end 166 | end, 167 | false 168 | ) 169 | 170 | RegisterCommand( 171 | 'stopallfires', 172 | function(source, args, rawCommand) 173 | if not Whitelist:isWhitelisted(source, "firescript.stop") then 174 | sendMessage(source, "Insufficient permissions.") 175 | return 176 | end 177 | 178 | Fire:removeAll() 179 | 180 | sendMessage(source, "Stopping fires") 181 | TriggerClientEvent("pNotify:SendNotification", source, { 182 | text = "Fires going out...", 183 | type = "info", 184 | timeout = 5000, 185 | layout = "centerRight", 186 | queue = "fire" 187 | }) 188 | end, 189 | false 190 | ) 191 | 192 | RegisterCommand( 193 | 'removeflame', 194 | function(source, args, rawCommand) 195 | if not Whitelist:isWhitelisted(source, "firescript.manage") then 196 | sendMessage(source, "Insufficient permissions.") 197 | return 198 | end 199 | 200 | local scenarioID = tonumber(args[1]) 201 | local flameID = tonumber(args[2]) 202 | 203 | if not (scenarioID and flameID) then 204 | return 205 | end 206 | 207 | local success = Fire:deleteFlame(scenarioID, flameID) 208 | 209 | if not success then 210 | sendMessage(source, "No such fire or flame registered.") 211 | return 212 | end 213 | 214 | sendMessage(source, "Removed flame #" .. flameID) 215 | end, 216 | false 217 | ) 218 | 219 | RegisterCommand( 220 | 'removescenario', 221 | function(source, args, rawCommand) 222 | if not Whitelist:isWhitelisted(source, "firescript.manage") then 223 | sendMessage(source, "Insufficient permissions.") 224 | return 225 | end 226 | local scenarioID = tonumber(args[1]) 227 | if not scenarioID then 228 | return 229 | end 230 | 231 | local success = Fire:deleteScenario(scenarioID) 232 | 233 | if not success then 234 | sendMessage(source, "No such scenario.") 235 | return 236 | end 237 | 238 | sendMessage(source, "Removed scenario #" .. scenarioID) 239 | end, 240 | false 241 | ) 242 | 243 | RegisterCommand( 244 | 'startscenario', 245 | function(source, args, rawCommand) 246 | if not Whitelist:isWhitelisted(source, "firescript.start") then 247 | sendMessage(source, "Insufficient permissions.") 248 | return 249 | end 250 | 251 | local scenarioID = tonumber(args[1]) 252 | local triggerDispatch = args[2] == "true" 253 | 254 | if not scenarioID then 255 | return 256 | end 257 | 258 | local success = Fire:startScenario(scenarioID, triggerDispatch, source) 259 | 260 | if not success then 261 | sendMessage(source, "No such scenario.") 262 | return 263 | end 264 | 265 | sendMessage(source, "Started scenario #" .. scenarioID) 266 | end, 267 | false 268 | ) 269 | 270 | RegisterCommand( 271 | 'stopscenario', 272 | function(source, args, rawCommand) 273 | if not Whitelist:isWhitelisted(source, "firescript.stop") then 274 | sendMessage(source, "Insufficient permissions.") 275 | return 276 | end 277 | local _source = source 278 | local scenarioID = tonumber(args[1]) 279 | 280 | if not scenarioID then 281 | return 282 | end 283 | 284 | local success = Fire:stopScenario(scenarioID) 285 | 286 | if not success then 287 | sendMessage(source, "No such scenario active.") 288 | return 289 | end 290 | 291 | sendMessage(source, "Stopping scenario #" .. scenarioID) 292 | 293 | TriggerClientEvent("pNotify:SendNotification", source, { 294 | text = "Fire going out...", 295 | type = "info", 296 | timeout = 5000, 297 | layout = "centerRight", 298 | queue = "fire" 299 | }) 300 | end, 301 | false 302 | ) 303 | 304 | RegisterCommand( 305 | 'firewl', 306 | function(source, args, rawCommand) 307 | local action = args[1] 308 | local serverId = tonumber(args[2]) 309 | 310 | if not (action and serverId) or serverId < 1 then 311 | return 312 | end 313 | 314 | local identifier = GetPlayerIdentifier(serverId, 0) 315 | 316 | if not identifier then 317 | sendMessage(source, "Player not online.") 318 | return 319 | end 320 | 321 | if action == "add" then 322 | Whitelist:addPlayer(serverId, identifier) 323 | sendMessage(source, ("Added %s to the whitelist."):format(GetPlayerName(serverId))) 324 | elseif action == "remove" then 325 | Whitelist:removePlayer(serverId, identifier) 326 | sendMessage(source, ("Removed %s from the whitelist."):format(GetPlayerName(serverId))) 327 | else 328 | sendMessage(source, "Invalid action.") 329 | end 330 | end, 331 | true 332 | ) 333 | 334 | RegisterCommand( 335 | 'firewlreload', 336 | function(source, args, rawCommand) 337 | Whitelist:load() 338 | sendMessage(source, "Reloaded whitelist from config.") 339 | end, 340 | true 341 | ) 342 | 343 | RegisterCommand( 344 | 'firewlsave', 345 | function(source, args, rawCommand) 346 | Whitelist:save() 347 | sendMessage(source, "Saved whitelist.") 348 | end, 349 | true 350 | ) 351 | 352 | RegisterCommand( 353 | 'firedispatch', 354 | function(source, args, rawCommand) 355 | local action = args[1] 356 | local serverId = tonumber(args[2]) 357 | 358 | if not (action and serverId) or serverId < 1 then 359 | return 360 | end 361 | 362 | if action == "scenario" then 363 | if not Fire.scenario[serverId] then 364 | sendMessage(source, "The specified scenario hasn't been found.") 365 | return 366 | end 367 | 368 | table.remove(args, 1) 369 | table.remove(args, 1) 370 | 371 | Fire.scenario[serverId].message = next(args) and table.concat(args, " ") or nil 372 | Fire:saveScenarios() 373 | sendMessage(source, ("Changed scenario's (#%s) dispatch message."):format(serverId)) 374 | else 375 | local identifier = GetPlayerIdentifier(serverId, 0) 376 | 377 | if not identifier then 378 | sendMessage(source, "Player not online.") 379 | return 380 | end 381 | 382 | if action == "add" then 383 | Dispatch:subscribe(serverId, (not args[3] or args[3] ~= "false")) 384 | sendMessage(source, ("Subscribed %s to dispatch."):format(GetPlayerName(serverId))) 385 | elseif action == "remove" then 386 | Dispatch:unsubscribe(serverId, identifier) 387 | sendMessage(source, ("Unsubscribed %s from the dispatch."):format(GetPlayerName(serverId))) 388 | else 389 | sendMessage(source, "Invalid action.") 390 | end 391 | end 392 | end, 393 | true 394 | ) 395 | 396 | RegisterCommand( 397 | 'randomfires', 398 | function(source, args, rawCommand) 399 | if not Whitelist:isWhitelisted(source, "firescript.manage") then 400 | sendMessage(source, "Insufficient permissions.") 401 | return 402 | end 403 | 404 | local _source = source 405 | local action = args[1] 406 | local scenarioID = tonumber(args[2]) 407 | 408 | if not action then 409 | return 410 | end 411 | 412 | if action == "add" then 413 | if not scenarioID then 414 | sendMessage(source, "Invalid argument (2).") 415 | return 416 | end 417 | Fire:setRandom(scenarioID, true) 418 | sendMessage(source, ("Set scenario #%s to start randomly."):format(scenarioID)) 419 | elseif action == "remove" then 420 | if not scenarioID then 421 | sendMessage(source, "Invalid argument (2).") 422 | return 423 | end 424 | Fire:setRandom(scenarioID, false) 425 | sendMessage(source, ("Set scenario #%s not to start randomly."):format(scenarioID)) 426 | elseif action == "disable" then 427 | Fire:stopSpawner() 428 | sendMessage(source, "Disabled random fire spawn.") 429 | elseif action == "enable" then 430 | Fire:startSpawner() 431 | sendMessage(source, "Enabled random fire spawn.") 432 | else 433 | sendMessage(source, "Invalid action.") 434 | end 435 | end, 436 | false 437 | ) 438 | 439 | RegisterCommand( 440 | 'setscenariodifficulty', 441 | function(source, args, rawCommand) 442 | if not Whitelist:isWhitelisted(source, "firescript.manage") then 443 | sendMessage(source, "Insufficient permissions.") 444 | return 445 | end 446 | 447 | local scenarioID = tonumber(args[1]) 448 | local difficulty = tonumber(args[2]) 449 | 450 | if not scenarioID or not difficulty or difficulty < 0 then 451 | sendMessage(source, "Invalid argument") 452 | return 453 | end 454 | 455 | local message = Fire:setScenarioDifficulty(scenarioID, difficulty) and ("Scenario #%s set to difficulty %s"):format(scenarioID, difficulty) or ("Scenario #%s doesn't exist"):format(scenarioID) 456 | 457 | sendMessage(source, message) 458 | end 459 | ) 460 | 461 | --================================-- 462 | -- FIRE SYNC -- 463 | --================================-- 464 | 465 | RegisterNetEvent('fireManager:requestSync') 466 | AddEventHandler( 467 | 'fireManager:requestSync', 468 | function() 469 | if source > 0 then 470 | TriggerClientEvent('fireClient:synchronizeFlames', source, Fire.active) 471 | end 472 | end 473 | ) 474 | 475 | RegisterNetEvent('fireManager:createFlame') 476 | AddEventHandler( 477 | 'fireManager:createFlame', 478 | function(fireIndex, coords) 479 | Fire:createFlame(fireIndex, coords) 480 | end 481 | ) 482 | 483 | RegisterNetEvent('fireManager:createFire') 484 | AddEventHandler( 485 | 'fireManager:createFire', 486 | function() 487 | Fire:create(coords, maximumSpread, spreadChance) 488 | end 489 | ) 490 | 491 | RegisterNetEvent('fireManager:removeFire') 492 | AddEventHandler( 493 | 'fireManager:removeFire', 494 | function(fireIndex) 495 | Fire:remove(fireIndex) 496 | end 497 | ) 498 | 499 | RegisterNetEvent('fireManager:removeAllFires') 500 | AddEventHandler( 501 | 'fireManager:removeAllFires', 502 | function() 503 | Fire:removeAll() 504 | end 505 | ) 506 | 507 | RegisterNetEvent('fireManager:removeFlame') 508 | AddEventHandler( 509 | 'fireManager:removeFlame', 510 | function(fireIndex, flameIndex) 511 | Fire:removeFlame(fireIndex, flameIndex) 512 | end 513 | ) 514 | 515 | --================================-- 516 | -- DISPATCH -- 517 | --================================-- 518 | 519 | RegisterNetEvent('fireDispatch:registerPlayer') 520 | AddEventHandler( 521 | 'fireDispatch:registerPlayer', 522 | function(playerSource, isFirefighter) 523 | source = tonumber(source) 524 | playerSource = tonumber(playerSource) 525 | if (source and source > 0) or not playerSource or playerSource < 0 then 526 | return 527 | end 528 | 529 | Dispatch:subscribe(playerSource, not (isFirefighter)) 530 | end 531 | ) 532 | 533 | RegisterNetEvent('fireDispatch:removePlayer') 534 | AddEventHandler( 535 | 'fireDispatch:removePlayer', 536 | function(playerSource) 537 | source = tonumber(source) 538 | playerSource = tonumber(playerSource) 539 | if (source and source > 0) or not playerSource or playerSource < 0 then 540 | return 541 | end 542 | 543 | Dispatch:subscribe(playerSource) 544 | end 545 | ) 546 | 547 | RegisterNetEvent('fireDispatch:create') 548 | AddEventHandler( 549 | 'fireDispatch:create', 550 | function(text, coords) 551 | if not Config.Dispatch.disableCalls and (source < 1 or Dispatch.expectingInfo[source]) then 552 | Dispatch:create(text, coords) 553 | if source > 0 then 554 | Dispatch.expectingInfo[source] = nil 555 | end 556 | end 557 | end 558 | ) 559 | 560 | --================================-- 561 | -- WHITELIST -- 562 | --================================-- 563 | 564 | RegisterNetEvent('fireManager:checkWhitelist') 565 | AddEventHandler( 566 | 'fireManager:checkWhitelist', 567 | function(serverId) 568 | if serverId then 569 | source = tonumber(serverId) or source 570 | end 571 | 572 | Whitelist:check(source) 573 | end 574 | ) 575 | 576 | --================================-- 577 | -- AUTO-SUBSCRIBE -- 578 | --================================-- 579 | 580 | if Config.Dispatch.enabled then 581 | local allowedJobs = {} 582 | local firefighterJobs = {} 583 | 584 | if Config.Dispatch.enableFramework then 585 | if type(Config.Dispatch.jobs) == "table" then 586 | for k, v in pairs(Config.Dispatch.jobs) do 587 | allowedJobs[v] = true 588 | end 589 | else 590 | allowedJobs[Config.Dispatch.jobs] = true 591 | end 592 | 593 | firefighterJobs = Config.Fire.spawner.firefighterJobs or allowedJobs 594 | end 595 | 596 | if Config.Dispatch.enableFramework == 1 then 597 | ESX = exports["es_extended"]:getSharedObject() 598 | 599 | AddEventHandler( 600 | "esx:setJob", 601 | function(source) 602 | local xPlayer = ESX.GetPlayerFromId(source) 603 | 604 | if allowedJobs[xPlayer.job.name] then 605 | Dispatch:subscribe(source, firefighterJobs[xPlayer.job.name]) 606 | else 607 | Dispatch:unsubscribe(source) 608 | end 609 | end 610 | ) 611 | 612 | AddEventHandler( 613 | "esx:playerLoaded", 614 | function(source, xPlayer) 615 | if allowedJobs[xPlayer.job.name] then 616 | Dispatch:subscribe(source, firefighterJobs[xPlayer.job.name]) 617 | else 618 | Dispatch:unsubscribe(source) 619 | end 620 | end 621 | ) 622 | elseif Config.Dispatch.enableFramework == 2 then 623 | AddEventHandler( 624 | 'QBCore:Server:PlayerLoaded', 625 | function(Player) 626 | if Player.PlayerData.job.onduty and allowedJobs[Player.PlayerData.job.name] then 627 | Dispatch:subscribe(Player.PlayerData.source, firefighterJobs[Player.PlayerData.job.name]) 628 | end 629 | end 630 | ) 631 | 632 | AddEventHandler( 633 | 'QBCore:Server:OnJobUpdate', 634 | function(source, job) 635 | if allowedJobs[job.name] and job.onduty then 636 | Dispatch:subscribe(source, firefighterJobs[job.name]) 637 | else 638 | Dispatch:unsubscribe(source) 639 | end 640 | end 641 | ) 642 | 643 | AddEventHandler( 644 | 'QBCore:Server:OnPlayerUnload', 645 | function(source) 646 | Dispatch:unsubscribe(source) 647 | end 648 | ) 649 | end 650 | end -------------------------------------------------------------------------------- /server/utils.lua: -------------------------------------------------------------------------------- 1 | --================================-- 2 | -- FIRE SCRIPT v1.6.3 -- 3 | -- by GIMI (+ foregz, Albo1125) -- 4 | -- License: GNU GPL 3.0 -- 5 | --================================-- 6 | 7 | function checkVersion() 8 | PerformHttpRequest( 9 | LatestVersionFeed, 10 | function(errorCode, data, headers) 11 | if tonumber(errorCode) == 200 then 12 | data = json.decode(data) 13 | if not data then 14 | print("^3[FireScript]^7 Couldn't check version - no data returned!") 15 | return 16 | end 17 | if data.tag_name == "v" .. Version then 18 | print("^2[FireScript]^7 Up to date.") 19 | else 20 | print(("^3[FireScript]^7 The script isn't up to date! Please see version %s."):format(data.tag_name)) 21 | end 22 | else 23 | print(("^3[FireScript]^7 Couldn't check version! Error code %s."):format(errorCode)) 24 | print(LatestVersionFeed) 25 | end 26 | end, 27 | 'GET', 28 | '', 29 | { 30 | ['User-Agent'] = ("FireScript v%s"):format(Version) 31 | } 32 | ) 33 | end 34 | 35 | -- Chat 36 | 37 | function sendMessage(source, text, customName) 38 | if source > 0 then 39 | TriggerClientEvent( 40 | "chat:addMessage", 41 | source, 42 | { 43 | templateId = "firescript", 44 | args = { 45 | ((customName ~= nil) and customName or ("FireScript v%s"):format(Version)), 46 | text 47 | } 48 | } 49 | ) 50 | else 51 | print(("[FireScript v%s] %s"):format(Version, text)) 52 | end 53 | end 54 | 55 | -- Table functions 56 | 57 | function highestIndex(table, fireIndex) 58 | if not table then 59 | return 60 | end 61 | local table = fireIndex ~= nil and table[fireIndex] or table 62 | local index = 0 63 | local count = 0 64 | 65 | for k, v in ipairs(table) do 66 | count = count + 1 67 | if k >= index then 68 | index = k 69 | end 70 | end 71 | 72 | return index, count 73 | end 74 | 75 | function table.length(t) 76 | if not t or type(t) ~= "table" then 77 | return 78 | end 79 | 80 | local count = 0 81 | 82 | for k, v in pairs(t) do count = count + 1 end 83 | 84 | return count 85 | end 86 | 87 | function table.random(t) 88 | if not t or type(t) ~= "table" or next(t) == nil then 89 | return false 90 | end 91 | 92 | local randomPosition = math.random(1, table.length(t)) 93 | local currentPosition = 0 94 | local randomKey = nil 95 | 96 | for k, v in pairs(t) do -- Select a random registered fire 97 | currentPosition = currentPosition + 1 98 | 99 | if currentPosition == randomPosition then 100 | randomKey = k 101 | break 102 | end 103 | end 104 | 105 | return randomKey, t[randomKey] 106 | end 107 | 108 | -- JSON config 109 | 110 | function saveData(data, keyword) 111 | if type(keyword) ~= "string" then 112 | return 113 | end 114 | SaveResourceFile(GetCurrentResourceName(), keyword .. ".json", json.encode(data), -1) 115 | end 116 | 117 | function loadData(keyword) 118 | local fileContents = LoadResourceFile(GetCurrentResourceName(), keyword .. ".json") 119 | return fileContents and json.decode(fileContents) or nil 120 | end -------------------------------------------------------------------------------- /server/whitelist.lua: -------------------------------------------------------------------------------- 1 | --================================-- 2 | -- FIRE SCRIPT v2.0.0 -- 3 | -- by GIMI (+ foregz, Albo1125) -- 4 | -- License: GNU GPL 3.0 -- 5 | --================================-- 6 | 7 | Whitelist = { 8 | players = {}, 9 | config = {}, 10 | __index = self, 11 | init = function(object) 12 | object = object or {players = {}, config = {}} 13 | setmetatable(object, self) 14 | return object 15 | end 16 | } 17 | 18 | function Whitelist:check(serverId) 19 | if serverId > 0 then 20 | local steamID = GetPlayerIdentifier(serverId, 0) 21 | if self.config[steamID] == true or IsPlayerAceAllowed(serverId, "firescript.all") then 22 | self.players[serverId] = true 23 | elseif self.players[serverId] ~= nil then 24 | self.players[serverId] = nil 25 | end 26 | end 27 | end 28 | 29 | function Whitelist:isWhitelisted(serverId, ace) 30 | ace = tostring(ace) 31 | return (serverId < 1 or (self.players[serverId] == true or (ace and IsPlayerAceAllowed(serverId, ace)))) 32 | end 33 | 34 | function Whitelist:addPlayer(serverId, steamId) 35 | if steamId then 36 | self.config[steamId] = true 37 | Whitelist:save() 38 | end 39 | if serverId then 40 | self.players[serverId] = true 41 | end 42 | end 43 | 44 | function Whitelist:removePlayer(serverId, steamId) 45 | if steamId then 46 | self.config[steamId] = nil 47 | Whitelist:save() 48 | end 49 | if serverId then 50 | self.players[serverId] = nil 51 | end 52 | end 53 | 54 | function Whitelist:load() 55 | local whitelistFile = loadData("whitelist") 56 | if whitelistFile ~= nil then 57 | self.config = whitelistFile 58 | for _, playerId in ipairs(GetPlayers()) do 59 | self:check(tonumber(playerId)) 60 | end 61 | else 62 | saveData({}, "whitelist") 63 | end 64 | end 65 | 66 | function Whitelist:save() 67 | saveData(self.config, "whitelist") 68 | end -------------------------------------------------------------------------------- /toneaudio/firescript_alarm.awc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gimicze/firescript/cacbcce450247f06b73571f9db7c729933d552d0/toneaudio/firescript_alarm.awc -------------------------------------------------------------------------------- /toneaudio/firescript_alarm.awc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | long_beeps 8 | long_beeps.wav 9 | 10 | 11 | peak 12 | 13 | 14 | data 15 | 16 | 17 | format 18 | PCM 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | short_beeps 33 | short_beeps.wav 34 | 35 | 36 | peak 37 | 38 | 39 | data 40 | 41 | 42 | format 43 | PCM 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | --------------------------------------------------------------------------------