RyanUSNS

Cem notification

May 19th, 2017
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.31 KB | None | 0 0
  1. local noteText
  2.  
  3. function addNotification(plr, cmd, ...)
  4.         if (not hasObjectPermissionTo(plr, "command.em", false)) then
  5.                 return false
  6.         end
  7.         local cemOnline = {}
  8.         local plrs = getElementsByType("player")
  9.         for i, cem in ipairs(plrs) do
  10.                 if (hasObjectPermissionTo(cem, "command.em", false)) then
  11.                         table.insert(cemOnline, cem)
  12.                 end
  13.         end
  14.         local text = table.concat({...}, " ")
  15.         local text = string.gsub(text, "#%x%x%x%x%x%x", "")
  16.         if (string.len(text) < 1) then
  17.                 exports.CIThelp:opc("(CEM Notification) "..getPlayerName(plr).." removed the CEM Notification", cemOnline, 212, 9, 185, true)
  18.                 noteText = nil
  19.                 return true
  20.         end
  21.         noteText = "#D409B9(CEM Notification) "..getPlayerName(plr)..": #FFFFFF"..text
  22.         exports.CIThelp:opc(noteText, cemOnline, 255, 255, 255, true)
  23. end
  24. addCommandHandler("cemnotif", addNotification)
  25.  
  26. function onPlrCmd(cmd)
  27.         if (not hasObjectPermissionTo(source, "command.em", false) or cmd ~= "rb" and cmd ~= "em" or not noteText) then
  28.                 return false
  29.         end
  30.         outputChatBox(noteText, source, 255, 255, 255, true)
  31. end
  32. addEventHandler("onPlayerCommand", root, onPlrCmd)
Advertisement
Add Comment
Please, Sign In to add comment