RyanUSNS

Server Side - Hanns

Apr 24th, 2020
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.11 KB | None | 0 0
  1. ------------------------------------------------------------------------------------
  2. --  PURPOSE:  Voice Command for Criminal Bosses and Police Chiefs
  3. --  DEVELOPERS:  HannS
  4. ------------------------------------------------------------------------------------
  5. local lastCheck = {}
  6.  
  7. function voiceCommand(plr, cmd, arg)
  8.     if (not hasObjectPermissionTo(plr, "command.gocb", true) and not hasObjectPermissionTo(plr, "command.gochief", true)) then
  9.         return false
  10.     end
  11.     if (not exports.CITcrimEvent:isPlayerInCriminalEvent(plr)) then
  12.         outputChatBox("This command can be only used inside a Criminal Event.", plr, 255, 0, 0)
  13.         return false
  14.     end
  15.     if (not exports.CITteams:isPlayerInTeams(plr, "Criminals", "Gangsters", "Police Service")) then
  16.         outputChatBox("You must be criminal or police.", plr, 255, 0, 0)
  17.         return false
  18.     end
  19.     if (not arg or arg ~= "go" or arg ~= "fb" or arg ~= "hp") then
  20.         outputChatBox("Syntax error: /qv go | /qv fb | /qv hp", plr, 255, 0, 0)
  21.         return false
  22.     end
  23.     local x, y, z = getElementPosition(plr)
  24.     if (hasObjectPermissionTo(plr, "command.gocb", true) and exports.CITteams:isPlayerInTeams(plr, "Criminals", "Gangsters")) then
  25.         if (lastCheck["CB"] and ((getTickCount() - lastCheck["CB"]) < 60000)) then
  26.             outputChatBox("This command can be used one time a minute.", plr, 255, 0, 0)
  27.             return false
  28.         end
  29.         lastCheck["CB"] = getTickCount()
  30.         for ind, crim in ipairs(exports.CITbusiness:getPlayersByJob("Criminal")) do
  31.             if (exports.CITcrimEvent:isPlayerInCriminalEvent(crim)) then
  32.                 triggerClientEvent(crim, "CITvoiceChat.playSound", crim, arg, x, y, z)
  33.             end
  34.         end
  35.         return true
  36.     end
  37.     if (lastCheck["PC"] and ((getTickCount() - lastCheck["PC"]) < 60000)) then
  38.         outputChatBox("This command can be used one time a minute.", plr, 255, 0, 0)
  39.         return false
  40.     end
  41.     lastCheck["PC"] = getTickCount()
  42.     for ind, pol in ipairs(exports.CITbusiness:getPlayersByJob("Police Service")) do
  43.         if (exports.CITcrimEvent:isPlayerInCriminalEvent(pol)) then
  44.             triggerClientEvent(pol, "CITvoiceChat.playSound", pol, arg, x, y, z)
  45.         end
  46.     end
  47. end
  48. addCommandHandler("qv", voiceCommand)
Add Comment
Please, Sign In to add comment