Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @name Tank Radio
- @inputs Switch
- @outputs Received:string Sent:string Freq IsOn RadioSounds:table
- @trigger all
- @model models/props_lab/reciever01d.mdl
- runOnChat(1)
- ### This is a tank radio ###
- ### Created by bad_idea & modded by Red ###
- ### Modded further by DatAmazingCheese ###
- ### Turn on with !on then set frequency with !freq <1-99> you can use decimals
- #############################################################################
- Language = "russian" ### Choose from "russian", "german" and "english" ###
- ### Requires http://steamcommunity.com/workshop/filedetails/?id=757675124 ###
- Freq = 1
- #############################################################################
- #init, setup
- if(first()|dupefinished())
- {
- #sets frequency to input number via global, updates scope and group
- function void setFrequency(Frequency:number)
- {
- local OldFrequency = Freq
- Freq = Frequency
- dsLeaveGroup(dsGetGroup())
- dsJoinGroup(toString(Freq))
- dsSetScope(2)
- entity():soundPlay(1,1,"buttons/blip2.wav")
- hint("Frequency: " + Freq,3)
- }
- function void playSound()
- {
- local TypeRandomNum = randint(4)
- local SubtypeRandomNum = randint(3)
- local StringBase = ""
- local StringEnd = ".wav"
- if(TypeRandomNum == 1)
- {
- StringBase = "/quickchat/voicemessage/voice_message_attention_to_point_0_"
- }
- elseif(TypeRandomNum == 2)
- {
- StringBase = "/quickchat/voicemessage/voice_message_attention_to_point_2_"
- }
- elseif(TypeRandomNum == 3)
- {
- StringBase = "/quickchat/voicemessage/voice_message_attack_target_1_"
- }
- elseif(TypeRandomNum == 4)
- {
- StringBase = "/quickchat/voicemessage/voice_message_cover_me_1_"
- SubtypeRandomNum = randint(3) #corner case handling
- }
- soundPlay(1,0,"acf_wtradio/"+Language+StringBase+toString(SubtypeRandomNum)+StringEnd)
- }
- function void transmit(User:entity,Message:string,Frequency:number)
- {
- local UserName = User:name()
- local Message = UserName+": "+Message
- print(Message)
- dsSend(User:name(),toString(Frequency), Message)
- playSound()
- }
- setFrequency(Freq)
- }
- #phys switch on
- elseif(changed(Switch))
- {
- IsOn = Switch
- }
- #chat cmd on
- elseif((!IsOn) & chatClk(owner()))
- {
- if(owner():lastSaid():lower() == "!on")
- {
- hideChat(1)
- setFrequency(Freq)
- IsOn = 1
- }
- }
- #actually transmitting or recieving something
- elseif (IsOn&&(entity():pos()-owner():pos()):length()<=118.11) #3m
- {
- #recieving
- if (dsGetString()!=Sent&dsGetString()!="")
- {
- print(dsGetString())
- playSound()
- }
- #transmitting
- elseif (chatClk(owner()))
- {
- hideChat(1)
- local Said = owner():lastSaid()
- local Said1 = Said:lower():explode(" ")[1,string]
- if((Said1 == "!frequency") | (Said1 == "!freq"))
- {
- setFrequency(clamp(owner():lastSaid():explode(" ")[2,string]:toNumber(),1,999))
- }
- elseif(Said1 == "!off")
- {
- IsOn = 0
- soundStop(1)
- hint("Radio Disabled",3)
- }
- else
- {
- Sent = Said
- transmit(owner(),Sent,Freq)
- }
- }
- }
- #disabled
- elseif(changed(IsOn) & !IsOn)
- {
- soundStop(1)
- hint("Radio Disabled",3)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement