This repository has been archived by the owner on Dec 18, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c4b7d74
Showing
3 changed files
with
161 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937' | ||
|
||
client_script 'vVoice.lua' | ||
server_script 'vVoice_s.lua' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |