Advertisement
sethxi

Untitled

Apr 7th, 2013
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.10 KB | None | 0 0
  1. --My Code---------------------------------------------------------------------------------------------
  2. function SetFreq(ply, args)
  3.     if args == "" then ply:SendLua('chat.AddText(Color(255,255,255,255),"Enter a channel frequency #")') return end
  4.     if tonumber(args)==nil then ply:SendLua('chat.AddText(Color(255,255,255,255),"Must be a number!")') return end
  5.     ply.radiofrequency = tonumber(args)
  6.     return ""
  7. end
  8. AddChatCommand("/setfreq", SetFreq)
  9.  
  10. function RadioTalk(ply, args)
  11.     if args == "" then ply:SendLua('chat.AddText(Color(255,255,255,255),"Enter something to say!")') return "" end
  12.     if ply.radiofrequency==nil then ply:SendLua('chat.AddText(Color(255,255,255,255),"Set a radio frequency!")') return "" end
  13.     msgToSay = args
  14.     for k,v in pairs(player.GetAll()) do
  15.         if(v.radiofrequency==ply.radiofrequency) then
  16.             v:SendLua('chat.AddText(Color(0,255,255,255),"[RADIO] '..ply:Nick()..': ", Color(255,223,117,255),"'..msgToSay..'")')
  17.         end
  18.     end
  19.     return ""
  20. end
  21. AddChatCommand("/r", RadioTalk)
  22. AddChatCommand("/radio", RadioTalk)
  23.  
  24. --Their Code--------------------------------------------------------------------------------------------
  25. local function SetRadioChannel(ply,args)
  26.     if tonumber(args) == nil or tonumber(args) < 0 or tonumber(args) > 99 then
  27.         GAMEMODE:Notify(ply, 1, 4, string.format(LANGUAGE.unable, "/channel", "0<channel<100"))
  28.         return ""
  29.     end
  30.     GAMEMODE:Notify(ply, 2, 4, "Channel set to "..args.."!")
  31.     ply.RadioChannel = tonumber(args)
  32.     return ""
  33. end
  34. AddChatCommand("/channel", SetRadioChannel)
  35.  
  36. local function SayThroughRadio(ply,args)
  37.     if not ply.RadioChannel then ply.RadioChannel = 1 end
  38.     if not args or args == "" then
  39.         GAMEMODE:Notify(ply, 1, 4, string.format(LANGUAGE.unable, "/radio", ""))
  40.         return ""
  41.     end
  42.     local DoSay = function(text)
  43.         if text == "" then return end
  44.         for k,v in pairs(player.GetAll()) do
  45.             if v.RadioChannel == ply.RadioChannel then
  46.                 GAMEMODE:TalkToPerson(v, Color(180,180,180,255), "Radio ".. tostring(ply.RadioChannel), Color(180,180,180,255), text, ply)
  47.             end
  48.         end
  49.     end
  50.     return args, DoSay
  51. end
  52. AddChatCommand("/radio", SayThroughRadio, 1.5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement