Advertisement
JTPenn814

Toggle Radio

Jun 21st, 2014
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.31 KB | None | 0 0
  1. local t = {}
  2. local hidePoliceRadio = {}
  3.  
  4. function policeRadio(thePlayer,cmd,...)
  5.     if (not exports.GTIutil:isPlayerInTeam(thePlayer, "Law Enforcement")) then return end
  6.    
  7.     if (t[thePlayer]) then
  8.         outputChatBox("You need to wait 3 seconds between each message.", thePlayer, 255, 0, 0)
  9.         return
  10.     end
  11.    
  12.     local playerName    = getPlayerName(thePlayer)
  13.     local message       = table.concat({...}, " ")
  14.     local team          = getTeamFromName("Law Enforcement")
  15.     local r, g, b       = getTeamColor(team)
  16.     local listeners     = getPlayersInTeam(team)
  17.    
  18.     for i,player in ipairs(listeners) do
  19.         if (not hidePoliceRadio[thePlayer]) then
  20.             outputChatBox("(RADIO) "..playerName.." : #FFFFFF"..message.."",player,r,g,b,true)
  21.             t[thePlayer] = true
  22.             setTimer(function () t[thePlayer] = nil end, 3000, 1)
  23.         end
  24.     end
  25. end
  26. addCommandHandler("r", policeRadio, false, false)
  27. addCommandHandler("radio", policeRadio, false, false)
  28.  
  29.  
  30. function disablePoliceRadio(player)
  31.     if (hidePoliceRadio[player]) then
  32.         hidePoliceRadio[player] = nil
  33.         outputChatBox("Radio enabled.", player)
  34.     else
  35.         hidePoliceRadio[player] = true
  36.         outputChatBox("Radio disabled.", player)
  37.     end
  38. end
  39. addCommandHandler("noradio", disablePoliceRadio)
  40.  
  41. addEventHandler("onPlayerQuit", root, function()
  42.     if (hidePoliceRadio[source]) then hidePoliceRadio[source] = nil end
  43. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement