RyanUSNS

Hanns

Apr 24th, 2020
641
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.38 KB | None | 0 0
  1. ------------------------------------------------------------------------------------
  2. --  PURPOSE:  Voice Command Function
  3. --  DEVELOPERS:  HannS
  4. ------------------------------------------------------------------------------------
  5.  
  6. local interval = 60000
  7. local lastCheck = {}
  8.  
  9. function voiceCommand(player, command, arg)
  10.     if (not hasObjectPermissionTo(player, "command.gocb", true) and not hasObjectPermissionTo(player, "command.gochief", true)) then
  11.         outputChatBox("You've no access to this command.", player, 255, 0, 0)
  12.         return false
  13.     end
  14.     if (not exports.CITcrimEvent:isPlayerInCriminalEvent(player)) then
  15.         outputChatBox("This command can be only used inside a Criminal Event.", player, 255, 0, 0)
  16.         return false
  17.     end
  18.     if (not exports.CITteams:isPlayerInTeams(player, "Criminals", "Gangsters", "Police Service")) then
  19.         outputChatBox("You must be criminal or police.", player, 255, 0, 0)
  20.         return false
  21.     end
  22.     if (not arg or arg ~= "go" or arg ~= "fb" or arg ~= "hp") then
  23.         outputChatBox("Syntax error: /qv go | /qv fb | /qv hp", player, 255, 0, 0)
  24.         return false
  25.     end
  26.     if (hasObjectPermissionTo(player, "command.gocb", true) and exports.CITteams:isPlayerInTeams(player, "Criminals", "Gangsters")) then
  27.         if (lastCheck["CB"] and ((getTickCount() - lastCheck["CB"]) < interval)) then
  28.             outputChatBox("This command can be used one time a minute.", player, 255, 0, 0)
  29.             return false
  30.         end
  31.         lastCheck["CB"] = getTickCount()
  32.         for i, v in pairs(exports.CITbusiness:getPlayersByJob("Criminal")) do --Ask it to Brian, if you can use this exports for all criminals: 'CITbusiness:getPlayersByJob(jobName). If yes, remove the line that contains "if (exports.CITteams:isPlayerInTeams(value, "Criminals", "Gangsters")) then"
  33.             if (exports.CITcrimEvent:isPlayerInCriminalEvent(value)) then
  34.                 triggerClientEvent(value, "CITvC.playSound", value, arg)
  35.             end
  36.         end
  37.         return true
  38.     end
  39.     if (lastCheck["PC"] and ((getTickCount() - lastCheck["PC"]) < interval)) then
  40.         outputChatBox("This command can be used one time a minute.", player, 255, 0, 0)
  41.         return false
  42.     end
  43.     lastCheck["PC"] = getTickCount()
  44.     for index, value in pairs(exports.CITbusiness:getPlayersByJob("Police Service")) do
  45.         if (exports.CITcrimEvent:isPlayerInCriminalEvent(value)) then
  46.             triggerClientEvent(value, "CITvC.playSound", value, arg)
  47.         end
  48.     end
  49. end
  50. addCommandHandler("qv", voiceCommand)
Advertisement
Add Comment
Please, Sign In to add comment