Advertisement
DatAmazingCheese

Tank Radio - DatAmazingCheese Version

Nov 10th, 2016
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.50 KB | None | 0 0
  1. @name Tank Radio
  2. @inputs Switch
  3. @outputs Received:string Sent:string Freq IsOn RadioSounds:table
  4. @trigger all
  5. @model models/props_lab/reciever01d.mdl
  6. runOnChat(1)
  7.  
  8. ### This is a tank radio ###
  9.  
  10. ### Created by bad_idea & modded by Red ###
  11.  
  12. ### Modded further by DatAmazingCheese ###
  13.  
  14. ### Turn on with !on then set frequency with !freq <1-99> you can use decimals
  15.  
  16. #############################################################################
  17.  
  18. Language = "russian" ### Choose from "russian", "german" and "english" ###
  19.  
  20. ### Requires http://steamcommunity.com/workshop/filedetails/?id=757675124 ###
  21.  
  22. Freq = 1
  23.  
  24. #############################################################################
  25.  
  26. #init, setup
  27. if(first()|dupefinished())
  28. {
  29. #sets frequency to input number via global, updates scope and group
  30. function void setFrequency(Frequency:number)
  31. {
  32. local OldFrequency = Freq
  33. Freq = Frequency
  34. dsLeaveGroup(dsGetGroup())
  35. dsJoinGroup(toString(Freq))
  36. dsSetScope(2)
  37. entity():soundPlay(1,1,"buttons/blip2.wav")
  38. hint("Frequency: " + Freq,3)
  39. }
  40.  
  41. function void playSound()
  42. {
  43. local TypeRandomNum = randint(4)
  44. local SubtypeRandomNum = randint(3)
  45. local StringBase = ""
  46. local StringEnd = ".wav"
  47. if(TypeRandomNum == 1)
  48. {
  49. StringBase = "/quickchat/voicemessage/voice_message_attention_to_point_0_"
  50. }
  51. elseif(TypeRandomNum == 2)
  52. {
  53. StringBase = "/quickchat/voicemessage/voice_message_attention_to_point_2_"
  54. }
  55. elseif(TypeRandomNum == 3)
  56. {
  57. StringBase = "/quickchat/voicemessage/voice_message_attack_target_1_"
  58. }
  59. elseif(TypeRandomNum == 4)
  60. {
  61. StringBase = "/quickchat/voicemessage/voice_message_cover_me_1_"
  62. SubtypeRandomNum = randint(3) #corner case handling
  63. }
  64. soundPlay(1,0,"acf_wtradio/"+Language+StringBase+toString(SubtypeRandomNum)+StringEnd)
  65. }
  66.  
  67. function void transmit(User:entity,Message:string,Frequency:number)
  68. {
  69. local UserName = User:name()
  70. local Message = UserName+": "+Message
  71. print(Message)
  72. dsSend(User:name(),toString(Frequency), Message)
  73. playSound()
  74. }
  75.  
  76. setFrequency(Freq)
  77. }
  78.  
  79. #phys switch on
  80. elseif(changed(Switch))
  81. {
  82. IsOn = Switch
  83. }
  84.  
  85. #chat cmd on
  86. elseif((!IsOn) & chatClk(owner()))
  87. {
  88. if(owner():lastSaid():lower() == "!on")
  89. {
  90. hideChat(1)
  91. setFrequency(Freq)
  92. IsOn = 1
  93. }
  94. }
  95.  
  96. #actually transmitting or recieving something
  97. elseif (IsOn&&(entity():pos()-owner():pos()):length()<=118.11) #3m
  98. {
  99. #recieving
  100. if (dsGetString()!=Sent&dsGetString()!="")
  101. {
  102. print(dsGetString())
  103. playSound()
  104. }
  105. #transmitting
  106. elseif (chatClk(owner()))
  107. {
  108. hideChat(1)
  109. local Said = owner():lastSaid()
  110. local Said1 = Said:lower():explode(" ")[1,string]
  111. if((Said1 == "!frequency") | (Said1 == "!freq"))
  112. {
  113. setFrequency(clamp(owner():lastSaid():explode(" ")[2,string]:toNumber(),1,999))
  114. }
  115. elseif(Said1 == "!off")
  116. {
  117. IsOn = 0
  118. soundStop(1)
  119. hint("Radio Disabled",3)
  120. }
  121. else
  122. {
  123. Sent = Said
  124. transmit(owner(),Sent,Freq)
  125. }
  126. }
  127. }
  128.  
  129. #disabled
  130. elseif(changed(IsOn) & !IsOn)
  131. {
  132. soundStop(1)
  133. hint("Radio Disabled",3)
  134. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement