├── .github └── FUNDING.yml ├── .gitignore ├── LICENSE ├── README.md ├── arccw_support ├── items │ ├── arccw_ammo │ │ └── sh_9x18.lua │ ├── arccw_grenades │ │ └── sh_arccw_firearms2_nade_claymore.lua │ ├── arccw_weapons │ │ └── sh_arccw_fml_fas_ak47.lua │ └── base │ │ ├── sh_arccw_ammo.lua │ │ ├── sh_arccw_attachments.lua │ │ ├── sh_arccw_grenades.lua │ │ └── sh_arccw_weapons.lua ├── sh_plugin.lua └── sv_plugin.lua ├── can_tool.lua ├── durability ├── items │ ├── base │ │ └── sh_repair_kit.lua │ └── repair_kit │ │ └── sh_hobo_kit.lua └── sh_plugin.lua ├── durability_img.png ├── inventory_fixes └── sh_plugin.lua ├── new_vendors ├── README.MD ├── derma │ ├── cl_vendor_remake.lua │ ├── cl_vendoreditor_inventory.lua │ └── cl_vendoreditor_remake.lua ├── entities │ └── entities │ │ └── ix_vendor_new.lua └── sh_plugin.lua ├── safebox ├── entities │ └── entities │ │ └── ix_safebox.lua ├── sh_plugin.lua └── sv_plugin.lua └── unload_mags └── sh_plugin.lua /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Lua sources 2 | luac.out 3 | 4 | # luarocks build files 5 | *.src.rock 6 | *.zip 7 | *.tar.gz 8 | 9 | # Object files 10 | *.o 11 | *.os 12 | *.ko 13 | *.obj 14 | *.elf 15 | 16 | # Precompiled Headers 17 | *.gch 18 | *.pch 19 | 20 | # Libraries 21 | *.lib 22 | *.a 23 | *.la 24 | *.lo 25 | *.def 26 | *.exp 27 | 28 | # Shared objects (inc. Windows DLLs) 29 | *.dll 30 | *.so 31 | *.so.* 32 | *.dylib 33 | 34 | # Executables 35 | *.exe 36 | *.out 37 | *.app 38 | *.i*86 39 | *.x86_64 40 | *.hex 41 | 42 | -------------------------------------------------------------------------------- /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 | # helix-plugins 2 | Helix plugins; garrysmod. 3 | 4 | Durability 5 | ![Image of Yaktocat](https://github.com/Heyter/helix-plugins/blob/master/durability_img.png?raw=true) 6 | 7 | ------------ 8 | 9 | Unload_Mags (aka Ammo Eject) - Can unload magazines from weapons. (overriding base_ammo) 10 | 11 | `ITEM.AmmoID = "id_ammo_for_this_weapon"` 12 | `ITEM.AmmoID = "pistolammo"` 13 | 14 | ------------ 15 | 16 | New_Vendors 17 | 18 |

19 | 20 |

