Guest User

error in sound

a guest
May 27th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 51.72 KB | None | 0 0
  1. <?xml version="1.0" encoding="iso-8859-1"?>
  2. <!DOCTYPE muclient>
  3.  
  4. <muclient>
  5. <plugin
  6. name="Aardwolf_Soundpack"
  7. author="Pwar"
  8. id="23832d1089f727f5f34abad8"
  9. language="Lua"
  10. purpose="Provide customizable comm and event sounds/triggers"
  11. date_written="2017-12-2 13:00:25"
  12. requires="4.76"
  13. version="1.1"
  14. save_state="y"
  15. >
  16. <description trim="y">
  17. <![CDATA[
  18.  
  19. > spset
  20. - Display events, their current volume, wav file, panning option and description
  21.  
  22. > spset [event]
  23. - display current saved settings for specified event
  24.  
  25. > spset [event] volume [0-100]
  26. - sets volume for specific event, 0 disables event completely, 100 is full volume
  27.  
  28. > spset [event] panning [-100 to 100]
  29. - sets panning 0 is both speakers , -100 full left speaker, 100 is full right speaker
  30.  
  31. > spset [event] wav filename.wav
  32. - sets a custom wav for this event, it can be located in either mushclient/sounds
  33. or your mushclient/sounds/saved folder
  34.  
  35. > spset [event] wav default
  36. - this will reset your event to its default wav
  37.  
  38. > sptog [event]
  39. - toggles an event off and on (0 and 100 volume)
  40.  
  41. > sptog all
  42. - toggles all events that are off to on, and vice versa
  43.  
  44. > spmute
  45. - toggles soundpack mute off and on
  46.  
  47. > spvol [0-100]
  48. - sets a global volume max percentage
  49.  
  50. > spallow
  51. - allows remotes sounds from player who sent the last
  52.  
  53. > spdeny [player]
  54. - stop accepting remote sounds from player on your allow list
  55.  
  56. Any message you send with !!SOUND(http://urlto/file.wav)
  57. will be played to yourself and others with the plugin installed.
  58.  
  59. If you want to play a file in your sounds or sounds/saved folder
  60. Simply !!SOUND(filename.wav) but both players must have the same filename!
  61.  
  62.  
  63. > sphelp
  64. - display only this help
  65.  
  66.  
  67. ]]>
  68. </description>
  69.  
  70. </plugin>
  71.  
  72. <aliases>
  73. <alias
  74. match="^spset (?<event>.+?) (?<setting>.+?) (?<value>.+?)$"
  75. script="spset"
  76. enabled="y"
  77. sequence="100"
  78. regexp="y"
  79. >
  80. </alias>
  81. <alias
  82. match="^spset (?<event>.+?)$"
  83. script="spset"
  84. enabled="y"
  85. sequence="100"
  86. regexp="y"
  87. >
  88. </alias>
  89. <alias
  90. match="^spsetvol (?<event>.+?)$"
  91. script="spsetvol"
  92. enabled="y"
  93. sequence="100"
  94. regexp="y"
  95. >
  96. </alias>
  97. <alias
  98. match="^spset?$"
  99. script="spset"
  100. enabled="y"
  101. sequence="100"
  102. regexp="y"
  103. >
  104. </alias>
  105. <alias
  106. name="spmute"
  107. match="^spmute$"
  108. script="spmute"
  109. enabled="y"
  110. sequence="100"
  111. regexp="y"
  112. >
  113. </alias>
  114. <alias
  115. match="^sphelp$"
  116. script="sphelp"
  117. enabled="y"
  118. sequence="100"
  119. regexp="y"
  120. >
  121. </alias>
  122. <alias
  123. match="^spdebug$"
  124. script="spdebug"
  125. enabled="y"
  126. sequence="100"
  127. regexp="y"
  128. >
  129. </alias>
  130. <alias
  131. match="^spvol(\s)(?<value>.+?)$"
  132. script="spvol"
  133. enabled="y"
  134. sequence="100"
  135. regexp="y"
  136. >
  137. </alias>
  138. <alias
  139. match="^sptog(\s)(?<event>.+?)$"
  140. script="sptog"
  141. enabled="y"
  142. sequence="100"
  143. regexp="y"
  144. >
  145. </alias>
  146. <alias
  147. match="^sptog$"
  148. script="sptog"
  149. enabled="y"
  150. sequence="100"
  151. regexp="y"
  152. >
  153. </alias>
  154. <alias
  155. match="^spallow$"
  156. script="spallow"
  157. enabled="y"
  158. sequence="100"
  159. regexp="y"
  160. >
  161. </alias>
  162. <alias
  163. match="^spdeny\s(.+)$"
  164. script="spdeny"
  165. enabled="y"
  166. sequence="100"
  167. regexp="y"
  168. >
  169. </alias>
  170. <alias
  171. match="^spdeny$"
  172. script="spdeny"
  173. enabled="y"
  174. sequence="100"
  175. regexp="y"
  176. >
  177. </alias>
  178. <alias
  179. match="^spvol$"
  180. script="spvol"
  181. enabled="y"
  182. sequence="100"
  183. regexp="y"
  184. >
  185. </alias>
  186. <alias
  187. match="^savesound(\s)(?<wav>.+?)$"
  188. script="save_sound"
  189. enabled="y"
  190. sequence="100"
  191. regexp="y"
  192. >
  193. </alias>
  194. <alias
  195. match="^savesound$"
  196. script="save_sound"
  197. enabled="y"
  198. sequence="100"
  199. regexp="y"
  200. >
  201. </alias>
  202.  
  203. <alias
  204. match="^(.+)!!SOUND\((?<url>.+?)\)"
  205. script="parse_input_rsound"
  206. enabled="y"
  207. sequence="99"
  208. regexp="y"
  209. >
  210. </alias>
  211.  
  212. </aliases>
  213. <triggers>
  214.  
  215. <trigger
  216. enabled="n"
  217. group="Alert"
  218. match="^INFO: Bonus experience has now expired.$"
  219. regexp="y"
  220. send_to="12"
  221. keep_evaluating="n"
  222. sequence="99"
  223. >
  224. <send>
  225. TriggerEvent("double_end")
  226. </send>
  227. </trigger>
  228.  
  229. <trigger
  230. enabled="n"
  231. group="Alert"
  232. match="^INFO: New post (.+) in forum Personal from (.+)$"
  233. regexp="y"
  234. send_to="12"
  235. keep_evaluating="n"
  236. sequence="99"
  237. >
  238. <send>
  239. TriggerEvent("personal_note")
  240. </send>
  241. </trigger>
  242.  
  243. <trigger
  244. enabled="n"
  245. group="Alert"
  246. match="^You were the first to complete this quest!$"
  247. regexp="y"
  248. send_to="12"
  249. keep_evaluating="n"
  250. sequence="99"
  251. >
  252. <send>
  253. TriggerEvent("gq_win")
  254. </send>
  255. </trigger>
  256.  
  257. <trigger
  258. enabled="n"
  259. group="Alert"
  260. match="^INFO: .+$"
  261. regexp="y"
  262. send_to="12"
  263. sequence="100"
  264. >
  265. <send>
  266. TriggerEvent("info")
  267. </send>
  268. </trigger>
  269.  
  270. <trigger
  271. enabled="n"
  272. group="Alert"
  273. match="^For the next 15 minutes experience is doubled in honor of the new superhero.$"
  274. regexp="y"
  275. send_to="12"
  276. sequence="100"
  277. >
  278. <send>
  279. TriggerEvent("double_exp")
  280. </send>
  281. </trigger>
  282.  
  283. <trigger
  284. enabled="n"
  285. group="Alert"
  286. match="^\[(.+)10 minutes of double exp started courtesy of (.+)\]$"
  287. regexp="y"
  288. send_to="12"
  289. sequence="100"
  290. >
  291. <send>
  292. TriggerEvent("double_exp")
  293. </send>
  294. </trigger>
  295.  
  296. <trigger
  297. enabled="n"
  298. group="Alert"
  299. match="^Double experience for 10 minutes courtesy of (.+) daily blessing.$"
  300. regexp="y"
  301. send_to="12"
  302. sequence="100"
  303. >
  304. <send>
  305. TriggerEvent("double_exp")
  306. </send>
  307. </trigger>
  308.  
  309. <trigger
  310. enabled="n"
  311. group="Alert"
  312. match="^Double experience for 10 minutes courtesy of (.+).$"
  313. regexp="y"
  314. send_to="12"
  315. sequence="100"
  316. >
  317. <send>
  318. TriggerEvent("double_exp")
  319. </send>
  320. </trigger>
  321.  
  322. <trigger
  323. enabled="n"
  324. group="Alert"
  325. match="^Aardwolf rejoices in the death of another MILLION monsters.$"
  326. regexp="y"
  327. send_to="12"
  328. sequence="100"
  329. >
  330. <send>
  331. TriggerEvent("double_exp")
  332. </send>
  333. </trigger>
  334.  
  335. <trigger
  336. enabled="n"
  337. group="Alert"
  338. match="^WARFARE: Type \'combat\' to join the war. No death penalties!$"
  339. regexp="y"
  340. send_to="12"
  341. sequence="100"
  342. >
  343. <send>
  344. TriggerEvent("warfare")
  345. </send>
  346. </trigger>
  347.  
  348. <trigger
  349. enabled="n"
  350. group="Alert"
  351. match="^Restore: .+$"
  352. regexp="y"
  353. send_to="12"
  354. sequence="100"
  355. >
  356. <send>
  357. TriggerEvent("restore")
  358. </send>
  359. </trigger>
  360.  
  361. <trigger
  362. enabled="n"
  363. group="Alert"
  364. match="^Remort Auction: .+$"
  365. regexp="y"
  366. send_to="12"
  367. sequence="100"
  368. >
  369. <send>
  370. TriggerEvent("rauction")
  371. </send>
  372. </trigger>
  373.  
  374. <trigger
  375. enabled="n"
  376. group="Alert"
  377. match="^.+\[QUEST\]$"
  378. name="QuestTargetFound"
  379. regexp="y"
  380. send_to="12"
  381. sequence="100"
  382. >
  383. <send>
  384. TriggerEvent("quest_target_found")
  385. </send>
  386. </trigger>
  387.  
  388. <trigger
  389. enabled="n"
  390. group="Alert"
  391. match="(.+)?Andolor's very own \(Aarchaeology\) Professor is here, studying\.$"
  392. name="AarchProfFound"
  393. regexp="y"
  394. send_to="12"
  395. sequence="100"
  396. >
  397. <send>
  398. TriggerEvent("aarch_prof")
  399. </send>
  400. </trigger>
  401.  
  402. <trigger
  403. enabled="n"
  404. group="Alert"
  405. match="^QUEST: You have run out of time for your quest!$"
  406. name="QuestTimeFail"
  407. regexp="y"
  408. send_to="12"
  409. sequence="100"
  410. >
  411. <send>
  412. TriggerEvent("quest_warning")
  413. </send>
  414. </trigger>
  415.  
  416. <trigger
  417. enabled="n"
  418. group="Alert"
  419. match="^You feel as if you are being watched.$"
  420. name="Scry"
  421. regexp="y"
  422. send_to="12"
  423. sequence="100"
  424. >
  425. <send>
  426. TriggerEvent("scry")
  427. </send>
  428. </trigger>
  429.  
  430. <trigger
  431. enabled="n"
  432. group="Alert"
  433. match="^You sense that (.+) is scrying you.$"
  434. name="ScryWish"
  435. regexp="y"
  436. send_to="12"
  437. sequence="100"
  438. >
  439. <send>
  440. TriggerEvent("scry")
  441. </send>
  442. </trigger>
  443.  
  444. <trigger
  445. enabled="n"
  446. group="Alert"
  447. match="^\*\* You can take revenge on (.+) for 15 minutes.$"
  448. name="PKAlert"
  449. regexp="y"
  450. send_to="12"
  451. sequence="100"
  452. >
  453. <send>
  454. TriggerEvent("scry")
  455. </send>
  456. </trigger>
  457. <trigger
  458. enabled="n"
  459. group="Alert"
  460. match="^You raise a level! You are now level (.+)\.$"
  461. name="LevelUp"
  462. regexp="y"
  463. send_to="12"
  464. sequence="100"
  465. >
  466. <send>
  467. TriggerEvent("level_up")
  468. </send>
  469. </trigger>
  470. <trigger
  471. enabled="n"
  472. group="Alert"
  473. match="^Congratulations, hero\. You have increased your powers\!$"
  474. name="PowerUp"
  475. regexp="y"
  476. send_to="12"
  477. sequence="100"
  478. >
  479. <send>
  480. TriggerEvent("level_up")
  481. </send>
  482. </trigger>
  483. <trigger
  484. enabled="n"
  485. group="Alert"
  486. match="^You die.$"
  487. name="SelfDeath"
  488. regexp="y"
  489. send_to="12"
  490. sequence="100"
  491. >
  492. <send>
  493. TriggerEvent("death")
  494. </send>
  495. </trigger>
  496. <trigger
  497. enabled="n"
  498. group="Alert"
  499. match="^Congratulations! You are now a superhero!(.+)$"
  500. name="LevelUpSh"
  501. regexp="y"
  502. send_to="12"
  503. sequence="100"
  504. >
  505. <send>
  506. TriggerEvent("level_up_sh")
  507. </send>
  508. </trigger>
  509.  
  510. <trigger
  511. enabled="n"
  512. group="Alert"
  513. match="^You ring the bell and hope that someone inside hears you\.$"
  514. name="Doorbell1"
  515. regexp="y"
  516. send_to="12"
  517. sequence="100"
  518. >
  519. <send>
  520. TriggerEvent("manor_doorbell")
  521. </send>
  522. </trigger>
  523. <trigger
  524. enabled="n"
  525. group="Alert"
  526. match="^(.+) is outside ringing the bell!$"
  527. name="Doorbell2"
  528. regexp="y"
  529. send_to="12"
  530. sequence="100"
  531. >
  532. <send>
  533. TriggerEvent("manor_doorbell")
  534. </send>
  535. </trigger>
  536. <trigger
  537. enabled="n"
  538. group="Alert"
  539. match="^You start to follow (.+)\.$"
  540. name="Follow"
  541. regexp="y"
  542. send_to="12"
  543. sequence="100"
  544. >
  545. <send>
  546. TriggerEvent("follow")
  547. </send>
  548. </trigger>
  549. <trigger
  550. enabled="n"
  551. group="Alert"
  552. match="^You stop following (.+)\.$"
  553. name="StopFollow"
  554. regexp="y"
  555. send_to="12"
  556. sequence="100"
  557. >
  558. <send>
  559. TriggerEvent("stop_follow")
  560. </send>
  561. </trigger>
  562. <trigger
  563. enabled="n"
  564. group="Alert"
  565. match="^(.+) starts to follow you\.$"
  566. name="Follow2"
  567. regexp="y"
  568. send_to="12"
  569. sequence="100"
  570. >
  571. <send>
  572. TriggerEvent("follow")
  573. </send>
  574. </trigger>
  575. <trigger
  576. enabled="n"
  577. group="Alert"
  578. match="^(.+) stops following you\.$"
  579. name="StopFollow2"
  580. regexp="y"
  581. send_to="12"
  582. sequence="100"
  583. >
  584. <send>
  585. TriggerEvent("stop_follow")
  586. </send>
  587. </trigger>
  588. <trigger
  589. enabled="n"
  590. group="Alert"
  591. match="^(.+) has invited you to join group: (.+)\.$"
  592. name="GroupInvited"
  593. regexp="y"
  594. send_to="12"
  595. sequence="100"
  596. >
  597. <send>
  598. TriggerEvent("gtell")
  599. </send>
  600. </trigger>
  601. <trigger
  602. enabled="n"
  603. group="Alert"
  604. match="^You have removed yourself from group: (.+)$"
  605. name="GroupRemoved"
  606. regexp="y"
  607. send_to="12"
  608. sequence="100"
  609. >
  610. <send>
  611. TriggerEvent("gtell")
  612. </send>
  613. </trigger>
  614. <trigger
  615. enabled="n"
  616. group="Alert"
  617. match="^(.+) has kicked you from the group\.$"
  618. name="GroupRemoved2"
  619. regexp="y"
  620. send_to="12"
  621. sequence="100"
  622. >
  623. <send>
  624. TriggerEvent("gtell")
  625. </send>
  626. </trigger>
  627. <trigger
  628. enabled="n"
  629. group="Alert"
  630. match="\[CP\]$"
  631. name="quest_target_found2"
  632. regexp="y"
  633. send_to="12"
  634. sequence="100"
  635. >
  636. <send>
  637. TriggerEvent("quest_target_found")
  638. </send>
  639. </trigger>
  640.  
  641. <trigger
  642. enabled="n"
  643. group="Alert"
  644. match="^Turning OFF the (.+) channel\.$"
  645. name="ChannelOff"
  646. regexp="y"
  647. send_to="12"
  648. sequence="100"
  649. >
  650. <send>
  651. TriggerEvent("channel_off")
  652. </send>
  653. </trigger>
  654.  
  655. <trigger
  656. enabled="n"
  657. group="Alert"
  658. match="^Channel (.+) will turn back on in (.*).$"
  659. name="ChannelOff2"
  660. regexp="y"
  661. send_to="12"
  662. sequence="100"
  663. >
  664. <send>
  665. TriggerEvent("channel_off")
  666. </send>
  667. </trigger>
  668.  
  669. <trigger
  670. enabled="n"
  671. group="Alert"
  672. match="^Turning ON the (.+) channel\.$"
  673. name="ChannelOn"
  674. regexp="y"
  675. send_to="12"
  676. sequence="100"
  677. >
  678. <send>
  679. TriggerEvent("channel_on")
  680. </send>
  681. </trigger>
  682.  
  683. <trigger
  684. enabled="n"
  685. group="Alert"
  686. match="^Removing timeout and turning ON the (.*) channel.$"
  687. name="ChannelOn2"
  688. regexp="y"
  689. send_to="12"
  690. sequence="100"
  691. >
  692. <send>
  693. TriggerEvent("channel_on")
  694. </send>
  695. </trigger>
  696.  
  697. <trigger
  698. enabled="n"
  699. group="Alert"
  700. match="^You find an \(Aarchaeology\) piece hidden in the corpse!$"
  701. name="AarchFind"
  702. regexp="y"
  703. send_to="12"
  704. sequence="100"
  705. >
  706. <send>
  707. TriggerEvent("special_find")
  708. </send>
  709. </trigger>
  710.  
  711. <trigger
  712. enabled="n"
  713. group="Alert"
  714. match="^You find a \|P\[Poker Card\]P\| special item hidden in the corpse!$"
  715. name="PokerCardFind"
  716. regexp="y"
  717. send_to="12"
  718. sequence="100"
  719. >
  720. <send>
  721. TriggerEvent("special_find")
  722. </send>
  723. </trigger>
  724.  
  725. <trigger
  726. enabled="n"
  727. group="Alert"
  728. match="^You get AardWords \(TM\) - (.+) from the (.+) corpse of (.+).$"
  729. name="AardWordsFind"
  730. regexp="y"
  731. send_to="12"
  732. sequence="100"
  733. >
  734. <send>
  735. TriggerEvent("special_find")
  736. </send>
  737. </trigger>
  738.  
  739. <trigger
  740. enabled="n"
  741. group="Alert"
  742. match="^\*\* You gain a bonus trivia point! \*\*$"
  743. name="TriviaPoint1"
  744. regexp="y"
  745. send_to="12"
  746. sequence="100"
  747. >
  748. <send>
  749. TriggerEvent("special_find")
  750. </send>
  751. </trigger>
  752.  
  753. <trigger
  754. enabled="n"
  755. group="Alert"
  756. match="^You killed a Trivia Point bonus mob\!\! Trivia point added\.$"
  757. name="TriviaPoint2"
  758. regexp="y"
  759. send_to="12"
  760. sequence="100"
  761. >
  762. <send>
  763. TriggerEvent("special_find")
  764. </send>
  765. </trigger>
  766.  
  767. <trigger
  768. enabled="n"
  769. group="Alert"
  770. match="^You get \((.+)\) (.+) from (.+) corpse of (.+)\.$"
  771. script="found_bonusitem"
  772. name="BonusItem"
  773. regexp="y"
  774. send_to="12"
  775. sequence="100"
  776. >
  777. </trigger>
  778.  
  779. <trigger
  780. enabled="n"
  781. group="Alert"
  782. match="^(.+) crumbles into (.*) gold pieces\.$"
  783. name="Crumble"
  784. regexp="y"
  785. send_to="12"
  786. sequence="100"
  787. >
  788. <send>
  789. local amount = string.gsub("%2", ",", "")
  790.  
  791. -- make sure it's worth playing a sound for! 100k and higher!
  792. if tonumber(amount) >= 100000 then
  793. TriggerEvent("special_find")
  794. end
  795. </send>
  796. </trigger>
  797.  
  798. <trigger
  799. enabled="n"
  800. group="Alert"
  801. match="^Channel timeout on (.*) has expired. Turning channel on.$"
  802. name="ChannelOn3"
  803. regexp="y"
  804. send_to="12"
  805. sequence="100"
  806. >
  807. <send>
  808. TriggerEvent("channel_on")
  809. </send>
  810. </trigger>
  811. <trigger
  812. enabled="n"
  813. group="Alert"
  814. match="^Congratulations\, that was one of your CAMPAIGN mobs\!$"
  815. name="CpMobDead"
  816. regexp="y"
  817. send_to="12"
  818. sequence="100"
  819. >
  820. <send>
  821. TriggerEvent("cp_mob_dead")
  822. </send>
  823. </trigger>
  824.  
  825. <trigger
  826. enabled="n"
  827. group="Alert"
  828. match="^Congratulations\, that was one of the GLOBAL QUEST mobs\!$"
  829. name="GqMobDead"
  830. regexp="y"
  831. send_to="12"
  832. sequence="100"
  833. >
  834. <send>
  835. TriggerEvent("gq_mob_dead")
  836. </send>
  837. </trigger>
  838.  
  839. <trigger
  840. enabled="n"
  841. group="Alert"
  842. match="^Global Quest: Global quest # (.*) has been declared(.*)$"
  843. name="GqDeclared"
  844. regexp="y"
  845. send_to="12"
  846. sequence="100"
  847. >
  848. <send>
  849. TriggerEvent("gquest_declare")
  850. </send>
  851. </trigger>
  852. <trigger
  853. enabled="n"
  854. group="Alert"
  855. match="^Global Quest: Global quest # (.*) for levels (.*) has now started.$"
  856. name="GqStarted"
  857. regexp="y"
  858. send_to="12"
  859. sequence="100"
  860. >
  861. <send>
  862. TriggerEvent("gquest_start")
  863. </send>
  864. </trigger>
  865. </triggers>
  866. <script>
  867. <![CDATA[
  868. local sp_version = "1.1.2"
  869. local sp_last_download
  870. local sp_global_volume = 100
  871. local sp_mute_toggle = "1"
  872. local rsound_accept = {}
  873. local rsound = {}
  874. local self = {}
  875. local sp_debug = "0"
  876.  
  877. local async = require "async"
  878. require "gmcphelper"
  879. require "serialize" -- serialize tables to strings
  880. dofile (GetInfo(60) .. "aardwolf_colors.lua")
  881.  
  882. local soundEvents = {
  883. ["zone_repop"] = {
  884. defaultwav = "zone_repop.wav",
  885. volume = "100",
  886. panning = "0",
  887. description = "Zone repops (respawns)"
  888. },
  889. ["info"] = {
  890. defaultwav = "info.wav",
  891. volume = "100",
  892. panning = "0",
  893. description = "Info messages"
  894. },
  895. ["personal_note"] = {
  896. defaultwav = "personal_note.wav",
  897. volume = "100",
  898. panning = "0",
  899. description = "Personal note received"
  900. },
  901. ["gq_win"] = {
  902. defaultwav = "gq_win.wav",
  903. volume = "100",
  904. panning = "0",
  905. description = "Global quest won"
  906. },
  907. ["special_find"] = {
  908. defaultwav = "special_find.wav",
  909. volume = "100",
  910. panning = "0",
  911. description = "Aarchaelogy or AardWords item"
  912. },
  913. ["bonus_item"] = {
  914. defaultwav = "bonus_item.wav",
  915. volume = "100",
  916. panning = "0",
  917. description = "Looted a bonus item with enhanced stats"
  918. },
  919. ["manor_doorbell"] = {
  920. defaultwav = "manor_doorbell.wav",
  921. volume = "100",
  922. panning = "0",
  923. description = "Doorbells for ring bell at manor"
  924. },
  925. ["follow"] = {
  926. defaultwav = "follow.wav",
  927. volume = "100",
  928. panning = "0",
  929. description = "Sound when you follow a player"
  930. },
  931. ["stop_follow"] = {
  932. defaultwav = "stop_follow.wav",
  933. volume = "100",
  934. panning = "0",
  935. description = "Sound when you stop following a player"
  936. },
  937. ["warfare"] = {
  938. defaultwav = "warfare.wav",
  939. volume = "100",
  940. panning = "0",
  941. description = "Warfare has been declared"
  942. },
  943. ["restore"] = {
  944. defaultwav = "restore.wav",
  945. volume = "100",
  946. panning = "0",
  947. description = "Restore messages"
  948. },
  949. ["gquest_start"] = {
  950. defaultwav = "global_quest.wav",
  951. volume = "100",
  952. panning = "0",
  953. description = "Gquest is started"
  954. },
  955. ["gquest_declare"] = {
  956. defaultwav = "global_quest.wav",
  957. volume = "100",
  958. panning = "0",
  959. description = "Gquest has been declared"
  960. },
  961. ["aarch_prof"] = {
  962. defaultwav = "aarch_prof.wav",
  963. volume = "100",
  964. panning = "0",
  965. description = "Aarch Professor in room"
  966. },
  967. ["quest_target_found"] = {
  968. defaultwav = "quest_target_found.wav",
  969. volume = "100",
  970. panning = "0",
  971. description = "Quest target in room"
  972. },
  973. ["quest_target_killed"] = {
  974. defaultwav = "quest_target_killed.wav",
  975. volume = "100",
  976. panning = "0",
  977. description = "Quest target killed"
  978. },
  979. ["quest_ready"] = {
  980. defaultwav = "quest_ready.wav",
  981. volume = "100",
  982. panning = "0",
  983. description = "Quest is available"
  984. },
  985. ["quest_start"] = {
  986. defaultwav = "quest_start.wav",
  987. volume = "100",
  988. panning = "0",
  989. description = "Quest has started"
  990. },
  991. ["quest_complete"] = {
  992. defaultwav = "quest_complete.wav",
  993. volume = "100",
  994. panning = "0",
  995. description = "Quest completed"
  996. },
  997. ["quest_warning"] = {
  998. defaultwav = "quest_warning.wav",
  999. volume = "100",
  1000. panning = "0",
  1001. description = "Quest time warnings"
  1002. },
  1003. ["death"] = {
  1004. defaultwav = "death.wav",
  1005. volume = "100",
  1006. panning = "0",
  1007. description = "Your own death"
  1008. },
  1009. ["cp_mob_dead"] = {
  1010. defaultwav = "cp_mob_dead.wav",
  1011. volume = "100",
  1012. panning = "0",
  1013. description = "CP target killed"
  1014. },
  1015. ["double_end"] = {
  1016. defaultwav = "double_end.wav",
  1017. volume = "100",
  1018. panning = "0",
  1019. description = "Double experience ended"
  1020. },
  1021. ["double_exp"] = {
  1022. defaultwav = "double_exp.wav",
  1023. volume = "100",
  1024. panning = "0",
  1025. description = "Double experience started"
  1026. },
  1027. ["gq_mob_dead"] = {
  1028. defaultwav = "gq_mob_dead.wav",
  1029. volume = "100",
  1030. panning = "0",
  1031. description = "Gquest target killed"
  1032. },
  1033. ["channel_off"] = {
  1034. defaultwav = "channel_off.wav",
  1035. volume = "100",
  1036. panning = "0",
  1037. description = "Channel toggle off"
  1038. },
  1039. ["channel_on"] = {
  1040. defaultwav = "channel_on.wav",
  1041. volume = "100",
  1042. panning = "0",
  1043. description = "Channel toggle on"
  1044. },
  1045. ["answer"] = {
  1046. defaultwav = "answer.wav",
  1047. volume = "100",
  1048. panning = "0",
  1049. description = "Comm Chan: Answer"
  1050. },
  1051. ["auction"] = {
  1052. defaultwav = "auction.wav",
  1053. volume = "100",
  1054. panning = "0",
  1055. description = "Comm Chan: Auctions"
  1056. },
  1057. ["rauction"] = {
  1058. defaultwav = "rauction.wav",
  1059. volume = "100",
  1060. panning = "0",
  1061. description = "Comm Chan: Remort Auctions"
  1062. },
  1063. ["barter"] = {
  1064. defaultwav = "barter.wav",
  1065. volume = "100",
  1066. panning = "0",
  1067. description = "Comm Chan: Barter"
  1068. },
  1069. ["claninfo"] = {
  1070. defaultwav = "claninfo.wav",
  1071. volume = "100",
  1072. panning = "0",
  1073. description = "Comm Chan: ClanInfo"
  1074. },
  1075. ["clantalk"] = {
  1076. defaultwav = "clantalk.wav",
  1077. volume = "100",
  1078. panning = "0",
  1079. description = "Comm Chan: ClanTalk"
  1080. },
  1081. ["curse"] = {
  1082. defaultwav = "curse.wav",
  1083. volume = "100",
  1084. panning = "0",
  1085. description = "Comm Chan: Curse"
  1086. },
  1087. ["debate"] = {
  1088. defaultwav = "debate.wav",
  1089. volume = "100",
  1090. panning = "0",
  1091. description = "Comm Chan: Debate"
  1092. },
  1093. ["gametalk"] = {
  1094. defaultwav = "gametalk.wav",
  1095. volume = "100",
  1096. panning = "0",
  1097. description = "Comm Chan: Gametalk"
  1098. },
  1099. ["ftalk"] = {
  1100. defaultwav = "ftalk.wav",
  1101. volume = "100",
  1102. panning = "0",
  1103. description = "Comm Chan: Ftalk"
  1104. },
  1105. ["gclan"] = {
  1106. defaultwav = "gclan.wav",
  1107. volume = "100",
  1108. panning = "0",
  1109. description = "Comm Chan: Gclan"
  1110. },
  1111. ["gossip"] = {
  1112. defaultwav = "gossip.wav",
  1113. volume = "100",
  1114. panning = "0",
  1115. description = "Comm Chan: Gossip"
  1116. },
  1117. ["gratz"] = {
  1118. defaultwav = "gratz.wav",
  1119. volume = "100",
  1120. panning = "0",
  1121. description = "Comm Chan: Gratz"
  1122. },
  1123. ["gsocial"] = {
  1124. defaultwav = "gsocial.wav",
  1125. volume = "100",
  1126. panning = "0",
  1127. description = "Comm Chan: Gsocial"
  1128. },
  1129. ["gtell"] = {
  1130. defaultwav = "gtell.wav",
  1131. volume = "100",
  1132. panning = "0",
  1133. description = "Comm Chan: Gtell"
  1134. },
  1135. ["helper"] = {
  1136. defaultwav = "helper.wav",
  1137. volume = "100",
  1138. panning = "0",
  1139. description = "Comm Chan: Helper"
  1140. },
  1141. ["immtalk"] = {
  1142. defaultwav = "immtalk.wav",
  1143. volume = "100",
  1144. panning = "0",
  1145. description = "Comm Chan: ImmTalk"
  1146. },
  1147. ["inform"] = {
  1148. defaultwav = "inform.wav",
  1149. volume = "100",
  1150. panning = "0",
  1151. description = "Comm Chan: Inform"
  1152. },
  1153. ["level_up"] = {
  1154. defaultwav = "level_up.wav",
  1155. volume = "100",
  1156. panning = "0",
  1157. description = "Level up"
  1158. },
  1159. ["level_up_sh"] = {
  1160. defaultwav = "level_up_sh.wav",
  1161. volume = "100",
  1162. panning = "0",
  1163. description = "Level up - Superhero"
  1164. },
  1165. ["ltalk"] = {
  1166. defaultwav = "ltalk.wav",
  1167. volume = "100",
  1168. panning = "0",
  1169. description = "Comm Chan: Ltalk"
  1170. },
  1171. ["market"] = {
  1172. defaultwav = "market.wav",
  1173. volume = "100",
  1174. panning = "0",
  1175. description = "Comm Chan: Market"
  1176. },
  1177. ["music"] = {
  1178. defaultwav = "music.wav",
  1179. volume = "100",
  1180. panning = "0",
  1181. description = "Comm Chan: Music"
  1182. },
  1183. ["newbie"] = {
  1184. defaultwav = "newbie.wav",
  1185. volume = "100",
  1186. panning = "0",
  1187. description = "Comm Chan: Newbie"
  1188. },
  1189. ["nobletalk"] = {
  1190. defaultwav = "nobletalk.wav",
  1191. volume = "100",
  1192. panning = "0",
  1193. description = "Comm Chan: NobleTalk"
  1194. },
  1195. ["pokerinfo"] = {
  1196. defaultwav = "pokerinfo.wav",
  1197. volume = "100",
  1198. panning = "0",
  1199. description = "Comm Chan: PokerInfo"
  1200. },
  1201. ["question"] = {
  1202. defaultwav = "question.wav",
  1203. volume = "100",
  1204. panning = "0",
  1205. description = "Comm Chan: Question"
  1206. },
  1207. ["quote"] = {
  1208. defaultwav = "quote.wav",
  1209. volume = "100",
  1210. panning = "0",
  1211. description = "Comm Chan: Quote"
  1212. },
  1213. ["racetalk"] = {
  1214. defaultwav = "racetalk.wav",
  1215. volume = "100",
  1216. panning = "0",
  1217. description = "Comm Chan: Racetalk"
  1218. },
  1219. ["rp"] = {
  1220. defaultwav = "rp.wav",
  1221. volume = "100",
  1222. panning = "0",
  1223. description = "Comm Chan: RP"
  1224. },
  1225. ["say"] = {
  1226. defaultwav = "say.wav",
  1227. volume = "100",
  1228. panning = "0",
  1229. description = "Comm Chan: Say"
  1230. },
  1231. ["scry"] = {
  1232. defaultwav = "scry.wav",
  1233. volume = "100",
  1234. panning = "0",
  1235. description = "Scried by player"
  1236. },
  1237. ["spouse"] = {
  1238. defaultwav = "spouse.wav",
  1239. volume = "100",
  1240. panning = "0",
  1241. description = "Comm Chan: Spouse"
  1242. },
  1243. ["remote_sound"] = {
  1244. defaultwav = "none.wav", --doesn't have a default for remote_sound
  1245. volume = "100",
  1246. panning = "0",
  1247. description = "Remote Sounds"
  1248. },
  1249. ["tech"] = {
  1250. defaultwav = "tech.wav",
  1251. volume = "100",
  1252. panning = "0",
  1253. description = "Comm Chan: Tech"
  1254. },
  1255. ["tell"] = {
  1256. defaultwav = "tell.wav",
  1257. volume = "100",
  1258. panning = "0",
  1259. description = "Comm Chan: Tell"
  1260. },
  1261. ["tiertalk"] = {
  1262. defaultwav = "tiertalk.wav",
  1263. volume = "100",
  1264. panning = "0",
  1265. description = "Comm Chan: TierTalk"
  1266. },
  1267. ["wangrp"] = {
  1268. defaultwav = "wangrp.wav",
  1269. volume = "100",
  1270. panning = "0",
  1271. description = "Comm Chan: WanGrp"
  1272. },
  1273. ["yell"] = {
  1274. defaultwav = "yell.wav",
  1275. volume = "100",
  1276. panning = "0",
  1277. description = "Comm Chan: Yell"
  1278. },
  1279. ["whisper"] = {
  1280. defaultwav = "whisper.wav",
  1281. volume = "100",
  1282. panning = "0",
  1283. description = "Comm Chan: Whisper"
  1284. }
  1285. }
  1286.  
  1287. function TriggerEvent(event)
  1288. local volume = tonumber(soundEvents[event].volume)
  1289. local filename = soundEvents[event].defaultwav
  1290.  
  1291. if volume == 0 then
  1292. logmsg("Event " .. event .. " has fired, but event volume is set to 0. Ignoring.")
  1293. return
  1294. end
  1295. logmsg("Event " .. event .. " has fired!")
  1296. volume = calc_volume(volume)
  1297.  
  1298. if (soundEvents[event].customwav ~= nil) then
  1299. filename = soundEvents[event].customwav
  1300. end
  1301. -- 100 event triggered
  1302. BroadcastPlugin(100, event)
  1303. PlaySound(0, filename, false, volume, soundEvents[event].panning)
  1304. end
  1305.  
  1306. function PlaySettingChanged()
  1307. local volume = 100
  1308. volume = calc_volume(volume)
  1309. PlaySound(0, "channel_on.wav", false, volume, 0)
  1310. end
  1311.  
  1312. function calc_volume(volume)
  1313.  
  1314. if sp_global_volume < volume then
  1315. volume = sp_global_volume
  1316. end
  1317.  
  1318. volume = .4 * volume
  1319. volume = -(40 - volume)
  1320. return volume
  1321. end
  1322.  
  1323. function spmute(name, line, wc)
  1324. if sp_mute_toggle == "0" then
  1325. sp_mute_toggle = "1"
  1326. ColourNote("SteelBlue", "", "[", "MediumSeaGreen", "", "Soundpack", "SteelBlue", "", "] Soundpack has been: ", "Red", "", "Disabled")
  1327. SaveState()
  1328. PlaySettingChanged()
  1329. toggle_triggers(0)
  1330. else
  1331. sp_mute_toggle = "0"
  1332. ColourNote("SteelBlue", "", "[", "MediumSeaGreen", "", "Soundpack", "SteelBlue", "", "] Soundpack has been: ", "Green", "", "Enabled")
  1333. SaveState()
  1334. PlaySettingChanged()
  1335. toggle_triggers(1)
  1336. end
  1337. end
  1338.  
  1339. function spvol(name, line, wc)
  1340. if (wc ~= nil) then
  1341. if (wc.value ~= nil) then
  1342. local value = tonumber(wc.value)
  1343. if (value == nil) then
  1344. showmsg("Global volume requires a valid number between 0 and 100")
  1345. return
  1346. end
  1347. if (value >= 0 and value <= 100) then
  1348. showmsg("Global volume has been set to " .. wc.value)
  1349.  
  1350. sp_global_volume = value
  1351. PlaySettingChanged()
  1352. SaveState()
  1353. return
  1354. end
  1355. end
  1356. end
  1357. showmsg("Global volume is currently set to " .. sp_global_volume)
  1358. end
  1359.  
  1360. function parse_input_rsound(name, line, wc)
  1361. Send(line)
  1362. if wc.url ~= nil then
  1363. play_rsound(wc.url)
  1364. end
  1365. end
  1366.  
  1367. function spdebug(name, line, wc)
  1368. if sp_debug == "1" then
  1369. sp_debug = "0"
  1370. print("")
  1371. showmsg("Debug has been disabled.")
  1372. print("")
  1373. else
  1374. sp_debug = "1"
  1375. print("")
  1376. showmsg("Debug has been enabled.")
  1377. print("")
  1378. end
  1379. SaveState()
  1380. end
  1381.  
  1382. function sphelp(name, line, wc)
  1383. print("")
  1384. NoteStyle(2)
  1385. showmsg("SoundPack v" .. sp_version .. " for Aardwolf by Pwar")
  1386. NoteStyle(0)
  1387. print("")
  1388. ColourNote("SteelBlue", "", GetPluginInfo (GetPluginID (), 3))
  1389. print("")
  1390. end
  1391.  
  1392. function sptog(name, line, wc)
  1393. if (wc.event ~= nil) then
  1394. if wc.event == "all" then
  1395. for event in pairs(soundEvents) do
  1396. if tonumber(soundEvents[event].volume) == 0 then
  1397. soundEvents[event].volume = 100
  1398. else
  1399. soundEvents[event].volume = 0
  1400. end
  1401. end
  1402. showmsg("All events have been toggled.")
  1403. SaveState()
  1404. PlaySettingChanged()
  1405. return
  1406. end
  1407. if soundEvents[wc.event] ~= nil then
  1408. if tonumber(soundEvents[wc.event].volume) == 0 then
  1409. soundEvents[wc.event].volume = 100
  1410. showmsg("Event \"" .. wc.event .. "\" has been enabled. Volume reset to 100.")
  1411. PlaySettingChanged()
  1412. SaveState()
  1413. return
  1414. else
  1415. soundEvents[wc.event].volume = 0
  1416. showmsg("Event \"" .. wc.event .. "\" has been disabled.")
  1417. SaveState()
  1418. PlaySettingChanged()
  1419. return
  1420. end
  1421. end
  1422. end
  1423. logerr("Invalid event. Type \"sptog\" to see a list of events.")
  1424. end
  1425.  
  1426. function spallow(name, line, wc)
  1427. if rsound.player ~=nil then
  1428. if can_rsound(rsound.player) then
  1429. return
  1430. else
  1431. table.insert(rsound_accept, rsound.player)
  1432. showmsg("Added player " .. rsound.player .. " to remote sound allow list")
  1433. SaveState()
  1434. if rsound.url ~= nil then
  1435. play_rsound(rsound.url)
  1436. end
  1437. end
  1438. return
  1439. end
  1440. logerr("Noone has recently sent a sound file to allow!")
  1441. end
  1442.  
  1443. function spdeny(name, line, wc)
  1444. if (wc[1] ~= nil) then -- we have an arg
  1445. if can_rsound(wc[1]) then
  1446. for i = 1, #rsound_accept do
  1447. if rsound_accept[i] ~= nil then
  1448. if string.lower(rsound_accept[i]) == string.lower(wc[1]) then
  1449. showmsg("Removed " .. rsound_accept[i] .. " from remote sound allow list.")
  1450. table.remove(rsound_accept, i)
  1451. SetVariable("sp_allowlist", serialize.save_simple(rsound_accept))
  1452. end
  1453. end
  1454. end
  1455. else
  1456. logerr(wc[1] .. " isn't on your remote sound allow list!")
  1457. end
  1458. else
  1459. showmsg("Usage is \"spdeny <player>\", see \"sphelp\" for more info.")
  1460. logprint("Valid deny targets:")
  1461. for i = 1, #rsound_accept do
  1462. logprint(rsound_accept[i])
  1463. end
  1464. end
  1465. end
  1466.  
  1467. function spsetvol(name, line, wc)
  1468. if soundEvents[wc.event] ~= nil then
  1469. -- set volume by click here print (utils.inputbox ("What is your name?", "Query", "Nick", "Courier", 9))
  1470. local volume = tonumber(utils.inputbox ("Specify volume for " .. wc.event .. "\r\nUse a number 0-100", "Event Volume: " .. wc.event, soundEvents[wc.event].volume, "Courier", 9, { validate = isInteger } ))
  1471. if volume == nil then return end
  1472. if (volume >= 0 and volume <= 100) then
  1473. showmsg(wc.event .. " volume setting has been set to: " .. volume)
  1474. SetVariable(wc.event .. "_volume", volume)
  1475. soundEvents[wc.event].volume = volume
  1476. PlaySettingChanged()
  1477. SaveState()
  1478. else
  1479. logerr("Invalid value \"" .. wc.value .. "\" for " .. wc.setting .. " -- see spset help")
  1480. end
  1481. end
  1482. end
  1483.  
  1484. function spset(name, line, wc)
  1485. if (wc ~= nil) then -- we have an arg
  1486. if (wc[1] == nil) then
  1487. listEvents()
  1488. return
  1489. elseif (wc.setting == nil) then
  1490. if soundEvents[wc.event] ~= nil then
  1491. showmsg("Event: " .. wc.event .. "\nVolume: " .. soundEvents[wc.event].volume .. ", Panning: " .. soundEvents[wc.event].panning .. " Desc: " .. soundEvents[wc.event].description)
  1492. if soundEvents[wc.event].customwav ~= nil then
  1493. logprint("Custom wav file set to: " .. soundEvents[wc.event].customwav)
  1494. end
  1495. return
  1496. end
  1497. logerr("Invalid event: " .. wc.event)
  1498. return
  1499. else
  1500.  
  1501. if (wc.event ~= nil) and (wc.setting ~= nil) and (wc.value ~= nil) then
  1502. if (soundEvents[wc.event] ~= nil) then
  1503. if (wc.setting == "wav") then
  1504. if wc.value == "default" then
  1505. showmsg(wc.event .. " " .. wc.setting .. " setting has been reset to default.")
  1506. soundEvents[wc.event].customwav = nil
  1507. DeleteVariable(wc.event .. "_customwav")
  1508. PlaySettingChanged()
  1509. SaveState()
  1510. return
  1511. elseif file_exists(GetInfo(74) .. wc.value) then
  1512. soundEvents[wc.event].customwav = GetInfo(74) .. wc.value
  1513. showmsg(wc.event .. " " .. wc.setting .. " setting has been set to: " .. wc.value)
  1514. SetVariable(wc.event .. "_customwav", GetInfo(74) .. wc.value)
  1515. PlaySettingChanged()
  1516. SaveState()
  1517. return
  1518. elseif file_exists(GetInfo(74) .. "saved\\" .. wc.value) then
  1519. soundEvents[wc.event].customwav = GetInfo(74) .. "saved\\" .. wc.value
  1520. showmsg(wc.event .. " " .. wc.setting .. " setting has been set to: " .. wc.value)
  1521. SetVariable(wc.event .. "_customwav", GetInfo(74) .. "saved\\" .. wc.value)
  1522. PlaySettingChanged()
  1523. SaveState()
  1524. return
  1525. end
  1526. logerr("File not found in sounds or sounds/saved: " .. wc.value)
  1527. return
  1528. end
  1529. if (wc.setting == "volume") then
  1530. local value = tonumber(wc.value)
  1531. if (value == nil) then
  1532. return
  1533. end
  1534. if (value >= 0 and value <= 100) then
  1535. showmsg(wc.event .. " " .. wc.setting .. " setting has been set to: " .. value)
  1536. SetVariable(wc.event .. "_" .. wc.setting, value)
  1537. soundEvents[wc.event].volume = value
  1538. PlaySettingChanged()
  1539. SaveState()
  1540. return
  1541. else
  1542. logerr("Invalid value \"" .. wc.value .. "\" for " .. wc.setting .. " -- see spset help")
  1543. return
  1544. end
  1545. elseif (wc.setting == "panning") then
  1546. local value = tonumber(wc.value)
  1547. if (value >= -100 and value <= 100) then
  1548. showmsg(wc.event .. " " .. wc.setting .. " setting has been set to: " .. value)
  1549. SetVariable(wc.event .. "_" .. wc.setting, value)
  1550. soundEvents[wc.event].panning = value
  1551. PlaySettingChanged()
  1552. SaveState()
  1553. return
  1554. else
  1555. logerr("Invalid value \"" .. wc.value .. "\" for " .. wc.setting .. " -- see spset help")
  1556. return
  1557. end
  1558. end
  1559. end
  1560. end
  1561. logerr("Invalid event: " .. wc.event)
  1562. end
  1563. end
  1564. end
  1565.  
  1566. function listEvents()
  1567. print("")
  1568. showmsg("Sound Pack Settings")
  1569. ColourNote("LightSeaGreen", "", padRight("Event", 20, " ") .. "Volume " .. padRight("Description", 30, " ") .. "Custom Wav")
  1570. logprint("------------------------------------------------------------------")
  1571.  
  1572. for event in orderedPairs(soundEvents) do
  1573. local volColor = "LimeGreen"
  1574. local volume = tonumber(soundEvents[event].volume)
  1575. local volStr = padRight(string.format("%3d", soundEvents[event].volume) .. "%", 5, " ")
  1576. Hyperlink("sptog " .. event, padRight(event, 22, " "), "Toggle Event: " .. event, "LightSeaGreen", "black", 0, 1)
  1577. if volume < 71 and volume > 30 then
  1578. volColor = "Yellow"
  1579. elseif volume < 31 then
  1580. volColor = "Red"
  1581. end
  1582. Hyperlink("spsetvol " .. event, padRight(volStr, 5, " "), "Adjust Volume: " .. event, volColor, "black", 0, 1)
  1583. local showString = padRight(soundEvents[event].description, 30, " ")
  1584. if soundEvents[event].customwav ~= nil then
  1585. local filename = string.sub(soundEvents[event].customwav, soundEvents[event].customwav:match'^.*()\\' + 1)
  1586. showString = padRight(showString, 65, " ") .. filename
  1587. end
  1588. logprint(showString)
  1589. end
  1590. end
  1591.  
  1592. function toggle_triggers(state)
  1593. local triggerList = GetTriggerList()
  1594. local aliasList = GetAliasList()
  1595.  
  1596. if state == 1 then
  1597. state = true
  1598. else
  1599. state = false
  1600. end
  1601.  
  1602. if triggerList then
  1603. for k, v in ipairs(triggerList) do
  1604. EnableTrigger(v, state)
  1605. end
  1606. end
  1607. end
  1608.  
  1609. function can_rsound(player)
  1610. for i = 1, #rsound_accept do
  1611. if rsound_accept[i] ~= nil then
  1612. if string.lower(rsound_accept[i]) == string.lower(player) then
  1613. return true
  1614. end
  1615. end
  1616. end
  1617. return false
  1618. end
  1619.  
  1620. function play_rsound(url)
  1621. if soundEvents["remote_sound"].volume == "0" then -- remote sounds are disabled
  1622. return
  1623. end
  1624. volume = tonumber(soundEvents["remote_sound"].volume)
  1625.  
  1626. if sp_global_volume < volume then
  1627. volume = sp_global_volume
  1628. end
  1629.  
  1630. volume = .4 * volume
  1631. volume = -(40 - volume)
  1632.  
  1633. if string.sub(url, 1, 5) == "http:" then
  1634. async.HEAD(url, async_head_download_complete, "HTTP", 120)
  1635. elseif string.sub(url, 1, 5) == "https" then
  1636. async.HEAD(url, async_head_download_complete, "HTTPS", 120)
  1637. else
  1638. -- These make sure it doesn't exist in sounds or sounds\saved with the current filename
  1639. if file_exists(GetInfo(74) .. url) then
  1640. print("Found file locally, playing")
  1641. PlaySound(0, GetInfo(74) .. url, false, volume, 0)
  1642. return
  1643. elseif file_exists(GetInfo(74) .. "saved\\" .. url) then
  1644. print("Found file locally, playing")
  1645. PlaySound(0, GetInfo(74) .. "saved\\" .. url, false, volume, 0)
  1646. return
  1647. end
  1648. return
  1649. end
  1650. end
  1651.  
  1652. function OnPluginBroadcast (msg, id, name, text)
  1653. if sp_mute_toggle == "1" then
  1654. return
  1655. end
  1656.  
  1657. if (id == '3e7dedbe37e44942dd46d264') then -- GMCP Handler plugin
  1658. if text == "char.base" then
  1659. self.name = gmcp("char.base.name")
  1660. elseif (text == "comm.repop") then
  1661. TriggerEvent("zone_repop")
  1662. elseif text == "comm.channel" then
  1663. local channel = gmcp("comm.channel.chan")
  1664. local msg = gmcp("comm.channel.msg")
  1665. local player = gmcp("comm.channel.player")
  1666. msg = strip_colours(msg)
  1667.  
  1668. j, k = string.find(msg, "!!SOUND%(")
  1669.  
  1670. if k ~= nil then
  1671. if player ~= self.name then -- don't need to play sounds we are the sender
  1672. url = string.sub(msg, k+1)
  1673. l = string.find(url, ")")
  1674. if l ~= nil then
  1675. url = string.sub(url, 1, l-1)
  1676. if can_rsound(player) then
  1677. play_rsound(url)
  1678. else showmsg(player .. " would like to play remote sounds.")
  1679. rsound.url = url
  1680. rsound.player = player
  1681. logprint("Type \"spallow\" to allow remote sounds from them.")
  1682. end
  1683. end
  1684. end
  1685. end
  1686.  
  1687. if soundEvents[channel] == nil then
  1688. return
  1689. end
  1690.  
  1691. if soundEvents[channel].volume == "0" then
  1692. --Volume is set to 0 we're done here
  1693. return
  1694. end
  1695.  
  1696. TriggerEvent(channel)
  1697.  
  1698. elseif (text == "comm.quest") then
  1699. local action = gmcp("comm.quest.action")
  1700.  
  1701. if (action == "ready") then
  1702. TriggerEvent("quest_ready")
  1703. elseif (action == "killed") then
  1704. TriggerEvent("quest_target_killed")
  1705. elseif (action == "comp") then
  1706. TriggerEvent("quest_complete")
  1707. elseif (action == "start") then
  1708. TriggerEvent("quest_start")
  1709. elseif (action == "warning") then
  1710. TriggerEvent("quest_warning")
  1711. end
  1712. end
  1713. end
  1714. end
  1715.  
  1716. function found_bonusitem(name, line, wildcards, style)
  1717. local foundStartTag = false
  1718. local foundEndTag = false
  1719.  
  1720. for index, value in ipairs(style) do
  1721. thisColor = RGBColourToName(value.textcolour)
  1722.  
  1723. if (thisColor == "lime" or thisColor == "red" or thisColor == "yellow") and value.text == "(" then
  1724. foundStartTag = true
  1725. elseif (thisColor == "lime" or thisColor == "red" or thisColor == "yellow") and value.text == ")" and foundStartTag then
  1726. foundEndTag = true
  1727. end
  1728.  
  1729. if foundStartTag and foundEndTag then
  1730. -- maybe add sounds for diff color tags later..
  1731. end
  1732. end
  1733. TriggerEvent("bonus_item")
  1734. end
  1735.  
  1736. function loadSavedSettings()
  1737. table.sort(soundEvents, sort_func)
  1738. Send_GMCP_Packet("request char") -- store player name for later
  1739.  
  1740. for event in pairs(soundEvents) do
  1741. if (GetVariable(event .. "_volume") ~= nil) then
  1742. soundEvents[event].volume = GetVariable(event .. "_volume")
  1743. end
  1744. if (GetVariable(event .. "_panning") ~= nil) then
  1745. soundEvents[event].panning = GetVariable(event .. "_panning")
  1746. end
  1747. if (GetVariable(event .. "_customwav") ~= nil) then
  1748. soundEvents[event].customwav = GetVariable(event .. "_customwav")
  1749. end
  1750. end
  1751.  
  1752. sp_debug = GetVariable("debug") or "0"
  1753. if (GetVariable("sp_global_volume") ~= nil) then
  1754. sp_global_volume = tonumber(GetVariable("sp_global_volume"))
  1755. end
  1756. if (GetVariable("sp_mute_toggle") ~= nil) then
  1757. sp_mute_toggle = GetVariable("sp_mute_toggle")
  1758. if sp_mute_toggle == "0" then
  1759. toggle_triggers(1)
  1760. end
  1761. else --first time install no data saved for toggle
  1762. first_time = true
  1763. end
  1764. if (GetVariable("sp_allowlist") ~= nil) then
  1765. local mystr = GetVariable("sp_allowlist")
  1766. rsound_accept = load( "return "..mystr)( )
  1767. end
  1768. end
  1769.  
  1770. function OnPluginListChanged()
  1771. dofile "lua/aard_requirements.lua"
  1772. if first_time and aard_req_novisuals_mode then
  1773. --enable soundpack if novisuals_mode
  1774. spmute()
  1775. end
  1776. end
  1777.  
  1778. function OnPluginSaveState()
  1779. for event in pairs(soundEvents) do
  1780. SetVariable(event .. "_volume", soundEvents[event].volume)
  1781. SetVariable(event .. "_panning", soundEvents[event].panning)
  1782. if soundEvents[event].customwav ~= nil then
  1783. SetVariable(event .. "_customwav", soundEvents[event].customwav)
  1784. end
  1785. end
  1786. SetVariable("sp_global_volume", sp_global_volume)
  1787. SetVariable("debug", sp_debug)
  1788. SetVariable("sp_mute_toggle", sp_mute_toggle)
  1789. SetVariable("sp_allowlist", serialize.save_simple(rsound_accept))
  1790. end
  1791.  
  1792. function OnPluginInstall()
  1793. print("")
  1794. ColourNote("SteelBlue", "", "[", "MediumSeaGreen", "", "Soundpack", "SteelBlue", "", "] " .. "Loaded Soundpack v" .. sp_version .. " by Pwar (", "MediumSeaGreen", "", "\"spmute\"", "SteelBlue", "",") to enable sounds or (", "MediumSeaGreen", "", "\"sphelp\"", "SteelBlue", "",") for more commands.")
  1795. print("")
  1796. loadSavedSettings()
  1797. end
  1798.  
  1799. ------ Utils ------
  1800. function padRight(text, length, padChar)
  1801. local padding = length - string.len(text)
  1802. for i = 1, padding do
  1803. text = text .. padChar
  1804. end
  1805. return text
  1806. end
  1807.  
  1808. function showmsg(message)
  1809. ColourNote("SteelBlue", "", "[", "MediumSeaGreen", "", "Soundpack", "SteelBlue", "", "] " .. message)
  1810. end
  1811.  
  1812. function logmsg(msg)
  1813. if GetVariable("debug") == "1" then
  1814. ColourNote("olive", "", "[dbg_sp] ", "MediumSeaGreen", "", msg)
  1815. end
  1816. end
  1817.  
  1818. function logprint(message)
  1819. ColourNote("SteelBlue", "", message)
  1820. end
  1821.  
  1822. function logerr(message)
  1823. ColourNote("SteelBlue", "", "[", "MediumSeaGreen", "", "Soundpack", "SteelBlue", "", "] ", "Red", "", "Error: " .. message)
  1824. end
  1825.  
  1826. function async_head_download_complete(retval, page, status, headers, full_status, request_url)
  1827. if headers == nil then
  1828. logerr("No headers received from " .. request_url)
  1829. return
  1830. end
  1831. local filesize = headers["content-length"]
  1832. if filesize == nil then
  1833. logerr("Link to wav invalid.")
  1834. return
  1835. elseif (tonumber(filesize) > 400000) then
  1836. logerr("File size exceeds 400k limit for wav files.")
  1837. return
  1838. end
  1839. logmsg("Starting download..")
  1840. -- change this to use async.GETFILE later
  1841. if string.sub(request_url, 1, 5) == "http:" then
  1842. async.doAsyncRemoteRequest(request_url, async_download_complete, "HTTP", 120)
  1843. elseif string.sub(request_url, 1, 5) == "https" then
  1844. async.doAsyncRemoteRequest(request_url, async_download_complete, "HTTPS", 120)
  1845. end
  1846. end
  1847.  
  1848. function async_download_complete(retval, page, status, headers, full_status, request_url)
  1849. local destination = GetInfo(74) .. "cache\\"
  1850. local filename = string.sub(request_url, request_url:match'^.*()/' + 1)
  1851.  
  1852. f = assert(io.open (destination .. "temp.wav", "wb")) -- open it
  1853. if status == 301 then
  1854. return
  1855. elseif status ~= 200 then
  1856. logerr("Web server reported error " .. status .. " while trying to download " .. request_url)
  1857. return
  1858. end
  1859.  
  1860. f:write(page) -- write file to disk
  1861. f:close() -- close it
  1862.  
  1863. local wave = parse_wav_header(destination .. "temp.wav")
  1864. if wave == nil then
  1865. logerr("Invalid wav header in file.")
  1866. return
  1867. end
  1868.  
  1869. --Round the seconds off and make size readable
  1870. wave.duration = round(wave.duration, 2)
  1871. wave.size = wave.size/1024
  1872. wave.size = round(wave.size, 2)
  1873.  
  1874. showmsg("Downloaded " .. filename .. " [" .. wave.duration .. "secs] (" .. wave.size .. "KB) to temporary folder.")
  1875. logprint("Type \"savesound filename.wav\" or \"savesound\" to save this sound for later.")
  1876. sp_last_download = filename
  1877.  
  1878. if (wave.duration > 30) then
  1879. logerr("File size exceeds 30 second limit for wav files.")
  1880. return
  1881. end
  1882.  
  1883. PlaySound(0, "cache\\temp.wav", false, volume, 0)
  1884. end
  1885.  
  1886. function save_sound(name, line, wc)
  1887. if wc[1] == nil then
  1888. if sp_last_download ~= nil then
  1889. wc.wav = sp_last_download
  1890. else
  1891. logerr("Noone has recently sent you a sound file to save.")
  1892. return
  1893. end
  1894. end
  1895. local cacheFile = GetInfo(74) .. "cache\\temp.wav"
  1896. local saveFile = GetInfo(74) .. "saved\\" .. wc.wav
  1897.  
  1898. -- These make sure it doesn't exist in sounds or sounds\saved with the current filename
  1899.  
  1900. if file_exists(GetInfo(74) .. wc.wav) then
  1901. logerr("Filename exists already: " .. GetInfo(74) .. wc.wav)
  1902. logprint("Type savesound filename.wav to save with alternate name.")
  1903. return
  1904. elseif file_exists(saveFile) then
  1905. logerr("Filename exists already: " .. saveFile)
  1906. logprint("Type savesound filename.wav to save with alternate name.")
  1907. return
  1908. end
  1909. if file_exists(cacheFile) then
  1910. assert(os.rename(cacheFile, saveFile))
  1911. showmsg("File saved to " .. saveFile)
  1912. return
  1913. else
  1914. logerr("savesound: Downloaded wav file is no longer available.")
  1915. end
  1916. end
  1917.  
  1918. function parse_wav_header(filename)
  1919. local wave = {}
  1920. local f = assert(io.open(filename, "r"))
  1921. -- read in 16 bytes at a time
  1922. local block = 16
  1923. if f:read(4) ~= "RIFF" then
  1924. --logerr("not a RIFF file")
  1925. return
  1926. end
  1927.  
  1928. file_size = f:read(4)
  1929. if not file_size then
  1930. --logerr("file header incomplete (file size)")
  1931. return
  1932. end
  1933. file_size = bton(file_size) + 8
  1934. if f:read(4) ~= "WAVE" then
  1935. --logerr("Not valid wave file!")
  1936. return
  1937. else
  1938. -- Read file chunks
  1939. local chunk_id, chunk_size
  1940. while true do
  1941. -- Read chunk header
  1942. chunk_id, chunk_size = f:read(4), f:read(4)
  1943. if not chunk_size then
  1944. break
  1945. end
  1946. chunk_size = bton(chunk_size)
  1947. -- Identify chunk type
  1948. if chunk_id == "fmt " then
  1949. -- Read format informations
  1950. local bytes = f:read(2)
  1951. if not bytes or bton(bytes) ~= 1 then
  1952. logerr("data must be in PCM format")
  1953. end
  1954. bytes = f:read(2)
  1955. if not bytes then
  1956. logerr("channels number not found")
  1957. end
  1958. channels_number = bton(bytes)
  1959. bytes = f:read(4)
  1960. if not bytes then
  1961. logerr("sample rate not found")
  1962. end
  1963. sample_rate = bton(bytes)
  1964. bytes = f:read(4)
  1965. if not bytes then
  1966. logerr("byte rate not found")
  1967. end
  1968. byte_rate = bton(bytes)
  1969. bytes = f:read(2)
  1970. if not bytes then
  1971. logerr("block align not found")
  1972. end
  1973. block_align = bton(bytes)
  1974. bytes = f:read(2)
  1975. if not bytes then
  1976. logerr("bits per sample not found")
  1977. end
  1978. bits_per_sample = bton(bytes)
  1979. if bits_per_sample ~= 8 and bits_per_sample ~= 16 and bits_per_sample ~= 24 and bits_per_sample ~= 32 then
  1980. logerr("bits per sample must be 8, 16, 24 or 32")
  1981. end
  1982.  
  1983. wave.size = f:seek("end")
  1984. wave.channels = channels_number
  1985. wave.bps = bits_per_sample
  1986. wave.samplerate = sample_rate
  1987. wave.duration = wave.size / (sample_rate * channels_number * bits_per_sample /8)
  1988. wave.md5sum = utils.tohex (utils.md5 (f:read ("*a")))
  1989. --logprint("File name: " .. filename)
  1990. --logprint("File size: " .. wave.size)
  1991. --logprint("Channels: " .. wave.channels)
  1992. --logprint("bps: " .. wave.bps)
  1993. --logprint("Sample rate: " .. wave.samplerate)
  1994. --logprint ("md5sum: " .. wave.md5sum)
  1995. end
  1996. end
  1997. f:close()
  1998. return wave
  1999. end
  2000. end
  2001.  
  2002. -- Byte-string(unsigend integer,little endian)<->Lua-number converters
  2003. function bton(s)
  2004. local bytes = {s:byte(1,#s)}
  2005. local n, bytes_n = 0, #bytes
  2006. for i = 0, bytes_n-1 do
  2007. n = n + bytes[1+i] * 2^(i*8)
  2008. end
  2009. return n
  2010. end
  2011.  
  2012. function round(num, numDecimalPlaces)
  2013. local mult = 10^(numDecimalPlaces or 0)
  2014. return math.floor(num * mult + 0.5) / mult
  2015. end
  2016.  
  2017. function file_exists(name)
  2018. local f=io.open(name,"r")
  2019. if f ~= nil then
  2020. io.close(f)
  2021. return true
  2022. else
  2023. return false
  2024. end
  2025. end
  2026.  
  2027. function isInteger(s)
  2028. if tonumber(s) then
  2029. return true
  2030. end
  2031. return false
  2032. end
  2033.  
  2034. function __genOrderedIndex( t )
  2035. local orderedIndex = {}
  2036. for key in pairs(t) do
  2037. table.insert( orderedIndex, key )
  2038. end
  2039. table.sort( orderedIndex )
  2040. return orderedIndex
  2041. end
  2042.  
  2043. function orderedNext(t, state)
  2044. local key = nil
  2045. if state == nil then
  2046. -- the first time, generate the index
  2047. t.__orderedIndex = __genOrderedIndex(t)
  2048. key = t.__orderedIndex[1]
  2049. else
  2050. -- fetch the next value
  2051. for i = 1,table.getn(t.__orderedIndex) do
  2052. if t.__orderedIndex[i] == state then
  2053. key = t.__orderedIndex[i+1]
  2054. end
  2055. end
  2056. end
  2057.  
  2058. if key then
  2059. return key, t[key]
  2060. end
  2061.  
  2062. -- no more value to return, cleanup
  2063. t.__orderedIndex = nil
  2064. return
  2065. end
  2066.  
  2067. function orderedPairs(t)
  2068. return orderedNext, t, nil
  2069. end
  2070.  
  2071. ]]>
  2072. </script>
  2073. </muclient>
Add Comment
Please, Sign In to add comment