Skip to content
This repository has been archived by the owner on Dec 18, 2018. It is now read-only.

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
TomGrobbe committed Sep 25, 2017
0 parents commit c4b7d74
Show file tree
Hide file tree
Showing 3 changed files with 161 additions and 0 deletions.
4 changes: 4 additions & 0 deletions __resource.lua
@@ -0,0 +1,4 @@
resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937'

client_script 'vVoice.lua'
server_script 'vVoice_s.lua'
152 changes: 152 additions & 0 deletions vVoice.lua
@@ -0,0 +1,152 @@
local voiceChatProximity = "veryclose" -- default: veryclose
-- valid options are: veryclose, close, nearby, distant, far, veryfar, global.
local voiceEnabled = true
local allowProximityChange = true -- Allow people to change the chat proximity using /voice distance <proximity>
local allowVoiceToggle = true -- Allow people to disable voice chat for themseleves using /voice toggle



















----------------- CODE DON'T TOUCH!!!! ---------------------

RegisterCommand("voice", function(source, args, rawCommand)
if args[1] == "toggle" then
if allowVoiceToggle then
voiceEnabled = not voiceEnabled
TriggerEvent('chatMessage', '', {255,255,255}, "^4Voice Chat is " .. (voiceEnabled == true and "^2enabled" or "^8disabled") .. "^4.")
else
TriggerEvent('chatMessage', '', {255,255,255}, "^4The ability to toggle voice chat is disabled, disable voice chat in your GTA V settings instead.")
end
elseif args[1] == "distance" then
if allowProximityChange then
if args[2] == "veryclose" then
voiceChatProximity = args[2]
TriggerServerEvent("updateClients", voiceChatProximity)
elseif args[2] == "close" then
voiceChatProximity = args[2]
TriggerServerEvent("updateClients", voiceChatProximity)
elseif args[2] == "nearby" then
voiceChatProximity = args[2]
TriggerServerEvent("updateClients", voiceChatProximity)
elseif args[2] == "distant" then
voiceChatProximity = args[2]
TriggerServerEvent("updateClients", voiceChatProximity)
elseif args[2] == "far" then
voiceChatProximity = args[2]
TriggerServerEvent("updateClients", voiceChatProximity)
elseif args[2] == "veryfar" then
voiceChatProximity = args[2]
TriggerServerEvent("updateClients", voiceChatProximity)
elseif args[2] == "global" then
voiceChatProximity = args[2]
TriggerServerEvent("updateClients", voiceChatProximity)
else
sendUsageMessage()
end
else
TriggerEvent('chatMessage', '', {255,255,255}, "^4The ability to change the proximity has been disabled, contact the server owner if you believe that this is an error.")
end
else
sendUsageMessage()
end
end)

function sendUsageMessage()
TriggerEvent('chatMessage', '', {255,255,255}, "^8Usage: ^0/voice [toggle|distance] <veryclose, close, nearby, distant, far, veryfar, global>")
end

local prox = 0.01

RegisterNetEvent("changeProximity")
AddEventHandler('changeProximity', function(vprox)
if vprox == "veryclose" then
prox = 25.01
elseif vprox == "close" then
prox = 75.01
elseif vprox == "nearby" then
prox = 200.01
elseif vprox == "distant" then
prox = 500.01
elseif vprox == "far" then
prox = 2500.01
elseif vprox == "veryfar" then
prox = 8000.01
elseif vprox == "global" then
prox = 0.00
end
end)

function getProximity()
if voiceChatProximity == "veryclose" then
prox = 25.01
elseif voiceChatProximity == "close" then
prox = 75.01
elseif voiceChatProximity == "nearby" then
prox = 200.01
elseif voiceChatProximity == "distant" then
prox = 500.01
elseif voiceChatProximity == "far" then
prox = 2500.01
elseif voiceChatProximity == "veryfar" then
prox = 8000.01
elseif voiceChatProximity == "global" then
prox = 0.00
end
end
getProximity()

Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
NetworkSetTalkerProximity(prox)
NetworkClearVoiceChannel()
NetworkSetVoiceActive(voiceEnabled)
local a = 0
if voiceEnabled then
for i=0,31 do
if NetworkIsPlayerTalking(i) then
displayInfo("~r~" .. GetPlayerName(i) .. " ~bb~is currently talking.", 255, 255, 255, 255, 0.40, (a * 0.02) + 0.001)
a = a + 1
end
end
end
end
end)


function displayInfo(text, red, green, blue, alpha, posx, posy)
local txt = text
local red = red
local green = green
local blue = blue
local alpha = alpha
local locx = posx
local locy = posy

SetTextFont(0)
SetTextProportional(1)
SetTextScale(0.0, 0.34)
SetTextColour(red, green, blue, alpha)
SetTextDropShadow(50, 0, 0, 0, 255)
SetTextEdge(1, 0, 0, 0, 255)
SetTextDropshadow()
SetTextOutline()
SetTextEntry("STRING")
AddTextComponentString(txt)
DrawText(locx, locy)
end
5 changes: 5 additions & 0 deletions vVoice_s.lua
@@ -0,0 +1,5 @@
RegisterServerEvent("updateClients")
AddEventHandler("updateClients", function(test)
TriggerClientEvent('changeProximity', -1, test)
TriggerClientEvent('chatMessage', -1, '', {255,255,255}, "^3VoiceChat proximity has now been changed to ^4" .. test)
end)

0 comments on commit c4b7d74

Please sign in to comment.