RyanUSNS

Voice chat - Server

Nov 20th, 2020 (edited)
929
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.40 KB | None | 0 0
  1. local messageNames = {
  2.     ["rush"] = true,
  3.     ["fb"] = true,
  4.     ["fm"] = true,
  5.     ["bkup"] = true,
  6.     ["clear"] = true
  7. }
  8. local voiceLimit = {}
  9.  
  10. function voiceCommands(plrBoss, cmd, msg)
  11.     local access
  12.     if (hasObjectPermissionTo(plrBoss, "command.gochief", false)) then
  13.         access = "pc"
  14.     elseif (hasObjectPermissionTo(plrBoss, "command.gocb", false)) then
  15.         access = "cb"
  16.     end
  17.     if (not access) then
  18.         return false
  19.     end
  20.     if (not msg or not messageNames[string.lower(msg)]) then
  21.         outputChatBox("SYNTAX: /vm fb, fm, clear, bkup", plrBoss, 255, 0, 0)
  22.         return false
  23.     end
  24.     if (not exports.CITcrimEvent:isPlayerInCriminalEvent(plrBoss)) then
  25.         outputChatBox("You can only use this command in Criminal Events!", plrBoss, 255, 0, 0)
  26.         return false
  27.     end
  28.     if (voiceLimit[access] and getTickCount() - voiceLimit[access] < 30000) then
  29.         outputChatBox("This command can be used one time in 30 seconds.", plrBoss, 255, 0, 0)
  30.         return false
  31.     end
  32.     local plrTeam = getPlayerTeam(plrBoss)
  33.     --if ((((access == "pc") and (plrTeam ~= getTeamFromName("Police Service")))) or ((access == "cb") and (plrTeam ~= getTeamFromName("Criminal") and plrTeam ~= getTeamFromName("Gangster")))) then
  34.     if ((((access == "pc") and (plrTeam ~= getTeamFromName("Police Service")))) or ((access == "cb") and (not exports.CITteams:isPlayerInTeams(plrBoss, "Criminals", "Gangsters")))) then
  35.         outputChatBox("For prevent abuse, you aren't allowed to use this command as "..getTeamName(plrTeam)..".", plrBoss, 255, 0, 0)
  36.         return false
  37.     end
  38.     local x, y, z, = getElementPosition(plrBoss)
  39.     local plrDim = getElementDimension(plrBoss)
  40.     local plrInt = getElementInterior(plrBoss)
  41.     local plrTable = {}
  42.     for i, plr in ipairs (getElementsByType("player")) do
  43.         if ((getElementDimension(plr) == plrDim) and (getElementInterior(plr) == plrInt)) then
  44.             if (access == "pc") then
  45.                 if (plrTeam == getTeamFromName("Police Service")) then
  46.                     plrTable[#plrTable + 1] = plr
  47.                 end
  48.             else
  49.                 --if (plrTeam == getTeamFromName("Criminals") or plrTeam == getTeamFromName("Gangsters")) then
  50.                 if (exports.CITteams:isPlayerInTeams(plr, "Criminals", "Gangsters")) then
  51.                     plrTable[#plrTable + 1] = plr
  52.                 end
  53.             end
  54.         end
  55.     end
  56.     --outputChatBox(#plrTable.." players", plrBoss, 255, 0, 0) --Test table
  57.     triggerClientEvent(plrTable, "clientSayVoice", resourceRoot, string.lower(msg))
  58. end
  59. addCommandHandler("vm", voiceCommands)
Advertisement
Add Comment
Please, Sign In to add comment