Advertisement
Risk_

Untitled

Sep 2nd, 2015
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.08 KB | None | 0 0
  1. function getOnlineAdmins()
  2.     local t = {}
  3.     for k,v in ipairs ( getElementsByType("player") ) do
  4.         while true do
  5.             local acc = getPlayerAccount(v)
  6.             if not acc or isGuestAccount(acc) then break end
  7.             local accName = getAccountName(acc)
  8.             local isAdmin = isObjectInACLGroup("user."..accName,aclGetGroup("sms"))
  9.             if isAdmin == true then
  10.                 table.insert(t,v)
  11.             end
  12.             break
  13.         end
  14.     end
  15.     return t
  16. end
  17.  
  18. function RGBToHex(red, green, blue, alpha)
  19.     if((red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255) or (alpha and (alpha < 0 or alpha > 255))) then
  20.         return nil
  21.     end
  22.     if(alpha) then
  23.         return string.format("#%.2X%.2X%.2X%.2X", red,green,blue,alpha)
  24.     else
  25.         return string.format("#%.2X%.2X%.2X", red,green,blue)
  26.     end
  27. end
  28.  
  29. function groupChat(plr, cmd, ...)
  30.     if (plr) then
  31.         local msg = table.concat({...}, " ")
  32.         if (msg) then
  33.             local plrGroup = getPlayerGroup(plr)
  34.             for index, player in pairs(getElementsByType("player")) do
  35.                 local g2 = getPlayerGroup(player)
  36.                 if (plrGroup and g2 and g2 == plrGroup) then
  37.                     local team=getPlayerTeam(plr)
  38.                     local groupName=getElementData(plr,"Group")
  39.                     if team and groupName then
  40.                         local r,g,b=getTeamColor(team)
  41.                         if r and g and b then
  42.                             local hex=RGBToHex(r,g,b)
  43.                             if hex then
  44.                                 outputChatBox(groupName.." -"..hex.." "..getPlayerName(plr)..": #FFFFFF"..msg, player, 255, 0, 0, true)
  45.                             end
  46.                         end
  47.                     end
  48.                 end
  49.                 local onlineAdmins = getOnlineAdmins()
  50.                 local groupName = getElementData(plr,"Group")
  51.                 for _,v in ipairs(onlineAdmins) do
  52.                     if v and groupName then
  53.                         local team=getPlayerTeam(plr)
  54.                         if team then
  55.                             local r,g,b=getTeamColor(team)
  56.                             if r and g and b then
  57.                                 local hex=RGBToHex(r,g,b)
  58.                                 if hex then
  59.                                     outputChatBox(groupName.." -"..hex.." "..getPlayerName(plr)..": #ffffff"..msg,v,255,128,0,true)
  60.                                     break
  61.                                 end
  62.                             end
  63.                         end
  64.                     else
  65.                         outputDebugString("0 admins online",3)
  66.                         break
  67.                     end
  68.                 end
  69.             end
  70.         end
  71.     end
  72. end
  73. addCommandHandler("gc", groupChat)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement