Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ------------------------------------------------------------------------------------
- -- PURPOSE: Voice Command Function
- -- DEVELOPERS: HannS
- ------------------------------------------------------------------------------------
- local interval = 60000
- local lastCheck = {}
- function voiceCommand(player, command, arg)
- if (not hasObjectPermissionTo(player, "command.gocb", true) and not hasObjectPermissionTo(player, "command.gochief", true)) then
- outputChatBox("You've no access to this command.", player, 255, 0, 0)
- return false
- end
- if (not exports.CITcrimEvent:isPlayerInCriminalEvent(player)) then
- outputChatBox("This command can be only used inside a Criminal Event.", player, 255, 0, 0)
- return false
- end
- if (not exports.CITteams:isPlayerInTeams(player, "Criminals", "Gangsters", "Police Service")) then
- outputChatBox("You must be criminal or police.", player, 255, 0, 0)
- return false
- end
- if (not arg or arg ~= "go" or arg ~= "fb" or arg ~= "hp") then
- outputChatBox("Syntax error: /qv go | /qv fb | /qv hp", player, 255, 0, 0)
- return false
- end
- if (hasObjectPermissionTo(player, "command.gocb", true) and exports.CITteams:isPlayerInTeams(player, "Criminals", "Gangsters")) then
- if (lastCheck["CB"] and ((getTickCount() - lastCheck["CB"]) < interval)) then
- outputChatBox("This command can be used one time a minute.", player, 255, 0, 0)
- return false
- end
- lastCheck["CB"] = getTickCount()
- 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"
- if (exports.CITcrimEvent:isPlayerInCriminalEvent(value)) then
- triggerClientEvent(value, "CITvC.playSound", value, arg)
- end
- end
- return true
- end
- if (lastCheck["PC"] and ((getTickCount() - lastCheck["PC"]) < interval)) then
- outputChatBox("This command can be used one time a minute.", player, 255, 0, 0)
- return false
- end
- lastCheck["PC"] = getTickCount()
- for index, value in pairs(exports.CITbusiness:getPlayersByJob("Police Service")) do
- if (exports.CITcrimEvent:isPlayerInCriminalEvent(value)) then
- triggerClientEvent(value, "CITvC.playSound", value, arg)
- end
- end
- end
- addCommandHandler("qv", voiceCommand)
Advertisement
Add Comment
Please, Sign In to add comment