I’m trying to create a channel marker or alert system (I’m gonna figure that out when I can make arguments function) with pma-voice and scully radio. Everything works as expected but I want to send different sounds by making it get args and if its equal to 1 it will send the sound. it will send another variant if its 2 etc…
The issue is, the arg is always equal to -1. I’ve tried it with
local arg = args
or
local arg = args[1] too. If it’s args[1], the error is attempt to index a number value (local ‘args’)
Code:
local QBCore = exports['qb-core']:GetCoreObject()
RegisterCommand("alert", function(source, args, rawCommand)
if source == 0 then
-- Command is being executed from the console
TriggerClientEvent('playChannelMarkerSound', -1, args, rawCommand)
print('Marker successfully executed.')
Citizen.Wait(5000)
TriggerClientEvent('playChannelMarkerSound', -1, args, rawCommand)
print('Marker successfully executed.')
else
local player = source
if QBCore.Functions.HasPermission(player, 'god') or QBCore.Functions.HasPermission(player, 'admin') or QBCore.Functions.HasPermission(player, 'mod') or IsPlayerAceAllowed(player, 'command') then
TriggerEvent('playChannelMarkerSound', -1, args, rawCommand)
Citizen.Wait(5000)
TriggerEvent('playChannelMarkerSound', -1, args, rawCommand)
else
TriggerClientEvent('okokNotify:Alert', source, "Error", "You're not an admin.", 5000, 'error')
end
end
end)
RegisterServerEvent('playChannelMarkerSound')
AddEventHandler('playChannelMarkerSound', function(args)
local soundName = Scully.MarkerSoundName
local volume = Scully.MarkerSoundVolume
local arg = args[1]
for _, channel in pairs({1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5}) do
local players = exports['pma-voice']:getPlayersInRadioChannel(channel)
for source, isTalking in pairs(players) do
if arg == 1 then
print(arg)
TriggerClientEvent('InteractSound_CL:PlayOnOne', source, soundName, volume)
else
print(arg)
TriggerClientEvent('okokNotify:Alert', source, "Error", "Wrong channel.", 5000, 'error')
end
end
end
end)
Any help is appreciated.
(ignore the soundName since I will remove it when args start to work, or use the command as /alert . For now I’m just trying to make it work like /alert )