21 | 22 | 23 | 24 | ### License 25 | 26 | Copyright (C) 2999 Heyter 27 | 28 | This program is free software: you can redistribute it and/or modify 29 | it under the terms of the GNU General Public License as published by 30 | the Free Software Foundation, either version 3 of the License, or 31 | (at your option) any later version. 32 | 33 | This program is distributed in the hope that it will be useful, 34 | but WITHOUT ANY WARRANTY; without even the implied warranty of 35 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 36 | GNU General Public License for more details. 37 | 38 | You should have received a copy of the GNU General Public License 39 | along with this program. If not, see . 40 | -------------------------------------------------------------------------------- /arccw_support/items/arccw_ammo/sh_9x18.lua: -------------------------------------------------------------------------------- 1 | ITEM.name = "9x18 Ammo" 2 | ITEM.model = "models/gmodz/ammo/9x18.mdl" 3 | ITEM.ammo = "9x18mm" 4 | ITEM.ammoAmount = 24 5 | ITEM.maxRounds = 48 6 | ITEM.description = "Ammo box that contains 9x18 mm caliber" 7 | ITEM.price = 2200 -------------------------------------------------------------------------------- /arccw_support/items/arccw_grenades/sh_arccw_firearms2_nade_claymore.lua: -------------------------------------------------------------------------------- 1 | ITEM.name = "M18A1 Claymore" 2 | ITEM.description = "The M18A1 Claymore is a directional anti-personnel mine developed for the United States Armed Forces. Its inventor, Norman MacLeod, named the mine after a large medieval Scottish sword." 3 | ITEM.model = "models/weapons/fas2/world/explosives/m18a1.mdl" 4 | ITEM.weaponCategory = "slam" 5 | ITEM.class = "arccw_firearms2_nade_claymore" 6 | ITEM.width = 1 7 | ITEM.height = 1 -------------------------------------------------------------------------------- /arccw_support/items/arccw_weapons/sh_arccw_fml_fas_ak47.lua: -------------------------------------------------------------------------------- 1 | ITEM.description = "" 2 | ITEM.model = "" 3 | ITEM.name = "" 4 | 5 | ITEM.width = 2 6 | ITEM.height = 1 7 | 8 | ITEM.price = 200 -------------------------------------------------------------------------------- /arccw_support/items/base/sh_arccw_ammo.lua: -------------------------------------------------------------------------------- 1 | ITEM.name = "Ammo Base" 2 | ITEM.model = "models/Items/BoxSRounds.mdl" 3 | ITEM.width = 1 4 | ITEM.height = 1 5 | ITEM.ammo = "pistol" -- type of the ammo 6 | ITEM.ammoAmount = 30 -- amount of the ammo 7 | ITEM.description = "A Box that contains %s of Pistol Ammo" 8 | ITEM.category = "Ammunition" 9 | ITEM.useSound = "items/ammo_pickup.wav" 10 | 11 | ITEM.maxRounds = 90 -- макс. патронов помещаемых в одну коробку 12 | 13 | function ITEM:GetDescription() 14 | local rounds = self:GetData("rounds", self.ammoAmount) 15 | return Format(self.description, rounds) 16 | end 17 | 18 | if (CLIENT) then 19 | function ITEM:PaintOver(item, w, h) 20 | draw.SimpleTextOutlined(item:GetData("rounds", item.ammoAmount), "DermaDefault", 1, 5, color_white, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER, 1, color_black) 21 | end 22 | end -------------------------------------------------------------------------------- /arccw_support/items/base/sh_arccw_attachments.lua: -------------------------------------------------------------------------------- 1 | ITEM.name = "ArcCW Attachment" 2 | ITEM.description = "" 3 | ITEM.category = "ArcCW Attachments" 4 | ITEM.model = "models/Items/BoxMRounds.mdl" 5 | ITEM.width = 1 6 | ITEM.height = 1 7 | 8 | ITEM.isAttachment = true 9 | ITEM.isArcCW = true 10 | 11 | ITEM.functions.Attach = { 12 | name = "Attach", 13 | icon = "icon16/wrench.png", 14 | isMulti = true, 15 | multiOptions = function(item, client) 16 | local targets = {} 17 | local items = client:GetItems() 18 | 19 | if (items) then 20 | local name = "" 21 | local slot 22 | local mods = {} 23 | 24 | for _, v in pairs(items) do 25 | if (v.isWeapon and v.isArcCW and v.attachments) then 26 | slot = v.attachments[item.uniqueID] 27 | if (!slot) then goto SKIP end 28 | 29 | mods = v:GetData("mods", {}) 30 | 31 | if (mods[slot]) then 32 | slot = ix.arccw_support.FindAttachSlot(v, item.uniqueID) 33 | if (!slot) then goto SKIP end 34 | end 35 | 36 | if (mods[slot]) then 37 | goto SKIP 38 | end 39 | 40 | name = v:GetName() 41 | 42 | if (v:GetData("equip")) then 43 | name = "> " .. name 44 | end 45 | 46 | targets[#targets + 1] = { 47 | name = name, 48 | data = { v.id }, 49 | } 50 | 51 | ::SKIP:: 52 | end 53 | end 54 | end 55 | 56 | return targets 57 | end, 58 | OnCanRun = function(item) 59 | return (!IsValid(item.entity) and IsValid(item.player) and item.invID == item.player:GetCharacter():GetInventory():GetID()) 60 | end, 61 | OnRun = function(item, data) 62 | if (!item) then return false end 63 | if (!istable(data) or !data[1]) then return false end 64 | 65 | return ix.arccw_support.Attach(ix.item.instances[data[1]], item.uniqueID) 66 | end, 67 | } -------------------------------------------------------------------------------- /arccw_support/items/base/sh_arccw_grenades.lua: -------------------------------------------------------------------------------- 1 | ITEM.base = "base_weapons" 2 | 3 | ITEM.name = "ArcCW Grenade" 4 | ITEM.category = "ArcCW Grenades" 5 | ITEM.weaponCategory = "grenade" 6 | 7 | ITEM.isArcCW = true 8 | ITEM.isArcCWGrenade = true 9 | ITEM.isGrenade = true 10 | ITEM.isWeapon = true 11 | 12 | if (CLIENT) then 13 | function ITEM:PaintOver(itemObj, w, h) 14 | local x, y = w - 14, h - 14 15 | 16 | if (itemObj:GetData("equip")) then 17 | surface.SetDrawColor(110, 255, 110, 100) 18 | surface.DrawRect(x, y, 8, 8) 19 | 20 | x = x - 8 * 1.6 21 | end 22 | end 23 | 24 | function ITEM:PopulateTooltip(tooltip) 25 | if (self:GetData("equip")) then 26 | local name = tooltip:GetRow("name") 27 | name:SetBackgroundColor(derma.GetColor("Success", tooltip)) 28 | end 29 | end 30 | end -------------------------------------------------------------------------------- /arccw_support/items/base/sh_arccw_weapons.lua: -------------------------------------------------------------------------------- 1 | ITEM.base = "base_weapons" 2 | 3 | ITEM.name = "ArcCW Weapon" 4 | ITEM.category = "ArcCW Weapons" 5 | ITEM.weaponCategory = "primary" 6 | ITEM.attachments = {} 7 | ITEM.isArcCW = true 8 | ITEM.ammo = nil -- type of the ammo 9 | 10 | if (CLIENT) then 11 | function ITEM:PaintOver(itemObj, w, h) 12 | local x, y = w - 14, h - 14 13 | 14 | if (itemObj:GetData("equip")) then 15 | surface.SetDrawColor(110, 255, 110, 100) 16 | surface.DrawRect(x, y, 8, 8) 17 | 18 | x = x - 8 * 1.6 19 | end 20 | 21 | if (!table.IsEmpty(itemObj:GetData("mods", {}))) then 22 | surface.SetDrawColor(255, 255, 110, 100) 23 | surface.DrawRect(x, y, 8, 8) 24 | end 25 | 26 | draw.SimpleTextOutlined(itemObj:GetData("ammo", 0), "DermaDefault", 1, 5, Color(252, 177, 3), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER, 1, color_black) 27 | end 28 | 29 | function ITEM:PopulateTooltip(tooltip) 30 | if (self:GetData("equip")) then 31 | local name = tooltip:GetRow("name") 32 | name:SetBackgroundColor(derma.GetColor("Success", tooltip)) 33 | end 34 | 35 | if (self.attachments and !table.IsEmpty(self.attachments)) then 36 | local mods = self:GetData("mods", {}) 37 | 38 | if (!table.IsEmpty(mods)) then 39 | local text = {} 40 | local item 41 | 42 | for _, itemID in pairs(mods) do 43 | item = ix.item.list[itemID] 44 | 45 | text[#text + 1] = (item and item.name) or itemID 46 | end 47 | 48 | text = table.concat(text, " + ") 49 | 50 | if (isstring(text)) then 51 | local row = tooltip:AddRowAfter("description", "ArcCWMods") 52 | row:SetText(text) 53 | row:SetBackgroundColor(derma.GetColor("Warning", tooltip)) 54 | row:SizeToContents() 55 | end 56 | end 57 | end 58 | end 59 | else 60 | function ITEM:Equip(client, bNoSelect, bNoSound) 61 | local items = client:GetCharacter():GetInventory():GetItems(true) 62 | 63 | client.carryWeapons = client.carryWeapons or {} 64 | 65 | local equippedItem 66 | for _, v in pairs(items) do 67 | if (v.id != self.id and v.isWeapon and client.carryWeapons[self.weaponCategory] and v:GetData("equip")) then 68 | equippedItem = v 69 | break 70 | end 71 | end 72 | 73 | if (equippedItem) then 74 | equippedItem:Unequip(client) 75 | 76 | if (equippedItem:GetData("equip")) then 77 | client:NotifyLocalized("weaponSlotFilled", self.weaponCategory) 78 | return false 79 | end 80 | end 81 | 82 | if (client:HasWeapon(self.class)) then 83 | client:StripWeapon(self.class) 84 | end 85 | 86 | local weapon = client:Give(self.class, !self.isGrenade) 87 | 88 | if (IsValid(weapon)) then 89 | local ammoType = weapon:GetPrimaryAmmoType() 90 | 91 | client.carryWeapons[self.weaponCategory] = weapon 92 | 93 | if (!bNoSelect) then 94 | client:SelectWeapon(weapon:GetClass()) 95 | end 96 | 97 | if (!bNoSound) then 98 | client:EmitSound(self.useSound, 80) 99 | end 100 | 101 | -- Remove default given ammo. 102 | if (client:GetAmmoCount(ammoType) == weapon:Clip1() and self:GetData("ammo", 0) == 0) then 103 | client:RemoveAmmo(weapon:Clip1(), ammoType) 104 | end 105 | 106 | -- assume that a weapon with -1 clip1 and clip2 would be a throwable (i.e hl2 grenade) 107 | -- TODO: figure out if this interferes with any other weapons 108 | if (weapon:GetMaxClip1() == -1 and weapon:GetMaxClip2() == -1 and client:GetAmmoCount(ammoType) == 0) then 109 | client:SetAmmo(1, ammoType) 110 | end 111 | 112 | self:SetData("equip", true) 113 | 114 | if (self.isGrenade) then 115 | weapon:SetClip1(1) 116 | client:SetAmmo(0, ammoType) 117 | else 118 | weapon:SetClip1(self:GetData("ammo", 0)) 119 | end 120 | 121 | weapon.ixItem = self 122 | 123 | if (self.OnEquipWeapon) then 124 | self:OnEquipWeapon(client, weapon) 125 | end 126 | else 127 | print(Format("[Helix] Cannot equip weapon - %s does not exist!", self.class)) 128 | end 129 | end 130 | end 131 | 132 | ITEM.functions.Detach = { 133 | name = "Detach", 134 | icon = "icon16/wrench.png", 135 | isMulti = true, 136 | multiOptions = function(item) 137 | local targets = {} 138 | local targetItem 139 | 140 | for _, attItemID in pairs(item:GetData("mods", {})) do 141 | targetItem = ix.item.list[attItemID] 142 | 143 | targets[#targets + 1] = { 144 | name = (targetItem and targetItem.name) or attItemID, 145 | data = { attItemID } 146 | } 147 | end 148 | 149 | return targets 150 | end, 151 | 152 | OnCanRun = function(item) 153 | return ( 154 | !IsValid(item.entity) and 155 | IsValid(item.player) and 156 | item.invID == item.player:GetCharacter():GetInventory():GetID() and 157 | !table.IsEmpty(item:GetData("mods", {})) 158 | ) 159 | end, 160 | 161 | OnRun = function(item, data) 162 | if (!istable(data) or !data[1]) then return false end 163 | if (!ix.item.list[data[1]]) then return false end 164 | 165 | ix.arccw_support.Detach(item, data[1]) 166 | return false 167 | end 168 | } 169 | 170 | hook.Add("PlayerDeath", "ixStripClip", function(client) 171 | client.carryWeapons = {} 172 | local weapon 173 | 174 | for _, v in pairs(client:GetCharacter():GetInventory():GetItems()) do 175 | if (v.isWeapon and v:GetData("equip")) then 176 | weapon = client:GetWeapon(v.class) 177 | 178 | if (IsValid(weapon) and weapon:Clip1() > 0) then 179 | v:SetData("ammo", weapon:Clip1(), false) 180 | else 181 | v:SetData("ammo", nil, false) 182 | end 183 | 184 | v:SetData("equip", nil, false) 185 | 186 | if (v.pacData) then 187 | v:RemovePAC(client) 188 | end 189 | end 190 | end 191 | end) -------------------------------------------------------------------------------- /arccw_support/sh_plugin.lua: -------------------------------------------------------------------------------- 1 | PLUGIN.name = "ArcCW compatibility" 2 | PLUGIN.author = "STEAM_0:1:29606990" 3 | PLUGIN.description = "" 4 | 5 | if (!ArcCW) then return end 6 | 7 | -- ProcessNPCSmoke very expensive on MP servers 8 | PLUGIN.ProcessNPCSmoke = false 9 | 10 | local pairs, ipairs, net = pairs, ipairs, net 11 | 12 | ix.arccw_support = ix.arccw_support or {} 13 | ix.arccw_support.free_atts = ix.arccw_support.free_atts or {} 14 | ix.arccw_support.atts_slots = {} 15 | 16 | -- https://github.com/HaodongMo/ArcCW/blob/master/lua/arccw/shared/sh_attachments.lua#L95 17 | local function ArcCW_SlotAcceptsAtt(slot, wep, att) 18 | local slots = {} 19 | 20 | if isstring(slot) then 21 | slots[slot] = true 22 | elseif istable(slot) then 23 | for _, i in pairs(slot) do 24 | slots[i] = true 25 | end 26 | end 27 | 28 | local atttbl = ArcCW.AttachmentTable[att] 29 | if !atttbl then return false end 30 | 31 | if atttbl.Hidden or atttbl.Blacklisted or ArcCW.AttachmentBlacklistTable[att] then return false end 32 | if wep.RejectAttachments and wep.RejectAttachments[att] then return false end 33 | 34 | if isstring(atttbl.Slot) then 35 | if !slots[atttbl.Slot] then return false end 36 | elseif istable(atttbl.Slot) then 37 | local yeah = false 38 | 39 | for _, i in pairs(atttbl.Slot) do 40 | if slots[i] then 41 | yeah = true 42 | break 43 | end 44 | end 45 | 46 | if !yeah then 47 | return false 48 | end 49 | end 50 | 51 | -- if wep and atttbl.Hook_Compatible then 52 | -- local compat = atttbl.Hook_Compatible(wep, {slot = slot, att = att}) 53 | -- if compat == true then 54 | -- return true 55 | -- elseif compat == false then 56 | -- return false 57 | -- end 58 | -- end 59 | 60 | return true 61 | end 62 | 63 | -- https://github.com/HaodongMo/ArcCW/blob/master/lua/arccw/shared/sh_attachments.lua#L25 64 | local function ArcCW_GetAttsForSlot(slot, wep) 65 | local ret = {} 66 | 67 | for id, atttbl in pairs(ArcCW.AttachmentTable) do 68 | if (ArcCW_SlotAcceptsAtt(slot, wep, id)) then 69 | ret[#ret + 1] = id 70 | end 71 | end 72 | 73 | return ret 74 | end 75 | 76 | function ix.arccw_support.FindAttachSlot(itemWeapon, attName) 77 | local slots = ix.arccw_support.atts_slots[itemWeapon.uniqueID] 78 | 79 | if (slots and slots[attName]) then 80 | local mods = itemWeapon:GetData("mods", {}) 81 | 82 | for i in pairs(slots[attName]) do 83 | if (!mods[i]) then 84 | return i 85 | end 86 | end 87 | end 88 | end 89 | 90 | function PLUGIN:InitHooks() 91 | RunConsoleCommand("arccw_npc_atts", 0) 92 | 93 | --if (CLIENT) then 94 | --[[ RunConsoleCommand("arccw_font", "Jura") 95 | RunConsoleCommand("arccw_hud_3dfun_decaytime", 0) 96 | RunConsoleCommand("arccw_hud_3dfun", 0) 97 | RunConsoleCommand("arccw_hud_3dfun_ammotype", 1) 98 | RunConsoleCommand("arccw_hud_3dfun_lite", 0) 99 | RunConsoleCommand("arccw_hud_3dfun_right", 2) 100 | RunConsoleCommand("arccw_hud_3dfun_up", 1) 101 | RunConsoleCommand("arccw_hud_3dfun_forward", 0) 102 | RunConsoleCommand("arccw_hud_size", 1) ]] 103 | --RunConsoleCommand("arccw_automaticreload", 1) 104 | --[[ RunConsoleCommand('arccw_attinv_hideunowned', 0) 105 | RunConsoleCommand('arccw_attinv_darkunowned', 0) 106 | RunConsoleCommand('arccw_attinv_onlyinspect', 0) 107 | RunConsoleCommand('arccw_attinv_simpleproscons', 0) ]] 108 | --end 109 | 110 | if (SERVER) then 111 | RunConsoleCommand('arccw_override_crosshair_off', 1) 112 | RunConsoleCommand("arccw_mult_defaultammo", 0) 113 | RunConsoleCommand("arccw_enable_dropping", 0) 114 | RunConsoleCommand("arccw_attinv_free", 0) 115 | RunConsoleCommand("arccw_attinv_loseondie", 0) 116 | RunConsoleCommand("arccw_malfunction", 2) 117 | end 118 | 119 | hook.Remove("PlayerSpawn", "ArcCW_SpawnAttInv") 120 | hook.Remove("PlayerCanPickupWeapon", "ArcCW_PlayerCanPickupWeapon") 121 | 122 | -- HUD 123 | if (CLIENT) then 124 | local hide = { 125 | ["CHudHealth"] = true, 126 | ["CHudBattery"] = true, 127 | ["CHudAmmo"] = true, 128 | ["CHudSecondaryAmmo"] = true, 129 | } 130 | 131 | hook.Add("HUDShouldDraw", "ArcCW_HideHUD", function(name) 132 | if !hide[name] then return end 133 | if !LocalPlayer():IsValid() then return end 134 | if !LocalPlayer():GetActiveWeapon().ArcCW then return end 135 | if ArcCW.HUDElementConVars[name] and ArcCW.HUDElementConVars[name] == false then return end 136 | 137 | return false 138 | end) 139 | 140 | ArcCW.PollingDefaultHUDElements = false 141 | ArcCW.HUDElementConVars = { 142 | ["CHudAmmo"] = true, 143 | ["CHudSecondaryAmmo"] = true, 144 | } 145 | 146 | function ArcCW:ShouldDrawHUDElement(ele) 147 | if (ArcCW.HUDElementConVars[ele]) then return true end 148 | return false 149 | end 150 | end 151 | 152 | function ArcCW:PlayerGetAtts(client, att) 153 | if (att == "") then 154 | return 999 155 | end 156 | 157 | local atttbl = ArcCW.AttachmentTable[att] 158 | 159 | if (IsValid(client) and att and atttbl) then 160 | if (atttbl.Free) then 161 | return 999 162 | end 163 | 164 | --if (!client:IsAdmin() and atttbl.AdminOnly) then 165 | -- return 0 166 | --end 167 | 168 | if (atttbl.InvAtt) then 169 | att = atttbl.InvAtt 170 | end 171 | 172 | if (client:GetCharacter():GetInventory():HasItem(att)) then 173 | return 1 174 | end 175 | end 176 | 177 | return 0 178 | end 179 | 180 | function ArcCW:PlayerGiveAtt(client, att) 181 | if (!IsValid(client)) then return end 182 | 183 | client.ArcCW_AttInv = client.ArcCW_AttInv or {} 184 | 185 | local atttbl = ArcCW.AttachmentTable[att] 186 | 187 | if (!atttbl) then 188 | ErrorNoHalt("[ArcCW:PlayerGiveAtt] Invalid attachment: " .. att) 189 | return 190 | end 191 | 192 | if (atttbl.InvAtt) then 193 | att = atttbl.InvAtt 194 | end 195 | 196 | if (client:GetCharacter():GetInventory():HasItem(att)) then 197 | client.ArcCW_AttInv[att] = 1 198 | else 199 | client.ArcCW_AttInv[att] = 0 200 | end 201 | end 202 | 203 | function ArcCW:PlayerTakeAtt(client, att) 204 | if (!IsValid(client)) then return end 205 | 206 | client.ArcCW_AttInv = client.ArcCW_AttInv or {} 207 | 208 | local atttbl = ArcCW.AttachmentTable[att] 209 | 210 | if (!atttbl) then 211 | ErrorNoHalt("[ArcCW:PlayerTakeAtt] Invalid attachment: " .. att) 212 | return 213 | end 214 | 215 | if (atttbl.InvAtt) then 216 | att = atttbl.InvAtt 217 | end 218 | 219 | if (client:GetCharacter():GetInventory():HasItem(att)) then 220 | client.ArcCW_AttInv[att] = 0 221 | else 222 | client.ArcCW_AttInv[att] = 1 223 | end 224 | end 225 | 226 | function ArcCW:PlayerSendAttInv(client) 227 | if (!IsValid(client)) then return end 228 | 229 | client.ArcCW_AttInv = {} 230 | 231 | local items = client:GetItems() 232 | 233 | if (items) then 234 | for _, v in pairs(items) do 235 | if (v.isAttachment and v.isArcCW) then 236 | client.ArcCW_AttInv[v.uniqueID] = 1 237 | end 238 | end 239 | end 240 | 241 | if (SERVER) then 242 | local atttbl 243 | 244 | net.Start("arccw_sendattinv") 245 | net.WriteUInt(table.Count(client.ArcCW_AttInv), 32) 246 | 247 | for att, count in pairs(client.ArcCW_AttInv) do 248 | atttbl = ArcCW.AttachmentTable[att] 249 | 250 | net.WriteUInt(atttbl.ID, ArcCW.GetBitNecessity()) 251 | net.WriteUInt(count, 32) 252 | end 253 | net.Send(client) 254 | end 255 | end 256 | 257 | function ArcCW:PlayerCanAttach(client, wep, attname, slot, detach) 258 | -- The global variable takes priority over everything 259 | if !ArcCW.EnableCustomization then return false end 260 | 261 | -- Allow hooks to block or force allow attachment usage 262 | local ret = hook.Run("ArcCW_PlayerCanAttach", client, wep, attname, slot, detach) 263 | 264 | -- Followed by convar 265 | if ret == nil and GetConVar("arccw_enable_customization"):GetInt() < 0 then return false end 266 | 267 | return (ret == nil and true) or ret 268 | end 269 | 270 | if (!self.ProcessNPCSmoke) then 271 | ArcCW.NPCsCache = {} 272 | ArcCW.SmokeCache = {} 273 | 274 | hook.Remove("OnEntityCreated", "ArcCW_NPCSmokeCache") 275 | hook.Remove("EntityRemoved", "ArcCW_NPCSmokeCache") 276 | hook.Remove("Think", "ArcCW_NPCSmoke") 277 | ArcCW.ProcessNPCSmoke = nil 278 | end 279 | end 280 | 281 | PLUGIN:InitHooks() 282 | 283 | function PLUGIN:InitPostEntity() 284 | self:InitHooks() 285 | 286 | do 287 | local item, class 288 | local attachments = {} 289 | 290 | -- Оружие 291 | for _, SWEP in ipairs(weapons.GetList()) do 292 | class = SWEP.ClassName 293 | 294 | if (weapons.IsBasedOn(class, "arccw_base")) then 295 | if (class:find("base") or class:find("nade") or class:find("melee")) then continue end 296 | 297 | item = ix.item.list[class] or ix.item.Register(class, "base_arccw_weapons", nil, nil, true) 298 | 299 | if (item and item.isArcCW and item.isWeapon) then 300 | item.class = class 301 | item.description = SWEP.Trivia_Desc or "" 302 | item.model = SWEP.WorldModel or "models/weapons/w_pistol.mdl" 303 | item.name = SWEP.PrintName or SWEP.TrueName 304 | 305 | ix.arccw_support.atts_slots[item.uniqueID] = ix.arccw_support.atts_slots[item.uniqueID] or {} 306 | 307 | item.attachments = {} 308 | 309 | -- pretty heavy. 310 | if (SWEP.Attachments) then 311 | local slots = {} 312 | 313 | for i, k in ipairs(SWEP.Attachments) do 314 | if (!k.PrintName or k.Hidden or k.Blacklisted or k.Integral) then goto SKIP end 315 | 316 | slots = {i} 317 | table.Add(slots, k.MergeSlots or {}) 318 | 319 | for _, slot in ipairs(slots) do 320 | for _, attID in ipairs(ArcCW_GetAttsForSlot((SWEP.Attachments[slot] or {}).Slot, SWEP)) do 321 | if (!item.attachments[attID]) then 322 | item.attachments[attID] = slot 323 | else 324 | -- bruh 325 | ix.arccw_support.atts_slots[item.uniqueID][attID] = ix.arccw_support.atts_slots[item.uniqueID][attID] or {} 326 | ix.arccw_support.atts_slots[item.uniqueID][attID][slot] = ix.arccw_support.atts_slots[item.uniqueID][attID][slot] or {} 327 | ix.arccw_support.atts_slots[item.uniqueID][attID][slot] = true 328 | end 329 | end 330 | end 331 | 332 | ::SKIP:: 333 | end 334 | end 335 | 336 | if (SWEP.Primary.Ammo and #SWEP.Primary.Ammo > 0) then 337 | game.AddAmmoType({ name = SWEP.Primary.Ammo }) 338 | 339 | for _, itemAmmo in pairs(ix.item.list) do 340 | if ((itemAmmo.base == "base_ammo" or itemAmmo.base == "base_arccw_ammo") and itemAmmo.ammo == SWEP.Primary.Ammo) then 341 | item.ammo = itemAmmo.ammo 342 | item.ammoID = itemAmmo.uniqueID 343 | -- ix.item.list[item.ammo].maxRounds = SWEP.Primary.ForceDefaultClip or SWEP.Primary.ClipSize 344 | break 345 | end 346 | end 347 | end 348 | 349 | SWEP.Primary.DefaultClip = 0 350 | SWEP.InitialDefaultClip = nil 351 | SWEP.isIxItem = true 352 | 353 | if (SWEP.ItemData) then 354 | for key, value in pairs(SWEP.ItemData) do 355 | item[key] = value 356 | end 357 | end 358 | end 359 | end 360 | end 361 | 362 | -- Обвесы на оружие 363 | for attID, v in pairs(ArcCW.AttachmentTable) do 364 | if (v.Free) then 365 | ix.arccw_support.free_atts[attID] = 1 366 | else 367 | item = ix.item.list[attID] or ix.item.Register(attID, "base_arccw_attachments", nil, nil, true) 368 | item.name = v.PrintName or v.ShortName 369 | item.description = v.Description 370 | item.model = v.Model or "models/Items/BoxMRounds.mdl" 371 | 372 | -- item.slot = oldItem and item.slot or v.Slot 373 | 374 | if (v.DroppedModel and v.DroppedModel != item.model) then 375 | function item:OnGetDropModel(entity) 376 | return v.DroppedModel 377 | end 378 | end 379 | 380 | if (v.ItemData) then 381 | for key, value in pairs(v.ItemData) do 382 | item[key] = value 383 | end 384 | end 385 | end 386 | end 387 | 388 | -- Добавление патронов в игру 389 | for _, v in pairs(ix.item.list) do 390 | if (v.base == "base_arccw_ammo") then 391 | game.AddAmmoType({ name = v.ammo }) 392 | end 393 | end 394 | end 395 | 396 | hook.Run("ArccwSupportPostInit") 397 | end 398 | 399 | ix.util.Include("sv_plugin.lua") 400 | 401 | if (CLIENT) then 402 | ix.arccw_support.cache_weapons = ix.arccw_support.cache_weapons or {} 403 | 404 | local oldWeapon 405 | function PLUGIN:PlayerWeaponChanged(client, weapon) 406 | if (!IsValid(weapon) or oldWeapon == weapon or !weapon.isIxItem) then return end 407 | oldWeapon = weapon 408 | 409 | local weaponItem 410 | local items = client:GetItems() 411 | 412 | if (items) then 413 | for _, v in pairs(items) do 414 | if (v.class == weapon:GetClass() and v:GetData("equip")) then 415 | weaponItem = v 416 | 417 | break 418 | end 419 | end 420 | end 421 | 422 | if (weaponItem) then 423 | ix.arccw_support.cache_weapons[weapon] = weaponItem 424 | client.StopArcAttach = CurTime() + 1 425 | end 426 | end 427 | 428 | function PLUGIN:ArcCW_PlayerCanAttach(client, weapon, attID, slot, detach) 429 | if (ix.arccw_support.free_atts[attID] or !weapon.isIxItem) then 430 | return 431 | end 432 | 433 | if (client.StopArcAttach or 0) > CurTime() then 434 | return false 435 | end 436 | 437 | local inventory = client:GetCharacter():GetInventory() 438 | 439 | if (!inventory) then 440 | return false 441 | end 442 | 443 | if (!detach) then 444 | if (!inventory:HasItem(attID)) then 445 | return false 446 | end 447 | else 448 | local weaponItem = ix.arccw_support.cache_weapons[weapon] 449 | 450 | if (weaponItem) then 451 | local mods = weaponItem:GetData("mods", {}) 452 | 453 | if (table.IsEmpty(mods) or !mods[slot] or !inventory:FindEmptySlot(weaponItem.width, weaponItem.height, true)) then 454 | return false 455 | end 456 | end 457 | end 458 | end 459 | end 460 | -------------------------------------------------------------------------------- /arccw_support/sv_plugin.lua: -------------------------------------------------------------------------------- 1 | local timer, IsValid = timer, IsValid 2 | 3 | function ix.arccw_support.Attach(itemWeapon, attID) 4 | if (!itemWeapon or !attID or !itemWeapon.isWeapon or !itemWeapon.attachments) then 5 | return false 6 | end 7 | 8 | if (table.IsEmpty(itemWeapon.attachments)) then 9 | return false 10 | end 11 | 12 | local client = itemWeapon.player or itemWeapon:GetOwner() 13 | 14 | if (IsValid(client) and (client.StopArcAttach or 0) < CurTime()) then 15 | local slot = itemWeapon.attachments[attID] 16 | if (!slot) then return false end 17 | 18 | local mods = itemWeapon:GetData("mods", {}) 19 | 20 | if (mods[slot]) then 21 | slot = ix.arccw_support.FindAttachSlot(itemWeapon, attID) 22 | 23 | if (!slot) then return false end 24 | end 25 | 26 | if (mods[slot]) then 27 | client:NotifyLocalized("arccw_alreadyAttached") 28 | return false 29 | end 30 | 31 | local weapon = client.carryWeapons and client.carryWeapons[itemWeapon.weaponCategory] 32 | 33 | if (!IsValid(weapon)) then 34 | weapon = client:GetWeapon(itemWeapon.class) 35 | end 36 | 37 | if (IsValid(weapon) and weapon.ixItem and weapon.ixItem == itemWeapon) then 38 | weapon:Attach(slot, attID) 39 | client:EmitSound("weapons/crossbow/reload1.wav") 40 | 41 | return false 42 | else 43 | mods[slot] = attID 44 | itemWeapon:SetData("mods", mods, true) 45 | mods = nil 46 | 47 | client:EmitSound("weapons/crossbow/reload1.wav") 48 | end 49 | 50 | return true 51 | end 52 | 53 | return false 54 | end 55 | 56 | function ix.arccw_support.Detach(itemWeapon, attID) 57 | if (!itemWeapon or itemWeapon.invID == 0 or !attID or !itemWeapon.isWeapon or !itemWeapon.attachments) then 58 | return false 59 | end 60 | 61 | if (table.IsEmpty(itemWeapon.attachments)) then 62 | return false 63 | end 64 | 65 | local inventory = ix.item.inventories[itemWeapon.invID] 66 | if (!inventory) then return end 67 | 68 | local client = itemWeapon.player or itemWeapon:GetOwner() 69 | 70 | if (IsValid(client) and (client.StopArcAttach or 0) < CurTime()) then 71 | local slot = itemWeapon.attachments[attID] 72 | local mods = itemWeapon:GetData("mods", {}) 73 | 74 | if (!slot or table.IsEmpty(mods)) then 75 | return false 76 | end 77 | 78 | if (!mods[slot]) then 79 | for slot2, attID2 in pairs(mods) do 80 | if (slot2 == slot) then goto SKIP end 81 | 82 | if (attID == attID2) then 83 | slot = slot2 84 | break 85 | end 86 | 87 | ::SKIP:: 88 | end 89 | end 90 | 91 | if (!mods[slot]) then 92 | return false 93 | end 94 | 95 | local weapon = client.carryWeapons and client.carryWeapons[itemWeapon.weaponCategory] 96 | 97 | if (!IsValid(weapon)) then 98 | weapon = client:GetWeapon(itemWeapon.class) 99 | end 100 | 101 | if (IsValid(weapon) and weapon.ixItem and weapon.ixItem == itemWeapon) then 102 | local attItem = ix.item.list[attID] 103 | 104 | if (!attItem or !inventory:FindEmptySlot(attItem.width, attItem.height, true)) then 105 | client:NotifyLocalized("noFit") 106 | return false 107 | end 108 | 109 | weapon:Detach(slot) 110 | client:EmitSound("weapons/crossbow/reload1.wav") 111 | 112 | return true 113 | else 114 | if (!inventory:Add(attID)) then 115 | client:NotifyLocalized("noFit") 116 | return false 117 | end 118 | 119 | mods[slot] = nil 120 | 121 | if (table.IsEmpty(mods)) then 122 | itemWeapon:SetData("mods", nil, true) 123 | else 124 | itemWeapon:SetData("mods", mods, true) 125 | end 126 | 127 | mods = nil 128 | 129 | client:EmitSound("weapons/crossbow/reload1.wav") 130 | end 131 | 132 | return true 133 | end 134 | 135 | return false 136 | end 137 | 138 | function ix.arccw_support.InitWeapon(client, weapon) 139 | if (IsValid(weapon) and IsValid(client)) then 140 | for _, i in pairs(weapon.Attachments) do 141 | if (!i.Integral) then 142 | i.Installed = nil 143 | end 144 | end 145 | 146 | local weaponItem = weapon.ixItem 147 | local items = client:GetItems() 148 | 149 | if (items and !weaponItem) then 150 | for _, v in pairs(items) do 151 | if (v.class == weapon:GetClass() and v:GetData("equip")) then 152 | weaponItem = v 153 | 154 | break 155 | end 156 | end 157 | end 158 | 159 | if (weaponItem) then 160 | local mods = weaponItem:GetData("mods", {}) 161 | 162 | if (!table.IsEmpty(mods)) then 163 | for slot, attID in pairs(mods) do 164 | weapon.Attachments[slot].Installed = attID 165 | end 166 | end 167 | end 168 | 169 | client.StopArcAttach = CurTime() + 1 170 | weapon:NetworkWeapon(client) 171 | end 172 | end 173 | 174 | -- HOOKS -- 175 | function PLUGIN:ArcCW_PlayerCanAttach(client, weapon, attID, slot, detach) 176 | if (ix.arccw_support.free_atts[attID] or !weapon.isIxItem or (client.StopArcAttach or 0) > CurTime()) then 177 | return 178 | end 179 | 180 | local weaponItem = weapon.ixItem 181 | 182 | if (weaponItem) then 183 | if (!detach) then 184 | local attItem = client:GetCharacter():GetInventory():HasItem(attID) 185 | 186 | if (!attItem) then 187 | return false 188 | end 189 | 190 | local mods = weaponItem:GetData("mods", {}) 191 | 192 | mods[slot] = attID 193 | weaponItem:SetData("mods", mods) 194 | mods = nil 195 | 196 | timer.Simple(.0, function() 197 | attItem:Remove() 198 | end) 199 | else 200 | local mods = weaponItem:GetData("mods", {}) 201 | 202 | if (table.IsEmpty(mods)) then 203 | return false 204 | end 205 | 206 | if (mods[slot]) then 207 | if (!client:GetCharacter():GetInventory():Add(attID)) then 208 | client:NotifyLocalized("noFit") 209 | return false 210 | end 211 | 212 | mods[slot] = nil 213 | 214 | if (table.IsEmpty(mods)) then 215 | weaponItem:SetData("mods", nil) 216 | else 217 | weaponItem:SetData("mods", mods) 218 | end 219 | 220 | mods = nil 221 | end 222 | end 223 | end 224 | end 225 | 226 | function PLUGIN:PlayerCanPickupWeapon(client, weapon) 227 | if (weapon.ArcCW and !weapon.Singleton and weapon.isIxItem) then 228 | -- if (!ArcCW.EnableCustomization or GetConVar("arccw_enable_customization"):GetInt() < 0 or GetConVar("arccw_attinv_free"):GetBool()) then 229 | -- return 230 | -- end 231 | 232 | weapon:SetNWBool("ArcCW_DisableAutosave", true) 233 | 234 | timer.Simple(.2, function() 235 | ix.arccw_support.InitWeapon(client, weapon) 236 | end) 237 | end 238 | end -------------------------------------------------------------------------------- /can_tool.lua: -------------------------------------------------------------------------------- 1 | PLUGIN.name = "CanTool" 2 | PLUGIN.author = "STEAM_0:1:29606990" 3 | PLUGIN.description = "Overwrite CanTool method" 4 | 5 | local NO_DUPLICATE_ENTS = {} 6 | NO_DUPLICATE_ENTS['ix_money'] = true 7 | NO_DUPLICATE_ENTS['ix_item'] = true 8 | NO_DUPLICATE_ENTS['ix_shipment'] = true 9 | 10 | do 11 | local TOOL_DANGEROUS = {} 12 | TOOL_DANGEROUS["dynamite"] = true 13 | TOOL_DANGEROUS["duplicator"] = true 14 | 15 | function GAMEMODE:CanTool(client, trace, tool_name) 16 | if (tool_name == "duplicator" and IsValid(trace.Entity) and (trace.Entity.NoDuplicate or NO_DUPLICATE_ENTS[trace.Entity:GetClass()])) then 17 | return false 18 | end 19 | 20 | if (client:IsAdmin()) then 21 | return true 22 | end 23 | 24 | if (TOOL_DANGEROUS[tool_name]) then 25 | return false 26 | end 27 | 28 | return self.BaseClass:CanTool(client, trace, tool_name) 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /durability/items/base/sh_repair_kit.lua: -------------------------------------------------------------------------------- 1 | ITEM.name = "Repair Kit Base" 2 | ITEM.category = "RepairKit" 3 | ITEM.description = "The repair kit repairs %s%% of the durability." 4 | ITEM.model = "models/props_lab/box01a.mdl" 5 | ITEM.useSound = "interface/inv_repair_kit.ogg" 6 | ITEM.width = 1 7 | ITEM.height = 1 8 | 9 | -- Percentage of the difference between maximum and current durability. See in ITEM:UseRepair 10 | ITEM.durability = 25 11 | 12 | -- How many times can an item be used before it is removed? 13 | ITEM.quantity = 1 14 | 15 | -- Only allowed for weapons. 16 | ITEM.isWeaponKit = true 17 | 18 | if (SERVER) then 19 | -- You can override this method in your item. 20 | -- item: The current used item. 21 | function ITEM:UseRepair(item, client) 22 | local maxDurability = item.maxDurability or ix.config.Get("maxValueDurability", 100) 23 | local durability = item:GetData("durability", maxDurability) 24 | local amount = math.max(0, (self.durability / 100) * (maxDurability - durability)) 25 | 26 | item:SetData("durability", math.Clamp(math.floor(durability + amount), 0, maxDurability)) 27 | end 28 | end 29 | 30 | if (CLIENT) then 31 | function ITEM:PaintOver(item, w, h) 32 | local quantity = item:GetData("quantity", item.quantity or 1) 33 | 34 | if (quantity > 0) then 35 | draw.SimpleText(quantity, "DermaDefault", w - 5, h - 5, color_white, TEXT_ALIGN_RIGHT, TEXT_ALIGN_BOTTOM, 1, color_black) 36 | end 37 | end 38 | 39 | function ITEM:GetDescription() 40 | return Format(self.description, self.durability) 41 | end 42 | end 43 | 44 | function ITEM:OnInstanced(invID, x, y, item) 45 | item:SetData("quantity", item.quantity or 1) 46 | end 47 | -------------------------------------------------------------------------------- /durability/items/repair_kit/sh_hobo_kit.lua: -------------------------------------------------------------------------------- 1 | ITEM.name = "Hobo kit" 2 | ITEM.durability = 15 3 | ITEM.quantity = 3 -------------------------------------------------------------------------------- /durability/sh_plugin.lua: -------------------------------------------------------------------------------- 1 | PLUGIN.name = "Durability" 2 | PLUGIN.author = "STEAM_0:1:29606990" -- AleXXX_007 - original idea. 3 | PLUGIN.description = "Adds durability for all weapons." 4 | 5 | -- HL2 Weapons bullet damage is not counted. 6 | -- bullet.Damage = (bullet.Damage / 100) * durability 7 | -- bullet.Damage always 0 8 | 9 | ix.config.Add("maxValueDurability", 100, "Maximum value of the durability.", nil, { 10 | data = {min = 1, max = 9999}, 11 | category = PLUGIN.name 12 | }) 13 | 14 | ix.config.Add("decDurability", 0.5, "By how many units do reduce the durability with each shot?", nil, { 15 | data = {min = 0.0001, max = 100, decimals = 4}, 16 | category = PLUGIN.name 17 | }) 18 | 19 | ix.config.Add("unequipItemDurability", false, "Unequip the item if durability is less than zero?", nil, { 20 | category = PLUGIN.name 21 | }) 22 | 23 | ix.lang.AddTable("russian", { 24 | ['Repair'] = "Починить", 25 | ['RepairKitWrong'] = 'У вас нет ремкомплекта!', 26 | ['DurabilityUnusableTip'] = 'Оружие теперь полностью сломано!', 27 | ['DurabilityText'] = 'Прочность', 28 | }) 29 | 30 | ix.lang.AddTable("english", { 31 | ['RepairKitWrong'] = 'You do not have a repair kit!', 32 | ['DurabilityUnusableTip'] = 'Your weapon is now completely broken!', 33 | ['DurabilityText'] = 'Durability', 34 | }) 35 | 36 | if (SERVER) then 37 | function PLUGIN:Tick() 38 | local curTime = CurTime() 39 | 40 | for _, v in ipairs(player.GetAll()) do 41 | if (curTime >= (v.ixNextTickDurability or 0) and v:Alive() and v:GetCharacter()) then 42 | local weapon = v:GetActiveWeapon() 43 | 44 | if (IsValid(weapon) and weapon.ixItem and weapon.ixItem.isWeapon) then 45 | local canShoot = weapon.ixItem:GetData("durability", weapon.ixItem.maxDurability or ix.config.Get("maxValueDurability", 100)) > 0 46 | 47 | if (!v:IsWepRaised()) then 48 | canShoot = false 49 | end 50 | 51 | if (canShoot ~= v:CanShootWeapon()) then 52 | v:SetNetVar("canShoot", canShoot) 53 | end 54 | end 55 | 56 | v.ixNextTickDurability = curTime + 0.1 57 | end 58 | end 59 | end 60 | 61 | function PLUGIN:EntityFireBullets(entity, bullet) 62 | if (IsValid(entity) and entity:IsPlayer()) then 63 | local weapon = entity:GetActiveWeapon() 64 | 65 | if (IsValid(weapon) and weapon.ixItem) then 66 | local item = weapon.ixItem 67 | 68 | if (item.isWeapon) then 69 | local durability = item:GetData("durability", item.maxDurability or ix.config.Get("maxValueDurability", 100)) 70 | local oldDurability = durability 71 | local originalDamage = bullet.Damage 72 | 73 | bullet.Damage = (originalDamage / 100) * durability 74 | bullet.Spread = bullet.Spread * (1 + (1 - (0.01 * durability))) 75 | 76 | if (originalDamage < 1) then 77 | durability = math.max(durability - ix.config.Get("decDurability", 1), 0) 78 | else 79 | durability = math.max(durability - (originalDamage / 100), 0) -- 100 = drainScale 80 | end 81 | 82 | if (oldDurability ~= durability) then 83 | item:SetData("durability", durability) 84 | end 85 | 86 | if (oldDurability > 0 and durability == 0) then 87 | entity:SetNetVar("canShoot", false) 88 | entity:NotifyLocalized('DurabilityUnusableTip') 89 | end 90 | 91 | if (ix.config.Get("unequipItemDurability", false) and durability < 1 and item.Unequip) then 92 | item:Unequip(entity) 93 | end 94 | end 95 | end 96 | end 97 | end 98 | else 99 | function PLUGIN:PopulateItemTooltip(tooltip, item) 100 | if (!item.isWeapon) then 101 | return 102 | end 103 | 104 | local panel = tooltip:AddRowAfter("description", "durability") 105 | local maxDurability = item.maxDurability or ix.config.Get("maxValueDurability", 100) 106 | local durability = math.Clamp(math.floor(item:GetData("durability", maxDurability)), 0, maxDurability) 107 | durability = math.max(0, math.floor((durability / maxDurability) * 100)) 108 | 109 | panel:SetText(Format("%s: %s%% / 100%%", L("DurabilityText"), durability)) 110 | panel:SetBackgroundColor(Color(219, 52, 52)) 111 | panel:SizeToContents() 112 | end 113 | end 114 | 115 | function PLUGIN:InitializedPlugins() 116 | local maxDurability = ix.config.Get("maxValueDurability", 100) 117 | 118 | for _, v in pairs(ix.item.list) do 119 | if (!v.isWeapon) then continue end 120 | 121 | maxDurability = v.maxDurability or maxDurability 122 | 123 | if CLIENT then 124 | function v:PaintOver(item, w, h) 125 | if (item:GetData("equip")) then 126 | surface.SetDrawColor(110, 255, 110, 100) 127 | surface.DrawRect(w - 14, h - 14, 8, 8) 128 | end 129 | 130 | local durability = item:GetData("durability", maxDurability) 131 | local durabilityPercent = math.Clamp(durability / maxDurability, 0, maxDurability) 132 | 133 | if (durabilityPercent > 0) then 134 | -- 2.55 = (255 / 100) 135 | local durabilityColor = Color(2.55 * (100 - durability), 2.55 * durability, 0, 255) 136 | 137 | surface.SetDrawColor(durabilityColor) 138 | surface.DrawRect(0, h - 2, w * durabilityPercent, 2) 139 | end 140 | end 141 | end 142 | 143 | v.functions.Repair = { 144 | name = "Repair", 145 | tip = "equipTip", 146 | icon = "icon16/bullet_wrench.png", 147 | OnRun = function(item) 148 | local client = item.player 149 | local itemKit = client:GetCharacter():GetInventory():HasItemOfBase("base_repair_kit") 150 | 151 | if (itemKit and itemKit.isWeaponKit) then 152 | local quantity = itemKit:GetData("quantity", itemKit.quantity or 1) - 1 153 | 154 | if (quantity < 1) then 155 | itemKit:Remove() 156 | else 157 | itemKit:SetData("quantity", quantity) 158 | end 159 | 160 | if (itemKit.UseRepair) then 161 | itemKit:UseRepair(item, client) 162 | end 163 | 164 | if (itemKit.useSound) then 165 | client:EmitSound(itemKit.useSound, 110) 166 | end 167 | 168 | itemKit = nil 169 | else 170 | client:NotifyLocalized('RepairKitWrong') 171 | end 172 | 173 | return false 174 | end, 175 | 176 | OnCanRun = function(item) 177 | if (item:GetData("durability", maxDurability) >= maxDurability) then 178 | return false 179 | end 180 | 181 | if (!item.player:GetCharacter():GetInventory():HasItemOfBase("base_repair_kit")) then 182 | return false 183 | end 184 | 185 | return true 186 | end 187 | } 188 | end 189 | end 190 | 191 | function PLUGIN:CanPlayerEquipItem(_, itemObj) 192 | if (ix.config.Get("unequipItemDurability", false)) then 193 | return itemObj:GetData("durability", ix.config.Get("maxValueDurability", 100)) > 0 194 | end 195 | end -------------------------------------------------------------------------------- /durability_img.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Heyter/helix-plugins/68e443cad8986d42e37902cf64c0412b9177f428/durability_img.png -------------------------------------------------------------------------------- /inventory_fixes/sh_plugin.lua: -------------------------------------------------------------------------------- 1 | PLUGIN.name = "Inventory fixes" 2 | PLUGIN.description = "Bug fix with complete removal of inventory." 3 | local ITEM = ix.meta.item or {} 4 | 5 | --- Removes the item. 6 | -- @realm shared 7 | -- @bool bNoReplication Whether or not the item's removal should not be replicated. 8 | -- @bool bNoDelete Whether or not the item should not be fully deleted 9 | -- @treturn number The X position that the item was removed from 10 | -- @treturn number The Y position that the item was removed from 11 | function ITEM:Remove(bNoReplication, bNoDelete) 12 | local inv = ix.inventory.Get(self.invID) 13 | local x2, y2 14 | 15 | if (inv) then 16 | if (self.invID ~= 0) then 17 | local failed = false 18 | 19 | for x = self.gridX, self.gridX + (self.width - 1) do 20 | if (inv.slots[x]) then 21 | for y = self.gridY, self.gridY + (self.height - 1) do 22 | local item = inv.slots[x][y] 23 | 24 | if (item and item.id == self.id) then 25 | inv.slots[x][y] = nil 26 | 27 | x2 = x2 or x 28 | y2 = y2 or y 29 | else 30 | failed = true 31 | end 32 | end 33 | end 34 | end 35 | 36 | if (failed) then 37 | local invW, invH = inv:GetSize() 38 | x2, y2 = nil, nil 39 | 40 | for x = 1, invW do 41 | if (inv.slots[x]) then 42 | for y = 1, invH do 43 | local item = inv.slots[x][y] 44 | 45 | if (item and item.id == self.id) then 46 | inv.slots[x][y] = nil 47 | 48 | x2 = x2 or x 49 | y2 = y2 or y 50 | end 51 | end 52 | end 53 | end 54 | end 55 | else 56 | ix.item.inventories[self.invID][self.id] = nil 57 | end 58 | end 59 | 60 | if (SERVER and !bNoReplication) then 61 | local entity = self:GetEntity() 62 | 63 | if (IsValid(entity)) then 64 | entity:Remove() 65 | end 66 | 67 | if (inv and inv.GetReceivers) then 68 | local receivers = inv:GetReceivers() 69 | 70 | if (self.invID ~= 0 and istable(receivers) and #receivers > 0) then 71 | net.Start("ixInventoryRemove") 72 | net.WriteUInt(self.id, 32) 73 | net.WriteUInt(self.invID, 32) 74 | net.Send(receivers) 75 | end 76 | end 77 | 78 | if (!bNoDelete) then 79 | local item = ix.item.instances[self.id] 80 | 81 | if (item and item.OnRemoved) then 82 | item:OnRemoved() 83 | end 84 | 85 | local query = mysql:Delete("ix_items") 86 | query:Where("item_id", self.id) 87 | query:Execute() 88 | 89 | ix.item.instances[self.id] = nil 90 | end 91 | end 92 | 93 | return x2, y2 94 | end 95 | 96 | ix.meta.item = ITEM 97 | -------------------------------------------------------------------------------- /new_vendors/README.MD: -------------------------------------------------------------------------------- 1 | ![alt text](https://i.imgur.com/fXeN6BC.png)\ 2 | https://imgur.com/a/2t7QBsU 3 | -------------------------------------------------------------------------------- /new_vendors/derma/cl_vendor_remake.lua: -------------------------------------------------------------------------------- 1 | local PANEL = {} 2 | 3 | AccessorFunc(PANEL, "money", "Money", FORCE_NUMBER) 4 | 5 | function PANEL:Init() 6 | self:DockPadding(1, 1, 1, 1) 7 | self:SetTall(22) 8 | self:Dock(BOTTOM) 9 | 10 | self.moneyLabel = self:Add("DLabel") 11 | self.moneyLabel:Dock(TOP) 12 | self.moneyLabel:SetFont("ixGenericFont") 13 | self.moneyLabel:SetText("") 14 | self.moneyLabel:SetTextInset(2, 0) 15 | self.moneyLabel:SizeToContents() 16 | self.moneyLabel.Paint = function(panel, width, height) 17 | derma.SkinFunc("DrawImportantBackground", 0, 0, width, height, ix.config.Get("color")) 18 | end 19 | 20 | self.bNoBackgroundBlur = true 21 | end 22 | 23 | function PANEL:SetMoney(money) 24 | money = math.max(math.Round(tonumber(money) or 0), 0) 25 | self.moneyLabel:SetText(ix.currency.Get(money)) 26 | end 27 | 28 | function PANEL:Paint(width, height) 29 | derma.SkinFunc("PaintBaseFrame", self, width, height) 30 | end 31 | 32 | vgui.Register("ixVendorRemakeMoney", PANEL, "EditablePanel") 33 | 34 | DEFINE_BASECLASS("Panel") 35 | PANEL = {} 36 | 37 | AccessorFunc(PANEL, "fadeTime", "FadeTime", FORCE_NUMBER) 38 | AccessorFunc(PANEL, "frameMargin", "FrameMargin", FORCE_NUMBER) 39 | 40 | function PANEL:Init() 41 | self:SetSize(ScrW(), ScrH()) 42 | self:SetPos(0, 0) 43 | self:SetFadeTime(0.25) 44 | self:SetFrameMargin(4) 45 | 46 | self.vendorInventory = self:Add("ixInventory") 47 | self.vendorInventory.bNoBackgroundBlur = true 48 | self.vendorInventory:ShowCloseButton(true) 49 | self.vendorInventory:SetTitle("John Doe") 50 | self.vendorInventory.Close = function(this) 51 | net.Start("ixVendorRemakeClose") 52 | net.SendToServer() 53 | self:Remove() 54 | end 55 | 56 | self.vendorMoney = self.vendorInventory:Add("ixVendorRemakeMoney") 57 | self.vendorMoney:SetVisible(false) 58 | 59 | -- Player inventory 60 | ix.gui.inv1 = self:Add("ixInventory") 61 | ix.gui.inv1.bNoBackgroundBlur = true 62 | ix.gui.inv1:ShowCloseButton(true) 63 | ix.gui.inv1.Close = function(this) 64 | net.Start("ixVendorRemakeClose") 65 | net.SendToServer() 66 | self:Remove() 67 | end 68 | 69 | self.localMoney = ix.gui.inv1:Add("ixVendorRemakeMoney") 70 | self.localMoney:SetVisible(false) 71 | 72 | self:SetAlpha(0) 73 | self:AlphaTo(255, self:GetFadeTime()) 74 | 75 | self.vendorInventory:MakePopup() 76 | ix.gui.inv1:MakePopup() 77 | end 78 | 79 | function PANEL:OnChildAdded(panel) 80 | panel:SetPaintedManually(true) 81 | end 82 | 83 | function PANEL:SetLocalInventory(inventory) 84 | if (IsValid(ix.gui.inv1) and !IsValid(ix.gui.menu)) then 85 | ix.gui.inv1:SetInventory(inventory) 86 | ix.gui.inv1:SetPos(self:GetWide() / 2 + self:GetFrameMargin() / 2, self:GetTall() / 2 - ix.gui.inv1:GetTall() / 2) 87 | end 88 | end 89 | 90 | function PANEL:SetLocalMoney(money) 91 | if (!self.localMoney:IsVisible()) then 92 | self.localMoney:SetVisible(true) 93 | ix.gui.inv1:SetTall(ix.gui.inv1:GetTall() + self.localMoney:GetTall() + 2) 94 | end 95 | 96 | self.localMoney:SetMoney(money) 97 | end 98 | 99 | function PANEL:SetVendorTitle(title) 100 | self.vendorInventory:SetTitle(title) 101 | end 102 | 103 | function PANEL:SetVendorInventory(inventory) 104 | self.vendorInventory:SetInventory(inventory) 105 | self.vendorInventory:SetPos( 106 | self:GetWide() / 2 - self.vendorInventory:GetWide() - 2, 107 | self:GetTall() / 2 - self.vendorInventory:GetTall() / 2 108 | ) 109 | 110 | ix.gui["inv" .. inventory:GetID()] = self.vendorInventory 111 | end 112 | 113 | function PANEL:SetVendorMoney(money) 114 | if (!self.vendorMoney:IsVisible()) then 115 | self.vendorMoney:SetVisible(true) 116 | self.vendorInventory:SetTall(self.vendorInventory:GetTall() + self.vendorMoney:GetTall() + 2) 117 | end 118 | 119 | self.vendorMoney:SetMoney(money) 120 | end 121 | 122 | function PANEL:Paint(width, height) 123 | ix.util.DrawBlurAt(0, 0, width, height) 124 | 125 | for _, v in ipairs(self:GetChildren()) do 126 | v:PaintManual() 127 | end 128 | end 129 | 130 | function PANEL:Remove() 131 | self:SetAlpha(255) 132 | self:AlphaTo(0, self:GetFadeTime(), 0, function() 133 | BaseClass.Remove(self) 134 | end) 135 | end 136 | 137 | function PANEL:OnRemove() 138 | if (!IsValid(ix.gui.menu)) then 139 | -- net.Start("ixVendorRemakeClose") 140 | -- net.SendToServer() 141 | 142 | self.vendorInventory:Remove() 143 | ix.gui.inv1:Remove() 144 | 145 | if (IsValid(ix.gui.vendorRemakeEditor)) then 146 | ix.gui.vendorRemakeEditor:Remove() 147 | end 148 | end 149 | end 150 | 151 | function PANEL:Think() 152 | local entity = self.entity 153 | 154 | if (!IsValid(entity)) then 155 | self:Remove() 156 | return 157 | end 158 | 159 | if ((self.nextUpdate or 0) < CurTime()) then 160 | self:SetVendorTitle(entity:GetDisplayName()) 161 | self.localMoney:SetMoney(LocalPlayer():GetCharacter():GetMoney()) 162 | self.vendorMoney:SetMoney(entity.money) 163 | 164 | self.nextUpdate = CurTime() + 0.25 165 | end 166 | end 167 | 168 | vgui.Register("ixVendorRemakeView", PANEL, "DFrame") 169 | -------------------------------------------------------------------------------- /new_vendors/derma/cl_vendoreditor_inventory.lua: -------------------------------------------------------------------------------- 1 | local PANEL = {} 2 | 3 | function PANEL:Init() 4 | self:SetSize(256, 132) 5 | self:Center() 6 | self:MakePopup() 7 | self:SetTitle(L"vendorTitleInvSize") 8 | end 9 | 10 | function PANEL:Setup() 11 | self.inventories = self.entity:GetInventory() 12 | 13 | self.invW = self:Add("DNumSlider") 14 | self.invW:Dock(TOP) 15 | self.invW:DockMargin(0, 4, 0, 0) 16 | self.invW:SetText(L"vendorSlideWInvSize") 17 | self.invW.Label:SetTextColor(color_white) 18 | self.invW.TextArea:SetTextColor(color_white) 19 | self.invW:SetDecimals(0) 20 | self.invW:SetValue(self.inventories.w) 21 | self.invW:SetMinMax(1, 32) 22 | 23 | self.invH = self:Add("DNumSlider") 24 | self.invH:Dock(TOP) 25 | self.invH:DockMargin(0, 4, 0, 0) 26 | self.invH:SetText(L"vendorSlideHInvSize") 27 | self.invH.Label:SetTextColor(color_white) 28 | self.invH.TextArea:SetTextColor(color_white) 29 | self.invH:SetDecimals(0) 30 | self.invH:SetValue(self.inventories.h) 31 | self.invH:SetMinMax(1, 32) 32 | 33 | self.send = self:Add("DButton") 34 | self.send:SetText(L"vendorResizeBtnInvSize") 35 | self.send:Dock(TOP) 36 | self.send:SetTextColor(color_white) 37 | self.send:DockMargin(0, 4, 0, 0) 38 | self.send.DoClick = function(this) 39 | self:Remove() 40 | 41 | self:updateVendor("inventory_size", {self.invW:GetValue(), self.invH:GetValue()}) 42 | end 43 | end 44 | 45 | vgui.Register("ixVendorInventoryEditor", PANEL, "DFrame") 46 | -------------------------------------------------------------------------------- /new_vendors/derma/cl_vendoreditor_remake.lua: -------------------------------------------------------------------------------- 1 | local PANEL = {} 2 | 3 | function PANEL:Init() 4 | local entity = ix.gui.vendorRemake.entity 5 | 6 | self:SetSize(320, 480) 7 | 8 | self:SetPos(0, 0) 9 | self:MakePopup() 10 | self:CenterVertical() 11 | self:SetTitle(L"vendorEditor") 12 | 13 | self.name = self:Add("DTextEntry") 14 | self.name:Dock(TOP) 15 | self.name:SetText(entity:GetDisplayName()) 16 | self.name.OnEnter = function(this) 17 | if (entity:GetDisplayName() != this:GetText()) then 18 | self:updateVendor("name", this:GetText()) 19 | end 20 | end 21 | 22 | self.description = self:Add("DTextEntry") 23 | self.description:Dock(TOP) 24 | self.description:DockMargin(0, 4, 0, 0) 25 | self.description:SetText(entity:GetDescription()) 26 | self.description.OnEnter = function(this) 27 | if (entity:GetDescription() != this:GetText()) then 28 | self:updateVendor("description", this:GetText()) 29 | end 30 | end 31 | 32 | self.model = self:Add("DTextEntry") 33 | self.model:Dock(TOP) 34 | self.model:DockMargin(0, 4, 0, 0) 35 | self.model:SetText(entity:GetModel()) 36 | self.model.OnEnter = function(this) 37 | if (entity:GetModel():lower() != this:GetText():lower()) then 38 | self:updateVendor("model", this:GetText():lower()) 39 | end 40 | end 41 | 42 | local useMoney = tonumber(entity.money) != nil 43 | 44 | self.money = self:Add("DTextEntry") 45 | self.money:Dock(TOP) 46 | self.money:DockMargin(0, 4, 0, 0) 47 | self.money:SetText(!useMoney and "∞" or entity.money) 48 | self.money:SetDisabled(!useMoney) 49 | self.money:SetEnabled(useMoney) 50 | self.money:SetNumeric(true) 51 | self.money.OnEnter = function(this) 52 | local value = tonumber(this:GetText()) or entity.money 53 | 54 | if (value == entity.money) then 55 | return 56 | end 57 | 58 | self:updateVendor("money", value) 59 | end 60 | 61 | self.bubble = self:Add("DCheckBoxLabel") 62 | self.bubble:SetText(L"vendorNoBubble") 63 | self.bubble:Dock(TOP) 64 | self.bubble:DockMargin(0, 4, 0, 0) 65 | self.bubble:SetValue(entity:GetNoBubble() and 1 or 0) 66 | self.bubble.OnChange = function(this, value) 67 | if (this.noSend) then 68 | this.noSend = nil 69 | else 70 | self:updateVendor("bubble", value) 71 | end 72 | end 73 | 74 | self.useMoney = self:Add("DCheckBoxLabel") 75 | self.useMoney:SetText(L"vendorUseMoney") 76 | self.useMoney:Dock(TOP) 77 | self.useMoney:DockMargin(0, 4, 0, 0) 78 | self.useMoney:SetChecked(useMoney) 79 | self.useMoney.OnChange = function(this, value) 80 | self:updateVendor("useMoney") 81 | end 82 | 83 | self.sellScale = self:Add("DNumSlider") 84 | self.sellScale:Dock(TOP) 85 | self.sellScale:DockMargin(0, 4, 0, 0) 86 | self.sellScale:SetText(L"vendorSellScale") 87 | self.sellScale.Label:SetTextColor(color_white) 88 | self.sellScale.TextArea:SetTextColor(color_white) 89 | self.sellScale:SetDecimals(1) 90 | self.sellScale.noSend = true 91 | self.sellScale:SetValue(entity.scale) 92 | self.sellScale.OnValueChanged = function(this, value) 93 | if (this.noSend) then 94 | this.noSend = nil 95 | else 96 | timer.Create("ixVendorScale", 1, 1, function() 97 | if (IsValid(self) and IsValid(self.sellScale)) then 98 | value = self.sellScale:GetValue() 99 | 100 | if (value != entity.scale) then 101 | self:updateVendor("scale", value) 102 | end 103 | end 104 | end) 105 | end 106 | end 107 | 108 | self.faction = self:Add("DButton") 109 | self.faction:SetText(L"vendorFaction") 110 | self.faction:Dock(TOP) 111 | self.faction:SetTextColor(color_white) 112 | self.faction:DockMargin(0, 4, 0, 0) 113 | self.faction.DoClick = function(this) 114 | if (IsValid(ix.gui.editorFaction)) then 115 | ix.gui.editorFaction:Remove() 116 | end 117 | 118 | ix.gui.editorFaction = vgui.Create("ixVendorFactionEditor") 119 | ix.gui.editorFaction.updateVendor = self.updateVendor 120 | ix.gui.editorFaction.entity = entity 121 | ix.gui.editorFaction:Setup() 122 | end 123 | 124 | self.inventory = self:Add("DButton") 125 | self.inventory:SetText(L"vendorTitleInvSize") 126 | self.inventory:Dock(TOP) 127 | self.inventory:SetTextColor(color_white) 128 | self.inventory:DockMargin(0, 4, 0, 0) 129 | self.inventory.DoClick = function(this) 130 | if (IsValid(ix.gui.editorInventory)) then 131 | ix.gui.editorInventory:Remove() 132 | end 133 | 134 | ix.gui.editorInventory = vgui.Create("ixVendorInventoryEditor") 135 | ix.gui.editorInventory.updateVendor = self.updateVendor 136 | ix.gui.editorInventory.entity = entity 137 | ix.gui.editorInventory:Setup() 138 | end 139 | 140 | local menu 141 | 142 | self.items = self:Add("DListView") 143 | self.items:Dock(FILL) 144 | self.items:DockMargin(0, 4, 0, 0) 145 | self.items:AddColumn(L"name").Header:SetTextColor(color_black) 146 | self.items:AddColumn(L"mode").Header:SetTextColor(color_black) 147 | self.items:AddColumn(L"price").Header:SetTextColor(color_black) 148 | self.items:AddColumn(L"stock").Header:SetTextColor(color_black) 149 | self.items:SetMultiSelect(false) 150 | self.items.OnRowRightClick = function(this, index, line) 151 | if (IsValid(menu)) then 152 | menu:Remove() 153 | end 154 | 155 | local uniqueID = line.item 156 | 157 | menu = DermaMenu() 158 | -- Modes of the item. 159 | local mode, panel = menu:AddSubMenu(L"mode") 160 | panel:SetImage("icon16/key.png") 161 | 162 | -- Disable buying/selling of the item. 163 | mode:AddOption(L"none", function() 164 | self:updateVendor("mode", {uniqueID, nil}) 165 | end):SetImage("icon16/cog_error.png") 166 | 167 | -- Allow the vendor to sell and buy this item. 168 | mode:AddOption(L"vendorBoth", function() 169 | self:updateVendor("mode", {uniqueID, VENDOR.SELLANDBUY}) 170 | end):SetImage("icon16/cog.png") 171 | 172 | -- Only allow the vendor to buy this item from players. 173 | mode:AddOption(L"vendorBuy", function() 174 | self:updateVendor("mode", {uniqueID, VENDOR.BUYONLY}) 175 | end):SetImage("icon16/cog_delete.png") 176 | 177 | -- Only allow the vendor to sell this item to players. 178 | mode:AddOption(L"vendorSell", function() 179 | self:updateVendor("mode", {uniqueID, VENDOR.SELLONLY}) 180 | end):SetImage("icon16/cog_add.png") 181 | 182 | local itemTable = ix.item.list[uniqueID] 183 | 184 | -- Set the price of the item. 185 | menu:AddOption(L"price", function() 186 | Derma_StringRequest( 187 | itemTable.GetName and itemTable:GetName() or L(itemTable.name), 188 | L"vendorPriceReq", 189 | entity:GetPrice(uniqueID), 190 | function(text) 191 | text = tonumber(text) 192 | 193 | if (text == itemTable.price) then 194 | text = nil 195 | end 196 | 197 | self:updateVendor("price", {uniqueID, text}) 198 | end 199 | ) 200 | end):SetImage("icon16/coins.png") 201 | 202 | -- Set the stock of the item or disable it. 203 | local stock, menuPanel = menu:AddSubMenu(L"stock") 204 | menuPanel:SetImage("icon16/table.png") 205 | 206 | -- Disable the use of stocks for this item. 207 | stock:AddOption(L"disable", function() 208 | self:updateVendor("stockDisable", uniqueID) 209 | end):SetImage("icon16/table_delete.png") 210 | 211 | -- Edit the maximum stock for this item. 212 | stock:AddOption(L"edit", function() 213 | local _, max = entity:GetStock(uniqueID) 214 | 215 | Derma_StringRequest( 216 | itemTable.GetName and itemTable:GetName() or L(itemTable.name), 217 | L"vendorStockReq", 218 | max or 1, 219 | function(text) 220 | self:updateVendor("stockMax", {uniqueID, text}) 221 | end 222 | ) 223 | end):SetImage("icon16/table_edit.png") 224 | 225 | -- Edit the current stock of this item. 226 | stock:AddOption(L"vendorEditCurStock", function() 227 | Derma_StringRequest( 228 | itemTable.GetName and itemTable:GetName() or L(itemTable.name), 229 | L"vendorStockCurReq", 230 | entity:GetStock(uniqueID) or 0, 231 | function(text) 232 | self:updateVendor("stock", {uniqueID, text}) 233 | end 234 | ) 235 | end):SetImage("icon16/table_edit.png") 236 | menu:Open() 237 | end 238 | 239 | self.lines = {} 240 | 241 | for k, v in SortedPairs(ix.item.list) do 242 | local mode = entity.items[k] and entity.items[k][VENDOR.MODE] 243 | local current, max = entity:GetStock(k) 244 | local panel = self.items:AddLine( 245 | v.GetName and v:GetName() or L(v.name), 246 | mode and L(VENDOR_TEXT[mode]) or L"none", 247 | entity:GetPrice(k), 248 | max and current.."/"..max or "-" 249 | ) 250 | 251 | panel.item = k 252 | self.lines[k] = panel 253 | end 254 | end 255 | 256 | function PANEL:OnRemove() 257 | if (IsValid(ix.gui.vendorRemake)) then 258 | ix.gui.vendorRemake:Remove() 259 | end 260 | 261 | if (IsValid(ix.gui.editorFaction)) then 262 | ix.gui.editorFaction:Remove() 263 | end 264 | 265 | if (IsValid(ix.gui.editorInventory)) then 266 | ix.gui.editorInventory:Remove() 267 | end 268 | end 269 | 270 | function PANEL:updateVendor(key, value) 271 | net.Start("ixVendorRemakeEdit") 272 | net.WriteString(key) 273 | net.WriteType(value) 274 | net.SendToServer() 275 | end 276 | 277 | vgui.Register("ixVendorRemakeEditor", PANEL, "DFrame") 278 | -------------------------------------------------------------------------------- /new_vendors/entities/entities/ix_vendor_new.lua: -------------------------------------------------------------------------------- 1 | local PLUGIN = PLUGIN 2 | ENT.Type = "anim" 3 | ENT.PrintName = "Vendor Remake" 4 | ENT.Category = "Helix" 5 | ENT.Spawnable = true 6 | ENT.AdminOnly = true 7 | ENT.bNoPersist = true 8 | 9 | function ENT:SetupDataTables() 10 | self:NetworkVar("Int", 0, "ID") 11 | self:NetworkVar("Bool", 0, "NoBubble") 12 | self:NetworkVar("String", 0, "DisplayName") 13 | self:NetworkVar("String", 1, "Description") 14 | end 15 | 16 | function ENT:Initialize() 17 | if (SERVER) then 18 | self:SetModel("models/mossman.mdl") 19 | self:SetUseType(SIMPLE_USE) 20 | self:SetMoveType(MOVETYPE_NONE) 21 | self:DrawShadow(true) 22 | self:SetSolid(SOLID_BBOX) 23 | self:PhysicsInit(SOLID_BBOX) 24 | 25 | self.items = {} 26 | self.messages = {} 27 | self.factions = {} 28 | self.classes = {} 29 | self.inventory_size = {w = 1, h = 1} 30 | 31 | self:SetDisplayName("John Doe") 32 | self:SetDescription("") 33 | 34 | self.receivers = {} 35 | 36 | local physObj = self:GetPhysicsObject() 37 | 38 | if (IsValid(physObj)) then 39 | physObj:EnableMotion(false) 40 | physObj:Sleep() 41 | end 42 | end 43 | 44 | timer.Simple(1, function() 45 | if (IsValid(self)) then 46 | self:SetAnim() 47 | end 48 | end) 49 | end 50 | 51 | if (SERVER) then 52 | local PLUGIN = PLUGIN 53 | 54 | function ENT:SpawnFunction(client, trace) 55 | local angles = (trace.HitPos - client:GetPos()):Angle() 56 | angles.r = 0 57 | angles.p = 0 58 | angles.y = angles.y + 180 59 | 60 | local entity = ents.Create("ix_vendor_new") 61 | entity:SetPos(trace.HitPos) 62 | entity:SetAngles(angles) 63 | entity:Spawn() 64 | entity:BuildInventory() 65 | 66 | PLUGIN:SaveData() 67 | 68 | return entity 69 | end 70 | 71 | function ENT:BuildInventory(callback, w, h) 72 | local invID = os.time() + self:EntIndex() 73 | 74 | if self:GetID() ~= 0 then 75 | invID = self:GetID() 76 | end 77 | 78 | local inventory = ix.inventory.Create(w or 1, h or 1, invID) 79 | 80 | inventory.vars.isNewVendor = true 81 | inventory.noSave = true 82 | 83 | if (callback) then 84 | callback(inventory) 85 | end 86 | 87 | self:SetInventory(inventory) 88 | end 89 | 90 | function ENT:SetInventory(inventory) 91 | if (inventory) then 92 | self:SetID(inventory:GetID()) 93 | inventory.OnAuthorizeTransfer = function(inventory, client, oldInventory, item) 94 | if (IsValid(client) and IsValid(self) and inventory.vars and inventory.vars.isNewVendor) then 95 | return false 96 | end 97 | end 98 | end 99 | end 100 | 101 | function ENT:OnRemoveInventory() 102 | local index = self:GetID() 103 | 104 | if (!ix.shuttingDown and !self.ixIsSafe and ix.entityDataLoaded and index) then 105 | local inventory = ix.item.inventories[index] 106 | 107 | if (inventory) then 108 | ix.item.inventories[index] = nil 109 | self.items = {} 110 | 111 | hook.Run("VendorRemakeRemoved", self, inventory) 112 | end 113 | end 114 | end 115 | 116 | function ENT:OnRemove() 117 | self:OnRemoveInventory() 118 | end 119 | 120 | function ENT:Use(activator) 121 | local inventory = self:GetInventory() 122 | 123 | if (inventory and (activator.ixNextOpen or 0) < CurTime()) then 124 | if (!self:CanAccess(activator) or hook.Run("CanPlayerUseVendor", activator) == false) then 125 | if (self.messages[VENDOR.NOTRADE]) then 126 | activator:ChatPrint(self:GetDisplayName()..": "..self.messages[VENDOR.NOTRADE]) 127 | else 128 | activator:NotifyLocalized("vendorNoTrade") 129 | end 130 | 131 | return 132 | end 133 | 134 | if (self.messages[VENDOR.WELCOME]) then 135 | activator:ChatPrint(self:GetDisplayName()..": "..self.messages[VENDOR.WELCOME]) 136 | end 137 | 138 | local items = {} 139 | 140 | -- Only send what is needed. 141 | for k, v in pairs(self.items) do 142 | if (!table.IsEmpty(v) and (CAMI.PlayerHasAccess(activator, "Helix - Manage Vendors", nil) or v[VENDOR.MODE])) then 143 | items[k] = v 144 | end 145 | end 146 | 147 | self.scale = self.scale or 0.5 148 | 149 | -- Open Inventory 150 | local character = activator:GetCharacter() 151 | if (character) then 152 | character:GetInventory():Sync(activator, true) 153 | end 154 | 155 | inventory:AddReceiver(activator) 156 | self.receivers[#self.receivers + 1] = activator 157 | activator.ixOpenVendorRemake = self 158 | inventory:Sync(activator) 159 | 160 | net.Start('ixVendorRemakeOpen') 161 | net.WriteEntity(self) 162 | net.WriteUInt(self.money or 0, 16) 163 | net.WriteTable(items) 164 | net.Send(activator) 165 | 166 | ix.log.Add(activator, "vendorRemakeUse", self:GetDisplayName()) 167 | 168 | activator.ixNextOpen = CurTime() + 1 169 | end 170 | end 171 | 172 | function ENT:SetMoney(value) 173 | self.money = value 174 | 175 | net.Start("ixVendorRemakeMoney") 176 | net.WriteUInt(value and value or -1, 16) 177 | net.Send(self.receivers) 178 | end 179 | 180 | function ENT:GiveMoney(value) 181 | if (self.money) then 182 | self:SetMoney(self:GetMoney() + value) 183 | end 184 | end 185 | 186 | function ENT:TakeMoney(value) 187 | if (self.money) then 188 | self:GiveMoney(-value) 189 | end 190 | end 191 | 192 | function ENT:SetStock(uniqueID, value) 193 | if (!self.items[uniqueID][VENDOR.MAXSTOCK]) then 194 | return 195 | end 196 | 197 | self.items[uniqueID] = self.items[uniqueID] or {} 198 | self.items[uniqueID][VENDOR.STOCK] = math.min(value, self.items[uniqueID][VENDOR.MAXSTOCK]) 199 | 200 | net.Start("ixVendorRemakeStock") 201 | net.WriteString(uniqueID) 202 | net.WriteUInt(value, 16) 203 | net.Send(self.receivers) 204 | end 205 | 206 | function ENT:AddStock(uniqueID, value) 207 | if (!self.items[uniqueID][VENDOR.MAXSTOCK]) then 208 | return 209 | end 210 | 211 | self:SetStock(uniqueID, self:GetStock(uniqueID) + (value or 1)) 212 | end 213 | 214 | function ENT:TakeStock(uniqueID, value) 215 | if (!self.items[uniqueID][VENDOR.MAXSTOCK]) then 216 | return 217 | end 218 | 219 | self:AddStock(uniqueID, -(value or 1)) 220 | end 221 | else 222 | function ENT:CreateBubble() 223 | self.bubble = ClientsideModel("models/extras/info_speech.mdl", RENDERGROUP_OPAQUE) 224 | self.bubble:SetPos(self:GetPos() + Vector(0, 0, 84)) 225 | self.bubble:SetModelScale(0.6, 0) 226 | end 227 | 228 | function ENT:Draw() 229 | local bubble = self.bubble 230 | 231 | if (IsValid(bubble)) then 232 | local realTime = RealTime() 233 | 234 | bubble:SetRenderOrigin(self:GetPos() + Vector(0, 0, 84 + math.sin(realTime * 3) * 0.05)) 235 | bubble:SetRenderAngles(Angle(0, realTime * 100, 0)) 236 | end 237 | 238 | self:DrawModel() 239 | end 240 | 241 | function ENT:Think() 242 | local noBubble = self:GetNoBubble() 243 | 244 | if (IsValid(self.bubble) and noBubble) then 245 | self.bubble:Remove() 246 | elseif (!IsValid(self.bubble) and !noBubble) then 247 | self:CreateBubble() 248 | end 249 | 250 | if ((self.nextAnimCheck or 0) < CurTime()) then 251 | self:SetAnim() 252 | self.nextAnimCheck = CurTime() + 60 253 | end 254 | 255 | self:SetNextClientThink(CurTime() + 0.25) 256 | 257 | return true 258 | end 259 | 260 | function ENT:OnRemove() 261 | if (IsValid(self.bubble)) then 262 | self.bubble:Remove() 263 | end 264 | end 265 | 266 | ENT.PopulateEntityInfo = true 267 | 268 | function ENT:OnPopulateEntityInfo(container) 269 | local name = container:AddRow("name") 270 | name:SetImportant() 271 | name:SetText(self:GetDisplayName()) 272 | name:SizeToContents() 273 | 274 | local descriptionText = self:GetDescription() 275 | 276 | if (descriptionText != "") then 277 | local description = container:AddRow("description") 278 | description:SetText(self:GetDescription()) 279 | description:SizeToContents() 280 | end 281 | end 282 | end 283 | 284 | function ENT:GetInventory() 285 | return ix.item.inventories[self:GetID()] 286 | end 287 | 288 | function ENT:GetMoney() 289 | return self.money 290 | end 291 | 292 | function ENT:CanAccess(client) 293 | local bAccess = false 294 | local uniqueID = ix.faction.indices[client:Team()].uniqueID 295 | 296 | if (self.factions and !table.IsEmpty(self.factions)) then 297 | if (self.factions[uniqueID]) then 298 | bAccess = true 299 | else 300 | return false 301 | end 302 | end 303 | 304 | if (bAccess and self.classes and !table.IsEmpty(self.classes)) then 305 | local class = ix.class.list[client:GetCharacter():GetClass()] 306 | local classID = class and class.uniqueID 307 | 308 | if (classID and !self.classes[classID]) then 309 | return false 310 | end 311 | end 312 | 313 | return true 314 | end 315 | 316 | function ENT:GetStock(uniqueID) 317 | if (self.items[uniqueID] and self.items[uniqueID][VENDOR.MAXSTOCK]) then 318 | return self.items[uniqueID][VENDOR.STOCK] or 0, self.items[uniqueID][VENDOR.MAXSTOCK] 319 | end 320 | end 321 | 322 | function ENT:GetPrice(uniqueID, selling) 323 | local price = ix.item.list[uniqueID] and self.items[uniqueID] and 324 | self.items[uniqueID][VENDOR.PRICE] or ix.item.list[uniqueID].price or 0 325 | 326 | if (selling) then 327 | price = math.floor(price * (self.scale or 0.5)) 328 | end 329 | 330 | return price 331 | end 332 | 333 | function ENT:HasMoney(amount) 334 | -- Vendor not using money system so they can always afford it. 335 | if (!self.money) then 336 | return true 337 | end 338 | 339 | return self.money >= amount 340 | end 341 | 342 | function ENT:SetAnim() 343 | for k, v in ipairs(self:GetSequenceList()) do 344 | if (v:lower():find("idle") and v != "idlenoise") then 345 | return self:ResetSequence(k) 346 | end 347 | end 348 | 349 | if (self:GetSequenceCount() > 1) then 350 | self:ResetSequence(4) 351 | end 352 | end 353 | -------------------------------------------------------------------------------- /new_vendors/sh_plugin.lua: -------------------------------------------------------------------------------- 1 | local PLUGIN = PLUGIN 2 | 3 | PLUGIN.name = "RE:Vendors" 4 | PLUGIN.author = "STEAM_0:1:29606990" -- Chessnut original code 5 | PLUGIN.description = "Adds NPC vendors that can sell things." 6 | 7 | ix.lang.AddTable("russian", { 8 | ['vendorTitleInvSize'] = "Размер инвентаря", 9 | ['vendorSlideWInvSize'] = "Ширина", 10 | ['vendorSlideHInvSize'] = "Высота", 11 | ['vendorResizeBtnInvSize'] = "Изменить размер", 12 | ['vendorRemoveItemEditor'] = "Удалить", 13 | ['vendorMaxStock'] = "У данного продавца полный запас этого товара!" 14 | }) 15 | 16 | ix.lang.AddTable("english", { 17 | ['vendorTitleInvSize'] = "Inventory size", 18 | ['vendorSlideWInvSize'] = "Width", 19 | ['vendorSlideHInvSize'] = "Height", 20 | ['vendorResizeBtnInvSize'] = "Resize", 21 | ['vendorRemoveItemEditor'] = "Remove item", 22 | ['vendorMaxStock'] = "This vendor has full stock of that item!" 23 | }) 24 | 25 | CAMI.RegisterPrivilege({ 26 | Name = "Helix - Manage Vendors", 27 | MinAccess = "admin" 28 | }) 29 | 30 | VENDOR = { 31 | SELLANDBUY = 1, -- Sell and buy the item. 32 | SELLONLY = 2, -- Only sell the item to the player. 33 | BUYONLY = 3, -- Only buy the item from the player. 34 | PRICE = 1, 35 | STOCK = 2, 36 | MODE = 3, 37 | MAXSTOCK = 4, 38 | NOTRADE = 3, 39 | WELCOME = 1 40 | } 41 | 42 | if CLIENT then 43 | local stockPnl, pricePnl = nil, nil 44 | local intPriceVendor = 0 45 | function PLUGIN:PopulateItemTooltip( tooltip, item ) 46 | if not item.invID then 47 | return 48 | end 49 | 50 | local panel = ix.gui.vendorRemake 51 | if (IsValid(panel)) then 52 | local entity = panel.entity 53 | if IsValid(entity) and entity.items[item.uniqueID] then 54 | local info = entity.items[item.uniqueID] 55 | if not info then 56 | return 57 | end 58 | 59 | local inventory = ix.inventory.Get(item.invID) 60 | 61 | if inventory and inventory.slots and inventory.vars then 62 | intPriceVendor = entity:GetPrice(item.uniqueID, not inventory.vars.isNewVendor) 63 | intPriceVendor = ix.currency.Get(intPriceVendor) 64 | 65 | pricePnl = tooltip:AddRowAfter("name", "priceVendor") 66 | 67 | if inventory.vars.isNewVendor then 68 | pricePnl:SetText(L"purchase".." ("..intPriceVendor..")") 69 | else 70 | -- elseif not inventory.vars.isNewVendor and IsValid(ix.gui.inv1) and not IsValid(ix.gui.menu) then 71 | pricePnl:SetText(L"sell".." ("..intPriceVendor..")") 72 | end 73 | pricePnl:SetBackgroundColor(derma.GetColor("Warning", panel)) 74 | pricePnl:SizeToContents() 75 | 76 | if (inventory.vars.isNewVendor and info[VENDOR.MAXSTOCK]) then 77 | if IsValid(pricePnl) then 78 | stockPnl = tooltip:AddRowAfter("priceVendor", "stockVendor") 79 | else 80 | stockPnl = tooltip:AddRowAfter("name", "stockVendor") 81 | end 82 | 83 | stockPnl:SetText(string.format("%s: %d/%d", L'stock', info[VENDOR.STOCK], info[VENDOR.MAXSTOCK])) 84 | stockPnl:SetBackgroundColor(derma.GetColor("Error", panel)) 85 | stockPnl:SizeToContents() 86 | end 87 | end 88 | end 89 | end 90 | end 91 | 92 | function PLUGIN:SendTradeToVendor(itemObject, isSellingToVendor) 93 | if (not IsValid(ix.gui.vendorRemake) or not itemObject.id) then 94 | return 95 | end 96 | 97 | local entity = ix.gui.vendorRemake.entity 98 | 99 | if (not entity.items[itemObject.uniqueID]) then 100 | return 101 | end 102 | 103 | net.Start("ixVendorRemakeTrade") 104 | net.WriteUInt(itemObject.id, 32) 105 | net.WriteBool(isSellingToVendor) 106 | net.SendToServer() 107 | end 108 | 109 | function PLUGIN:InventoryItemOnDrop(itemObject, curInv, newInventory) 110 | if curInv and newInventory then 111 | if (newInventory.vars and newInventory.vars.isNewVendor and curInv.slots) or (curInv.vars and curInv.vars.isNewVendor and newInventory.slots) then 112 | if (newInventory == curInv) then 113 | return 114 | end 115 | 116 | if IsValid(ix.gui.vendorRemake) and not IsValid(ix.gui.vendorRemakeEditor) then -- sell / purchase that item 117 | local entity = ix.gui.vendorRemake.entity 118 | if (not entity.items[itemObject.uniqueID]) then 119 | return 120 | end 121 | 122 | if curInv.vars.isNewVendor then -- purchase item to vendor 123 | self:SendTradeToVendor(itemObject, false) 124 | elseif newInventory.vars.isNewVendor then -- sell item to vendor 125 | self:SendTradeToVendor(itemObject, true) 126 | end 127 | end 128 | end 129 | end 130 | end 131 | end 132 | 133 | function PLUGIN:CanTransferItem(itemObject, curInv, newInventory) 134 | if curInv and newInventory then 135 | if (newInventory.vars and newInventory.vars.isNewVendor) or (curInv.vars and curInv.vars.isNewVendor) then 136 | if curInv:GetID() == 0 then 137 | return true -- META:Add() 138 | end 139 | 140 | return false 141 | end 142 | end 143 | end 144 | 145 | if (SERVER) then 146 | util.AddNetworkString("ixVendorRemakeOpen") 147 | util.AddNetworkString("ixVendorRemakeClose") 148 | util.AddNetworkString("ixVendorRemakeEditor") 149 | util.AddNetworkString("ixVendorRemakeEditFinish") 150 | util.AddNetworkString("ixVendorRemakeEdit") 151 | util.AddNetworkString("ixVendorRemakeTrade") 152 | util.AddNetworkString("ixVendorRemakeStock") 153 | util.AddNetworkString("ixVendorRemakeMoney") 154 | 155 | ix.log.AddType("vendorCharacterTraded", function(client, ...) 156 | local arg = {...} 157 | return string.format("%s %s '%s' to the vendor '%s'.", client:Name(), arg[3] == true and "selling" or "purchased", arg[2], arg[1]) 158 | end) 159 | 160 | ix.log.AddType("vendorRemakeUse", function(client, ...) 161 | local arg = {...} 162 | return string.format("%s used the '%s' vendor.", client:Name(), arg[1]) 163 | end) 164 | 165 | function PLUGIN:SaveData() 166 | local data = {} 167 | 168 | for _, entity in ipairs(ents.FindByClass("ix_vendor_new")) do 169 | local inventory = entity:GetInventory() 170 | 171 | if (inventory) then 172 | local bodygroups = {} 173 | 174 | for _, v in ipairs(entity:GetBodyGroups() or {}) do 175 | bodygroups[v.id] = entity:GetBodygroup(v.id) 176 | end 177 | 178 | data[#data + 1] = { 179 | name = entity:GetDisplayName(), 180 | description = entity:GetDescription(), 181 | pos = entity:GetPos(), 182 | angles = entity:GetAngles(), 183 | model = entity:GetModel(), 184 | skin = entity:GetSkin(), 185 | bodygroups = bodygroups, 186 | bubble = entity:GetNoBubble(), 187 | inventory_id = inventory:GetID(), 188 | items = entity.items, 189 | factions = entity.factions, 190 | classes = entity.classes, 191 | money = entity.money, 192 | scale = entity.scale, 193 | inventory_size = {w = entity.inventory_size.w or 1, h = entity.inventory_size.h or 1}, 194 | } 195 | end 196 | end 197 | 198 | self:SetData(data) 199 | end 200 | 201 | function PLUGIN:CharacterVendorTraded(client, vendor, uniqueID, isSellingToVendor) 202 | ix.log.Add(client, "vendorCharacterTraded", vendor:GetDisplayName(), uniqueID, isSellingToVendor) 203 | end 204 | 205 | function PLUGIN:VendorRemakeRemoved(entity, inventory) 206 | self:SaveData() 207 | end 208 | 209 | function PLUGIN:LoadData() 210 | for _, v in ipairs(self:GetData() or {}) do 211 | local inventoryID = tonumber(v.inventory_id) 212 | 213 | if (!inventoryID or inventoryID < 1) then 214 | ErrorNoHalt(string.format("[Helix] Attempted to restore container inventory with invalid inventory ID '%s'\n", tostring(inventoryID))) 215 | continue 216 | end 217 | 218 | local entity = ents.Create("ix_vendor_new") 219 | entity:SetPos(v.pos) 220 | entity:SetAngles(v.angles) 221 | entity:Spawn() 222 | 223 | entity:SetModel(v.model) 224 | entity:SetSkin(v.skin or 0) 225 | entity:SetSolid(SOLID_BBOX) 226 | entity:PhysicsInit(SOLID_BBOX) 227 | 228 | local physObj = entity:GetPhysicsObject() 229 | 230 | if (IsValid(physObj)) then 231 | physObj:EnableMotion(false) 232 | physObj:Sleep() 233 | end 234 | 235 | entity:SetNoBubble(v.bubble) 236 | entity:SetDisplayName(v.name or "John Doe") 237 | entity:SetDescription(v.description) 238 | 239 | for id, bodygroup in pairs(v.bodygroups or {}) do 240 | entity:SetBodygroup(id, bodygroup) 241 | end 242 | 243 | entity.inventory_size = {w = v.inventory_size.w or 1, h = v.inventory_size.h or 1} 244 | entity:BuildInventory(function(inventory) 245 | for uniqueID, data in pairs(v.items) do 246 | if (not data or not ix.item.Get(tostring(uniqueID))) then continue end 247 | inventory:Add(tostring(uniqueID), 1, nil, nil, nil, true) 248 | end 249 | end, entity.inventory_size.w, entity.inventory_size.h) 250 | 251 | 252 | local items = {} 253 | 254 | for uniqueID, data in pairs(v.items) do 255 | if (not data or not ix.item.Get(tostring(uniqueID))) then continue end 256 | items[tostring(uniqueID)] = data 257 | end 258 | 259 | entity.items = items 260 | entity.factions = v.factions or {} 261 | entity.classes = v.classes or {} 262 | entity.money = v.money 263 | entity.scale = v.scale or 0.5 264 | 265 | items = nil 266 | end 267 | end 268 | 269 | net.Receive("ixVendorRemakeClose", function(len, client) 270 | local entity = client.ixOpenVendorRemake 271 | if (IsValid(entity)) then 272 | local inventory = entity:GetInventory() 273 | if (inventory) then 274 | inventory:RemoveReceiver(client) 275 | end 276 | 277 | for k, v in ipairs(entity.receivers) do 278 | if (v == client) then 279 | table.remove(entity.receivers, k) 280 | break 281 | end 282 | end 283 | 284 | client.ixOpenVendorRemake = nil 285 | end 286 | end) 287 | 288 | local function UpdateEditReceivers(receivers, key, value) 289 | net.Start("ixVendorRemakeEdit") 290 | net.WriteString(key) 291 | net.WriteType(value) 292 | net.Send(receivers) 293 | end 294 | -- SERVER 295 | net.Receive("ixVendorRemakeEdit", function(len, client) 296 | if (!CAMI.PlayerHasAccess(client, "Helix - Manage Vendors", nil)) then 297 | return 298 | end 299 | 300 | local entity = client.ixOpenVendorRemake 301 | if (!IsValid(entity)) then 302 | return 303 | end 304 | 305 | local key = net.ReadString() 306 | local data = net.ReadType() 307 | local feedback = true 308 | 309 | if (key == "name") then 310 | entity:SetDisplayName(data) 311 | elseif (key == 'inventory_size') then 312 | entity:OnRemoveInventory() 313 | 314 | local invW, invH = math.floor(data[1]), math.floor(data[2]) 315 | 316 | timer.Create("ixVendorRemakeRestoreInvSize", 1, 1, function() 317 | entity:BuildInventory(function(inventory) 318 | entity.inventory_size = {w = inventory.w, h = inventory.h} 319 | 320 | for k, v in ipairs(entity.receivers) do 321 | inventory:AddReceiver(v) 322 | inventory:Sync(v) 323 | end 324 | 325 | UpdateEditReceivers(entity.receivers, key, value) 326 | end, invW, invH) 327 | end) 328 | 329 | feedback = false 330 | elseif (key == "remove_inv_item") then 331 | if (IsValid(entity)) then 332 | entity:GetInventory():Remove(data[1], nil, true, true) 333 | entity.items[data[2]] = nil 334 | end 335 | elseif (key == "description") then 336 | entity:SetDescription(data) 337 | elseif (key == "bubble") then 338 | entity:SetNoBubble(data) 339 | elseif (key == "mode") then 340 | local uniqueID = data[1] 341 | local mode = data[2] 342 | local inventory = entity:GetInventory() 343 | local items = inventory:GetItemsByUniqueID(uniqueID, true) 344 | 345 | if (mode and #items == 0 and !inventory:Add(uniqueID)) then 346 | feedback = false 347 | else 348 | if (not mode and #items > 0) then 349 | for _, v in ipairs(items) do 350 | if (v.uniqueID == uniqueID) then 351 | inventory:Remove(v.id, nil, true, true) 352 | break 353 | end 354 | end 355 | end 356 | 357 | entity.items[uniqueID] = entity.items[uniqueID] or {} 358 | entity.items[uniqueID][VENDOR.MODE] = mode 359 | end 360 | 361 | UpdateEditReceivers(entity.receivers, key, data) 362 | elseif (key == "price") then 363 | local uniqueID = data[1] 364 | data[2] = tonumber(data[2]) 365 | 366 | if (data[2]) then 367 | data[2] = math.Round(data[2]) 368 | end 369 | 370 | entity.items[uniqueID] = entity.items[uniqueID] or {} 371 | entity.items[uniqueID][VENDOR.PRICE] = data[2] 372 | 373 | UpdateEditReceivers(entity.receivers, key, data) 374 | 375 | data = uniqueID 376 | elseif (key == "stockDisable") then 377 | local uniqueID = data[1] 378 | 379 | entity.items[data] = entity.items[uniqueID] or {} 380 | entity.items[data][VENDOR.MAXSTOCK] = nil 381 | 382 | UpdateEditReceivers(entity.receivers, key, data) 383 | elseif (key == "stockMax") then 384 | local uniqueID = data[1] 385 | data[2] = math.max(math.Round(tonumber(data[2]) or 1), 1) 386 | 387 | entity.items[uniqueID] = entity.items[uniqueID] or {} 388 | entity.items[uniqueID][VENDOR.MAXSTOCK] = data[2] 389 | entity.items[uniqueID][VENDOR.STOCK] = math.Clamp(entity.items[uniqueID][VENDOR.STOCK] or data[2], 1, data[2]) 390 | 391 | data[3] = entity.items[uniqueID][VENDOR.STOCK] 392 | 393 | UpdateEditReceivers(entity.receivers, key, data) 394 | 395 | data = uniqueID 396 | elseif (key == "stock") then 397 | local uniqueID = data[1] 398 | 399 | entity.items[uniqueID] = entity.items[uniqueID] or {} 400 | 401 | if (!entity.items[uniqueID][VENDOR.MAXSTOCK]) then 402 | data[2] = math.max(math.Round(tonumber(data[2]) or 0), 0) 403 | entity.items[uniqueID][VENDOR.MAXSTOCK] = data[2] 404 | end 405 | 406 | data[2] = math.Clamp(math.Round(tonumber(data[2]) or 0), 0, entity.items[uniqueID][VENDOR.MAXSTOCK]) 407 | entity.items[uniqueID][VENDOR.STOCK] = data[2] 408 | 409 | UpdateEditReceivers(entity.receivers, key, data) 410 | 411 | data = uniqueID 412 | elseif (key == "faction") then 413 | local faction = ix.faction.teams[data] 414 | 415 | if (faction) then 416 | entity.factions[data] = !entity.factions[data] 417 | 418 | if (!entity.factions[data]) then 419 | entity.factions[data] = nil 420 | end 421 | end 422 | 423 | local uniqueID = data 424 | data = {uniqueID, entity.factions[uniqueID]} 425 | elseif (key == "class") then 426 | local class 427 | 428 | for _, v in ipairs(ix.class.list) do 429 | if (v.uniqueID == data) then 430 | class = v 431 | 432 | break 433 | end 434 | end 435 | 436 | if (class) then 437 | entity.classes[data] = !entity.classes[data] 438 | 439 | if (!entity.classes[data]) then 440 | entity.classes[data] = nil 441 | end 442 | end 443 | 444 | local uniqueID = data 445 | data = {uniqueID, entity.classes[uniqueID]} 446 | elseif (key == "model") then 447 | entity:SetModel(data) 448 | entity:SetSolid(SOLID_BBOX) 449 | entity:PhysicsInit(SOLID_BBOX) 450 | entity:SetAnim() 451 | 452 | timer.Create("ixVendorRemakeUpdateInvType", 1, 1, function() 453 | local strModel = tostring(entity:GetModel()):lower() 454 | local query = mysql:Update("ix_inventories") 455 | query:Update("inventory_type", "vendor_new:"..strModel) 456 | query:Where("inventory_id", entity:GetID()) 457 | query:Execute() 458 | query, strModel = nil, nil 459 | end) 460 | 461 | elseif (key == "useMoney") then 462 | if (entity.money) then 463 | entity:SetMoney() 464 | else 465 | entity:SetMoney(0) 466 | end 467 | elseif (key == "money") then 468 | data = math.Round(math.abs(tonumber(data) or 0)) 469 | 470 | entity:SetMoney(data) 471 | feedback = false 472 | elseif (key == "scale") then 473 | data = tonumber(data) or 0.5 474 | 475 | entity.scale = data 476 | 477 | UpdateEditReceivers(entity.receivers, key, data) 478 | end 479 | 480 | PLUGIN:SaveData() 481 | 482 | if (feedback) then 483 | local receivers = {} 484 | 485 | for _, v in ipairs(entity.receivers) do 486 | if (CAMI.PlayerHasAccess(v, "Helix - Manage Vendors", nil)) then 487 | receivers[#receivers + 1] = v 488 | end 489 | end 490 | 491 | net.Start("ixVendorRemakeEditFinish") 492 | net.WriteString(key) 493 | net.WriteType(data) 494 | net.Send(receivers) 495 | receivers = nil 496 | end 497 | end) 498 | 499 | net.Receive("ixVendorRemakeTrade", function(length, client) 500 | if ((client.ixVendorTry or 0) < CurTime()) then 501 | client.ixVendorTry = CurTime() + 0.33 502 | else 503 | return 504 | end 505 | 506 | local entity = client.ixOpenVendorRemake 507 | 508 | if (!IsValid(entity) or client:GetPos():Distance(entity:GetPos()) > 192) then 509 | return 510 | end 511 | 512 | local itemID = net.ReadUInt(32) 513 | local isSellingToVendor = net.ReadBool() 514 | 515 | local itemData = ix.item.instances[itemID] 516 | local uniqueID = itemData.uniqueID 517 | local data = entity.items[uniqueID] 518 | 519 | if (data and 520 | hook.Run("CanPlayerTradeWithVendor", client, entity, uniqueID, isSellingToVendor) != false) then 521 | local price = entity:GetPrice(uniqueID, isSellingToVendor) 522 | 523 | if (isSellingToVendor) then 524 | if (data[VENDOR.MODE] ~= VENDOR.SELLANDBUY and data[VENDOR.MODE] ~= VENDOR.BUYONLY) then 525 | return false 526 | end 527 | 528 | local found = false 529 | local name 530 | 531 | if (!entity:HasMoney(price)) then 532 | return client:NotifyLocalized("vendorNoMoney") 533 | end 534 | 535 | local stock, max = entity:GetStock(uniqueID) 536 | if (stock and stock >= max) then 537 | return client:NotifyLocalized("vendorMaxStock") 538 | end 539 | 540 | local invOkay = true 541 | 542 | for _, v in pairs(client:GetCharacter():GetInventory():GetItems()) do 543 | if (v.id == itemID and v:GetID() != 0 and ix.item.instances[v:GetID()] and v:GetData("equip", false) == false) then 544 | invOkay = v:Remove() 545 | found = true 546 | name = L(v.name, client) 547 | 548 | break 549 | end 550 | end 551 | 552 | if (!found) then 553 | return 554 | end 555 | 556 | if (!invOkay) then 557 | client:GetCharacter():GetInventory():Sync(client, true) 558 | return client:NotifyLocalized("tellAdmin", "trd!iid") 559 | end 560 | 561 | client:GetCharacter():GiveMoney(price) 562 | client:NotifyLocalized("businessSell", name, ix.currency.Get(price)) 563 | entity:TakeMoney(price) 564 | entity:AddStock(uniqueID) 565 | 566 | PLUGIN:SaveData() 567 | hook.Run("CharacterVendorTraded", client, entity, uniqueID, isSellingToVendor) 568 | else 569 | if (data[VENDOR.MODE] ~= VENDOR.SELLANDBUY and data[VENDOR.MODE] ~= VENDOR.SELLONLY) then 570 | return false 571 | end 572 | 573 | local stock = entity:GetStock(uniqueID) 574 | 575 | if (stock and stock < 1) then 576 | return client:NotifyLocalized("vendorNoStock") 577 | end 578 | 579 | if (!client:GetCharacter():HasMoney(price)) then 580 | return client:NotifyLocalized("canNotAfford") 581 | end 582 | 583 | local name = L(ix.item.list[uniqueID].name, client) 584 | 585 | client:GetCharacter():TakeMoney(price) 586 | client:NotifyLocalized("businessPurchase", name, ix.currency.Get(price)) 587 | 588 | entity:GiveMoney(price) 589 | 590 | if (!client:GetCharacter():GetInventory():Add(uniqueID)) then 591 | ix.item.Spawn(uniqueID, client) 592 | end 593 | 594 | entity:TakeStock(uniqueID) 595 | 596 | PLUGIN:SaveData() 597 | hook.Run("CharacterVendorTraded", client, entity, uniqueID, isSellingToVendor) 598 | end 599 | else 600 | client:NotifyLocalized("vendorNoTrade") 601 | end 602 | end) 603 | else 604 | VENDOR_TEXT = {} 605 | VENDOR_TEXT[VENDOR.SELLANDBUY] = "vendorBoth" 606 | VENDOR_TEXT[VENDOR.BUYONLY] = "vendorBuy" 607 | VENDOR_TEXT[VENDOR.SELLONLY] = "vendorSell" 608 | 609 | function PLUGIN:CreateItemInteractionMenu(item_panel, menu, itemTable) 610 | if not IsValid(ix.gui.vendorRemake) then 611 | return 612 | end 613 | 614 | local entity = ix.gui.vendorRemake.entity 615 | local inventory = ix.item.inventories[item_panel.inventoryID] 616 | local data = entity.items[itemTable.uniqueID] and entity.items[itemTable.uniqueID][VENDOR.MODE] or 0 617 | 618 | menu = DermaMenu() 619 | 620 | if inventory.vars.isNewVendor then 621 | if (data == VENDOR.SELLANDBUY or data == VENDOR.SELLONLY) then 622 | menu:AddOption(L"purchase", function() 623 | self:SendTradeToVendor(itemTable, false) 624 | end):SetImage("icon16/basket_put.png") 625 | end 626 | 627 | if IsValid(ix.gui.vendorRemakeEditor) then 628 | menu:AddOption(L"vendorRemoveItemEditor", function() 629 | ix.gui.vendorRemakeEditor:updateVendor("remove_inv_item", {itemTable.id, itemTable.uniqueID}) 630 | end):SetImage("icon16/basket_delete.png") 631 | end 632 | else -- client inventory 633 | if (data == VENDOR.SELLANDBUY or data == VENDOR.BUYONLY) then 634 | menu:AddOption(L"sell", function() 635 | self:SendTradeToVendor(itemTable, true) 636 | end):SetImage("icon16/basket_remove.png") 637 | end 638 | end 639 | 640 | menu:Open() 641 | 642 | return true 643 | end 644 | 645 | net.Receive("ixVendorRemakeEdit", function() 646 | local panel = ix.gui.vendorRemake 647 | 648 | if (!IsValid(panel)) then 649 | return 650 | end 651 | 652 | local entity = panel.entity 653 | 654 | if (!IsValid(entity)) then 655 | return 656 | end 657 | 658 | local key = net.ReadString() 659 | local data = net.ReadType() 660 | 661 | if (key == "mode") then 662 | local uniqueID = data[1] 663 | 664 | entity.items[uniqueID] = entity.items[uniqueID] or {} 665 | entity.items[uniqueID][VENDOR.MODE] = data[2] 666 | elseif (key == 'inventory_size') then 667 | if (!IsValid(ix.gui.menu) and IsValid(ix.gui.vendorRemake)) then 668 | ix.gui.vendorRemake:SetLocalInventory(LocalPlayer():GetCharacter():GetInventory()) 669 | ix.gui.vendorRemake:SetVendorInventory(entity:GetInventory()) 670 | end 671 | elseif (key == "price") then 672 | local uniqueID = data[1] 673 | 674 | entity.items[uniqueID] = entity.items[uniqueID] or {} 675 | entity.items[uniqueID][VENDOR.PRICE] = tonumber(data[2]) 676 | elseif (key == "stockDisable") then 677 | if (entity.items[data]) then 678 | entity.items[data][VENDOR.MAXSTOCK] = nil 679 | end 680 | elseif (key == "stockMax") then 681 | local uniqueID = data[1] 682 | local value = data[2] 683 | local current = data[3] 684 | 685 | entity.items[uniqueID] = entity.items[uniqueID] or {} 686 | entity.items[uniqueID][VENDOR.MAXSTOCK] = value 687 | entity.items[uniqueID][VENDOR.STOCK] = current 688 | elseif (key == "stock") then 689 | local uniqueID = data[1] 690 | local value = data[2] 691 | 692 | entity.items[uniqueID] = entity.items[uniqueID] or {} 693 | 694 | if (!entity.items[uniqueID][VENDOR.MAXSTOCK]) then 695 | entity.items[uniqueID][VENDOR.MAXSTOCK] = value 696 | end 697 | 698 | entity.items[uniqueID][VENDOR.STOCK] = value 699 | elseif (key == "scale") then 700 | entity.scale = data 701 | elseif (key == "remove_inv_item") then 702 | entity.items[data[2]] = nil 703 | end 704 | end) 705 | 706 | net.Receive("ixVendorRemakeEditFinish", function() 707 | local panel = ix.gui.vendorRemake 708 | local editor = ix.gui.vendorRemakeEditor 709 | 710 | if (!IsValid(panel) or !IsValid(editor)) then 711 | return 712 | end 713 | 714 | local entity = panel.entity 715 | 716 | if (!IsValid(entity)) then 717 | return 718 | end 719 | 720 | local key = net.ReadString() 721 | local data = net.ReadType() 722 | 723 | if (key == "name") then 724 | editor.name:SetText(data) 725 | elseif (key == "description") then 726 | editor.description:SetText(data) 727 | elseif (key == "bubble") then 728 | editor.bubble.noSend = true 729 | editor.bubble:SetValue(data and 1 or 0) 730 | elseif (key == "mode") then 731 | if (data[2] == nil) then 732 | editor.lines[data[1]]:SetValue(2, L"none") 733 | else 734 | editor.lines[data[1]]:SetValue(2, L(VENDOR_TEXT[data[2]])) 735 | end 736 | elseif (key == "price") then 737 | editor.lines[data]:SetValue(3, entity:GetPrice(data)) 738 | elseif (key == "stockDisable") then 739 | editor.lines[data]:SetValue(4, "-") 740 | elseif (key == "stockMax" or key == "stock") then 741 | local current, max = entity:GetStock(data) 742 | 743 | editor.lines[data]:SetValue(4, current.."/"..max) 744 | elseif (key == "faction") then 745 | local uniqueID = data[1] 746 | local state = data[2] 747 | local editPanel = ix.gui.editorFaction 748 | 749 | entity.factions[uniqueID] = state 750 | 751 | if (IsValid(editPanel) and IsValid(editPanel.factions[uniqueID])) then 752 | editPanel.factions[uniqueID]:SetChecked(state == true) 753 | end 754 | elseif (key == "class") then 755 | local uniqueID = data[1] 756 | local state = data[2] 757 | local editPanel = ix.gui.editorFaction 758 | 759 | entity.classes[uniqueID] = state 760 | 761 | if (IsValid(editPanel) and IsValid(editPanel.classes[uniqueID])) then 762 | editPanel.classes[uniqueID]:SetChecked(state == true) 763 | end 764 | elseif (key == "model") then 765 | editor.model:SetText(entity:GetModel()) 766 | elseif (key == "scale") then 767 | editor.sellScale.noSend = true 768 | editor.sellScale:SetValue(data) 769 | elseif (key == "remove_inv_item") then 770 | editor.lines[data[2]]:SetValue(2, L"none") 771 | end 772 | 773 | surface.PlaySound("buttons/button14.wav") 774 | end) 775 | 776 | net.Receive("ixVendorRemakeOpen", function() 777 | if (IsValid(ix.gui.menu)) then 778 | net.Start("ixVendorRemakeClose") 779 | net.SendToServer() 780 | return 781 | end 782 | 783 | local entity = net.ReadEntity() 784 | 785 | if (!IsValid(entity)) then 786 | return 787 | end 788 | 789 | entity.money = net.ReadUInt(16) 790 | entity.items = net.ReadTable() 791 | 792 | local inventory = entity:GetInventory() 793 | if (inventory and inventory.slots) then 794 | if IsValid(ix.gui.vendorRemake) then 795 | ix.gui.vendorRemake:Remove() 796 | end 797 | 798 | local localInventory = LocalPlayer():GetCharacter():GetInventory() 799 | ix.gui.vendorRemake = vgui.Create("ixVendorRemakeView") 800 | ix.gui.vendorRemake.entity = entity 801 | 802 | if (localInventory) then 803 | ix.gui.vendorRemake:SetLocalInventory(localInventory) 804 | end 805 | 806 | ix.gui.vendorRemake:SetVendorTitle(entity:GetDisplayName()) 807 | ix.gui.vendorRemake:SetVendorInventory(entity:GetInventory()) 808 | 809 | if (entity.money) then 810 | if (localInventory) then 811 | ix.gui.vendorRemake:SetLocalMoney(LocalPlayer():GetCharacter():GetMoney()) 812 | end 813 | ix.gui.vendorRemake:SetVendorMoney(entity.money) 814 | end 815 | end 816 | end) 817 | 818 | net.Receive("ixVendorRemakeEditor", function() 819 | local entity = net.ReadEntity() 820 | 821 | if (!IsValid(entity) or !CAMI.PlayerHasAccess(LocalPlayer(), "Helix - Manage Vendors", nil)) then 822 | return 823 | end 824 | 825 | entity.money = net.ReadUInt(16) 826 | entity.items = net.ReadTable() 827 | entity.scale = net.ReadFloat() 828 | entity.messages = net.ReadTable() 829 | entity.factions = net.ReadTable() 830 | entity.classes = net.ReadTable() 831 | 832 | local inventory = entity:GetInventory() 833 | if (inventory and inventory.slots) then 834 | if IsValid(ix.gui.vendorRemake) then 835 | ix.gui.vendorRemake:Remove() 836 | end 837 | 838 | local localInventory = LocalPlayer():GetCharacter():GetInventory() 839 | ix.gui.vendorRemake = vgui.Create("ixVendorRemakeView") 840 | ix.gui.vendorRemake.entity = entity 841 | 842 | if (localInventory) then 843 | ix.gui.vendorRemake:SetLocalInventory(localInventory) 844 | end 845 | 846 | ix.gui.vendorRemake:SetVendorTitle(entity:GetDisplayName()) 847 | ix.gui.vendorRemake:SetVendorInventory(entity:GetInventory()) 848 | 849 | if (entity.money) then 850 | if (localInventory) then 851 | ix.gui.vendorRemake:SetLocalMoney(LocalPlayer():GetCharacter():GetMoney()) 852 | end 853 | ix.gui.vendorRemake:SetVendorMoney(entity.money) 854 | end 855 | 856 | ix.gui.vendorRemakeEditor = vgui.Create("ixVendorRemakeEditor") 857 | end 858 | end) 859 | 860 | net.Receive("ixVendorRemakeMoney", function() 861 | local panel = ix.gui.vendorRemake 862 | 863 | if (!IsValid(panel)) then 864 | return 865 | end 866 | 867 | local entity = panel.entity 868 | 869 | if (!IsValid(entity)) then 870 | return 871 | end 872 | 873 | local value = net.ReadUInt(16) 874 | value = value != -1 and value or nil 875 | entity.money = value 876 | 877 | local editor = ix.gui.vendorRemakeEditor 878 | 879 | if (IsValid(editor)) then 880 | local useMoney = tonumber(value) != nil 881 | 882 | editor.money:SetDisabled(!useMoney) 883 | editor.money:SetEnabled(useMoney) 884 | editor.money:SetText(useMoney and value or "∞") 885 | end 886 | end) 887 | 888 | net.Receive("ixVendorRemakeStock", function() 889 | local panel = ix.gui.vendorRemake 890 | 891 | if (!IsValid(panel)) then 892 | return 893 | end 894 | 895 | local entity = panel.entity 896 | 897 | if (!IsValid(entity)) then 898 | return 899 | end 900 | 901 | local uniqueID = net.ReadString() 902 | local amount = net.ReadUInt(16) 903 | 904 | entity.items[uniqueID] = entity.items[uniqueID] or {} 905 | entity.items[uniqueID][VENDOR.STOCK] = amount 906 | 907 | local editor = ix.gui.vendorRemakeEditor 908 | 909 | if (IsValid(editor)) then 910 | local _, max = entity:GetStock(uniqueID) 911 | 912 | editor.lines[uniqueID]:SetValue(4, amount .. "/" .. max) 913 | end 914 | end) 915 | end 916 | 917 | properties.Add("vendor_remake_edit", { 918 | MenuLabel = "Edit Vendor", 919 | Order = 999, 920 | MenuIcon = "icon16/user_edit.png", 921 | 922 | Filter = function(self, entity, client) 923 | if (!IsValid(entity)) then return false end 924 | if (entity:GetClass() ~= "ix_vendor_new") then return false end 925 | if (!gamemode.Call( "CanProperty", client, "vendor_remake_edit", entity)) then return false end 926 | 927 | return CAMI.PlayerHasAccess(client, "Helix - Manage Vendors", nil) 928 | end, 929 | 930 | Action = function(self, entity) 931 | self:MsgStart() 932 | net.WriteEntity(entity) 933 | self:MsgEnd() 934 | end, 935 | 936 | Receive = function(self, length, client) 937 | local entity = net.ReadEntity() 938 | 939 | if (!IsValid(entity)) then return end 940 | if (!self:Filter(entity, client)) then return end 941 | 942 | local itemsTable = {} 943 | 944 | for k, v in pairs(entity.items) do 945 | if (!table.IsEmpty(v)) then 946 | itemsTable[k] = v 947 | end 948 | end 949 | 950 | -- Open Inventory 951 | local character = client:GetCharacter() 952 | if (character) then 953 | character:GetInventory():Sync(client, true) 954 | end 955 | 956 | entity:GetInventory():AddReceiver(client) 957 | entity.receivers[#entity.receivers + 1] = client 958 | client.ixOpenVendorRemake = entity 959 | entity:GetInventory():Sync(client) 960 | 961 | net.Start("ixVendorRemakeEditor") 962 | net.WriteEntity(entity) 963 | net.WriteUInt(entity.money or 0, 16) 964 | net.WriteTable(itemsTable) 965 | net.WriteFloat(entity.scale or 0.5) 966 | net.WriteTable(entity.messages) 967 | net.WriteTable(entity.factions) 968 | net.WriteTable(entity.classes) 969 | net.Send(client) 970 | end 971 | }) 972 | -------------------------------------------------------------------------------- /safebox/entities/entities/ix_safebox.lua: -------------------------------------------------------------------------------- 1 | ENT.Type = "anim" 2 | ENT.PrintName = "Safebox" 3 | ENT.Category = "Helix" 4 | ENT.Spawnable = true 5 | ENT.AdminOnly = true 6 | ENT.bNoPersist = true 7 | 8 | if (SERVER) then 9 | function ENT:Initialize() 10 | self:SetModel("models/props_junk/trashdumpster01a.mdl") 11 | self:PhysicsInit(SOLID_VPHYSICS) 12 | self:SetSolid(SOLID_VPHYSICS) 13 | self:SetUseType(SIMPLE_USE) 14 | 15 | local physObj = self:GetPhysicsObject() 16 | 17 | if (IsValid(physObj)) then 18 | physObj:EnableMotion(true) 19 | physObj:Wake() 20 | end 21 | end 22 | 23 | function ENT:Use(activator) 24 | if (CurTime() < (activator.ixNextOpen or 0)) then 25 | return 26 | end 27 | 28 | local openTime = ix.config.Get("safeboxOpenTime", 1) 29 | 30 | ix.safebox.Restore(activator, function() 31 | if (openTime > 0) then 32 | activator:SetAction("@storageSearching", openTime) 33 | activator:DoStaredAction(self, function() 34 | if (IsValid(activator) and activator:Alive()) then 35 | net.Start("ixSafeboxOpen") 36 | net.Send(activator) 37 | end 38 | end, openTime, function() 39 | if (IsValid(activator)) then 40 | activator:SetAction() 41 | end 42 | end) 43 | else 44 | net.Start("ixSafeboxOpen") 45 | net.Send(activator) 46 | end 47 | end) 48 | 49 | activator.ixNextOpen = CurTime() + 1 50 | end 51 | else 52 | ENT.PopulateEntityInfo = true 53 | 54 | function ENT:OnPopulateEntityInfo(tooltip) 55 | local title = tooltip:AddRow("name") 56 | title:SetImportant() 57 | title:SetText(self.PrintName) 58 | title:SetBackgroundColor(ix.config.Get("color")) 59 | title:SizeToContents() 60 | 61 | local description = tooltip:AddRow("description") 62 | description:SetText("It can permanently hold stuff.") 63 | description:SizeToContents() 64 | end 65 | end -------------------------------------------------------------------------------- /safebox/sh_plugin.lua: -------------------------------------------------------------------------------- 1 | PLUGIN.name = "Safebox" 2 | PLUGIN.author = "STEAM_0:1:29606990" 3 | PLUGIN.description = "Personal storage of items for players." 4 | 5 | ix.config.Add("safeInvWidth", 5, "How many slots in a row there is in a safebox inventory.", nil, { 6 | data = {min = 0, max = 20}, 7 | category = PLUGIN.name 8 | }) 9 | 10 | ix.config.Add("safeInvHeight", 5, "How many slots in a column there is in a safebox inventory.", nil, { 11 | data = {min = 0, max = 20}, 12 | category = PLUGIN.name 13 | }) 14 | 15 | ix.config.Add("safeboxOpenTime", 0.5, "How long it takes to open a safebox.", nil, { 16 | data = {min = 0, max = 50, decimals = 1}, 17 | category = PLUGIN.name 18 | }) 19 | 20 | ix.config.Add("safeEnableMoney", true, "Allow money transfer.", nil, { 21 | category = PLUGIN.name 22 | }) 23 | 24 | ix.safebox = ix.safebox or {} 25 | ix.util.Include("sv_plugin.lua") 26 | 27 | function PLUGIN:InitializedPlugins() 28 | ix.inventory.Register("safebox", ix.config.Get("safeInvWidth"), ix.config.Get("safeInvHeight")) 29 | end 30 | 31 | if (CLIENT) then 32 | net.Receive("ixSafeboxOpen", function() 33 | if (IsValid(ix.gui.menu)) then 34 | return 35 | end 36 | 37 | local client = LocalPlayer() 38 | local character = client:GetCharacter() 39 | 40 | if (!character) then 41 | return 42 | end 43 | 44 | local index = character:GetData("safeboxID") 45 | local inventory = ix.inventory.Get(index) 46 | 47 | if (inventory and inventory.slots) then 48 | local localInventory = character:GetInventory() 49 | local panel = vgui.Create("ixStorageView") 50 | 51 | local allowMoney = ix.config.Get("safeEnableMoney") 52 | 53 | if (localInventory) then 54 | panel:SetLocalInventory(localInventory) 55 | 56 | if (allowMoney) then 57 | panel:SetLocalMoney(character:GetMoney()) 58 | end 59 | end 60 | 61 | panel:SetStorageID(index) 62 | panel:SetStorageInventory(inventory) 63 | 64 | if (allowMoney) then 65 | panel:SetStorageMoney(character:GetData("safeboxMoney", 0)) 66 | 67 | panel.storageMoney.OnTransfer = function(_, amount) 68 | net.Start("ixSafeboxMoneyTake") 69 | net.WriteUInt(amount, 32) 70 | net.SendToServer() 71 | end 72 | 73 | panel.localMoney.OnTransfer = function(_, amount) 74 | net.Start("ixStorageMoneyGive") 75 | net.WriteUInt(amount, 32) 76 | net.SendToServer() 77 | end 78 | 79 | panel.Think = function(this) 80 | local money = character:GetMoney() 81 | 82 | if (this.localMoney:GetMoney() ~= money) then 83 | this.localMoney:SetMoney(money) 84 | end 85 | 86 | money = character:GetData("safeboxMoney", 0) 87 | 88 | if (this.storageMoney:GetMoney() ~= money) then 89 | this.storageMoney:SetMoney(money) 90 | end 91 | end 92 | end 93 | end 94 | end) 95 | end -------------------------------------------------------------------------------- /safebox/sv_plugin.lua: -------------------------------------------------------------------------------- 1 | util.AddNetworkString("ixSafeboxOpen") 2 | util.AddNetworkString("ixSafeboxMoneyTake") 3 | util.AddNetworkString("ixSafeboxMoneyGive") 4 | 5 | function PLUGIN:PlayerLoadedCharacter(client) 6 | ix.safebox.Restore(client) 7 | end 8 | 9 | function PLUGIN:SaveData() 10 | local data = {} 11 | 12 | for _, v in ipairs(ents.FindByClass("ix_safebox")) do 13 | local motion = v:GetPhysicsObject() 14 | 15 | if (IsValid(motion)) then 16 | motion = motion:IsMotionEnabled() 17 | end 18 | 19 | data[#data + 1] = { v:GetPos(), v:GetAngles(), v:GetModel(), motion } 20 | end 21 | 22 | self:SetData(data) 23 | data = nil 24 | end 25 | 26 | function PLUGIN:LoadData() 27 | local data = self:GetData() 28 | 29 | if (data) then 30 | for _, v in ipairs(data) do 31 | local entity = ents.Create("ix_safebox") 32 | entity:SetPos(v[1]) 33 | entity:SetAngles(v[2]) 34 | entity:Spawn() 35 | entity:SetModel(v[3]) 36 | entity:SetSolid(SOLID_VPHYSICS) 37 | entity:PhysicsInit(SOLID_VPHYSICS) 38 | 39 | local physObject = entity:GetPhysicsObject() 40 | 41 | if (IsValid(physObject)) then 42 | if (v[4] == false) then 43 | physObject:EnableMotion(false) 44 | physObject:Sleep() 45 | else 46 | physObject:EnableMotion(true) 47 | end 48 | end 49 | end 50 | end 51 | 52 | data = nil 53 | end 54 | 55 | function ix.safebox.Restore(client, callback) 56 | local character = client:GetCharacter() 57 | 58 | if (!character) then 59 | return 60 | end 61 | 62 | local index = character:GetData("safeboxID") 63 | local characterID = character:GetID() 64 | 65 | if (index) then 66 | local inventory = ix.inventory.Get(index) 67 | 68 | if (inventory) then 69 | inventory:Sync(client) 70 | inventory:AddReceiver(client) 71 | 72 | if (callback) then 73 | callback() 74 | end 75 | else 76 | local invType = ix.item.inventoryTypes["safebox"] 77 | ix.inventory.Restore(index, invType.w, invType.h, function(inv) 78 | inv:SetOwner(characterID) 79 | end) 80 | end 81 | else 82 | ix.inventory.New(characterID, "safebox", function(inv) 83 | character:SetData("safeboxID", inv:GetID()) 84 | end) 85 | end 86 | end 87 | 88 | net.Receive("ixSafeboxMoneyTake", function(length, client) 89 | if (!ix.config.Get("safeEnableMoney") or CurTime() < (client.ixSafeboxMoneyTimer or 0)) then 90 | return 91 | end 92 | 93 | local character = client:GetCharacter() 94 | 95 | if (!character) then 96 | return 97 | end 98 | 99 | local index = character:GetData("safeboxID") 100 | local inventory = ix.inventory.Get(index) 101 | 102 | if (!inventory) then 103 | return 104 | end 105 | 106 | local safeboxMoney = character:GetData("safeboxMoney", 0) 107 | local amount = net.ReadUInt(32) 108 | amount = math.Clamp(math.Round(tonumber(amount) or 0), 0, safeboxMoney) 109 | 110 | if (amount == 0) then 111 | return 112 | end 113 | 114 | character:SetMoney(character:GetMoney() + amount) 115 | 116 | local total = safeboxMoney - amount 117 | character:SetData("safeboxMoney", total) 118 | 119 | client.ixSafeboxMoneyTimer = CurTime() + 0.5 120 | end) 121 | 122 | net.Receive("ixStorageMoneyGive", function(length, client) 123 | if (!ix.config.Get("safeEnableMoney") or CurTime() < (client.ixSafeboxMoneyTimer or 0)) then 124 | return 125 | end 126 | 127 | local character = client:GetCharacter() 128 | 129 | if (!character) then 130 | return 131 | end 132 | 133 | local index = character:GetData("safeboxID") 134 | local inventory = ix.inventory.Get(index) 135 | 136 | if (!inventory) then 137 | return 138 | end 139 | 140 | local amount = net.ReadUInt(32) 141 | amount = math.Clamp(math.Round(tonumber(amount) or 0), 0, character:GetMoney()) 142 | 143 | if (amount == 0) then 144 | return 145 | end 146 | 147 | character:SetMoney(character:GetMoney() - amount) 148 | 149 | local safeboxMoney = character:GetData("safeboxMoney", 0) 150 | local total = safeboxMoney + amount 151 | character:SetData("safeboxMoney", total) 152 | 153 | client.ixSafeboxMoneyTimer = CurTime() + 0.5 154 | end) -------------------------------------------------------------------------------- /unload_mags/sh_plugin.lua: -------------------------------------------------------------------------------- 1 | PLUGIN.name = "Unload mags" 2 | PLUGIN.author = "STEAM_0:1:29606990" 3 | PLUGIN.desc = "Unload mags for weapons." 4 | 5 | ix.lang.AddTable("russian", { 6 | ['Unload mags'] = "Разгрузить обойму" 7 | }) 8 | 9 | local cache_ammo = {} 10 | 11 | function PLUGIN:InitializedPlugins() 12 | for k, v in pairs(ix.item.list) do 13 | if v.ammo and v.ammoAmount then 14 | -- On player uneqipped the item, Removes a weapon from the player and keep the ammo in the item. 15 | v.functions.use = { -- sorry, for name order. 16 | name = "Load", 17 | tip = "useTip", 18 | icon = "icon16/add.png", 19 | OnRun = function(item) 20 | local ammo = item:GetData('mags_ammo', item.ammoAmount) 21 | if ammo < 1 then 22 | return true 23 | end 24 | 25 | item.player:GiveAmmo(ammo, item.ammo) 26 | item.player:EmitSound("items/ammo_pickup.wav", 110) 27 | ammo = nil 28 | 29 | return true 30 | end, 31 | } 32 | 33 | function v:OnInstanced(invID, x, y, item) 34 | if item.data and item.data.mags_ammo then 35 | item:SetData('mags_ammo', item.data.mags_ammo) 36 | end 37 | end 38 | 39 | if CLIENT then 40 | function v:PaintOver(item, w, h) 41 | draw.SimpleText(item:GetData('mags_ammo', item.ammoAmount), "DermaDefault",w - 5, h - 5, color_white, TEXT_ALIGN_RIGHT, TEXT_ALIGN_BOTTOM, 1, color_black) 42 | end 43 | 44 | function v:GetDescription() 45 | return Format(self.description, self:GetData('mags_ammo', self.ammoAmount)) 46 | end 47 | end 48 | elseif v.isWeapon and not v.isGrenade then 49 | v.functions.unloadAmmo = { 50 | name = "Unload mags", 51 | tip = "unloadAmmoTip", 52 | icon = "icon16/bullet_wrench.png", 53 | OnRun = function(item) 54 | local client = item.player 55 | client.carryWeapons = client.carryWeapons or {} 56 | 57 | local weapon = client.carryWeapons[item.weaponCategory] 58 | if (!IsValid(weapon)) then 59 | weapon = client:GetWeapon(item.class) 60 | end 61 | 62 | if (IsValid(weapon) and weapon:Clip1() > 0) then 63 | local char = client:GetCharacter() 64 | if not char then return false end 65 | 66 | local itemID = item.AmmoID 67 | 68 | if not itemID then 69 | local ammoName = game.GetAmmoName(weapon:GetPrimaryAmmoType()) 70 | if not ammoName or ammoName == "" then return false end 71 | 72 | itemID = cache_ammo[ammoName] 73 | 74 | if not itemID then 75 | for k, v in pairs(ix.item.list) do 76 | if not v.ammo then continue end 77 | if v.ammo:lower() == ammoName:lower() then 78 | itemID = k 79 | cache_ammo[ammoName] = itemID 80 | break 81 | end 82 | end 83 | end 84 | 85 | ammoName = nil 86 | end 87 | 88 | if itemID then 89 | item:SetData('ammo', nil) 90 | local ammo = weapon:Clip1() 91 | weapon:SetClip1(0) 92 | 93 | local tbl = {mags_ammo = ammo} 94 | if (!char:GetInventory():Add(itemID, nil, tbl)) then 95 | ix.item.Spawn(itemID, client, nil, nil, tbl) 96 | end 97 | 98 | tbl, ammo, itemID = nil, nil, nil 99 | end 100 | 101 | char = nil 102 | end 103 | 104 | weapon, client = nil, nil 105 | 106 | return false 107 | end, 108 | OnCanRun = function(item) 109 | local client = item.player 110 | client.carryWeapons = client.carryWeapons or {} 111 | 112 | local weapon = client.carryWeapons[item.weaponCategory] 113 | if (!IsValid(weapon)) then 114 | weapon = client:GetWeapon(item.class) 115 | end 116 | 117 | return not IsValid(item.entity) and IsValid(client) and item:GetData("equip") == true and item.invID == client:GetCharacter():GetInventory():GetID() 118 | and item.isWeapon and not item.isGrenade and IsValid(weapon) and weapon:Clip1() > 0 119 | end 120 | } 121 | end 122 | end 123 | end 124 | --------------------------------------------------------------------------------