[Release][ESX / vRP / Standalone] Drag & Drop chat command packs

You can make me an example of command only for policies, use VRP

Zap is just a server host. it depends on the framework you use eg VRP or ESX look at the instructions to install.

1 Like

thx i resolved it

How do I get the only police to use the command?

Here’s an example command pack I made for you, it makes two commands that both require you to be police by default (both vRP and ESX supported)

Police Example Pack
CommandPack("Police Requirement Example", "glitchdetector", {
    -- Add commands here
    -- Check if you are a valid police officer
    {
        command = "polcheck",
        reply = "You are a police officer!",
    },
    -- Speak via police megaphone
    {
        command = "polmega",
        usage = "/polmega [message]",
        help = "Speak loudly through your megaphone",
        args = {{name = "message", help = "Message to send"}},
        format = "^4^*#message#",
        range = 25.0,
    }
}, {
    -- Default values
    prereq = function(source)
        if SETTINGS.use_vrp then
            local user_id = vRP.getUserId({source})
            return vRP.hasPermission({user_id, "police.service"}) -- Most Police jobs in Dunko's vRP uses police.service
        elseif SETTINGS.use_esx then
            local xPlayer = ESX.GetPlayerFromId(source)
            return xPlayer.job.name == 'police' -- No clue if there's a way to check multiple jobs without "or"-ing them all
        end
        return false
    end,
    noperm = "You are not a police officer!",
})

I have also added it as an example in the repository

Error parsing script @chat_commands/commands/cmds_police.lua in resource chat_commands: @chat_commands/commands/cmds_police.lua:32: ‘)’ expected (to close ‘(’ at line 2) near
Failed to load script commands/cmds_police.lua.

hmm…

There’s a missing ) at the end of the script, my bad

works great glitch,just sadly I don’t think that the esx_identity wants to cooperate, doesn’t read the rp name from it,want to add to the report command not only the id and fivem nickname,but the rp name aswell
Anyway to change
(GetPlayerName(source), source)
that it would display not only fivem name but esx rp name aswell?

And also is there a way to check,that only a specific Player.Job would be able to write some of the commands? as an example
if ESX.PlayerData.job ~= nil and ESX.PlayerData.job.name == ‘taxi’ then

Yes, that’s exactly what the police example pack that’s in the repository shows how to do

Are you using the correct text placeholder for the name?
Post your code

was trying to config the part where it checks
XPlayer.job.name == ‘Police’

started getting

@chat_commands/commands/cmds_taxi.lua:2: attempt to call a nil value
and on the second line,its only

CommandPack("Information Commands", "glitchdetector", {

The resource is still the same,just added a new command to the folder,so don’t mind the cmds_taxi haha,just named it for tracking purposes haha

{
    -- Default values
    prereq = function(source)
        if SETTINGS.use_vrp then
            local user_id = vRP.getUserId({source})
            return vRP.hasPermission({user_id, "police.service"}) -- Most Police jobs in Dunko's vRP uses police.service
        elseif SETTINGS.use_esx then
            local xPlayer = ESX.GetPlayerFromId(source)
            return xPlayer.job.name == 'taxi' -- No clue if there's a way to check multiple jobs without "or"-ing them all
        end
        return false
    end,
    noperm = "Tu ne taxi darbuotojas!",
}

I know I could have made the code shorter,because we only use esx,so it wouldn’t need to check if its vrp,but still

Make sure it matches the actual job name, it’s case sensitive.
Since the example used Police I’d think you’d need Taxi

doesn’t seem to be because of that,i added this in one of the first lines:


    {
        command = "taxi",
        reply = "Tu taxistas!",
    },
To check if it even checks if im taxi

then at the end

{
    -- Default values
    prereq = function(source)
        if SETTINGS.use_vrp then
            local user_id = vRP.getUserId({source})
            return vRP.hasPermission({user_id, "police.service"}) -- Most Police jobs in Dunko's vRP uses police.service
        elseif SETTINGS.use_esx then
            local xPlayer = ESX.GetPlayerFromId(source)
            return xPlayer.job.name == 'taxi' -- No clue if there's a way to check multiple jobs without "or"-ing them all
        end
        return false
    end,
    noperm = "Tu ne taxistas!",
})

I didn’t bother changing the vrp values,because it setted for esx

The commands are not being picked up by my discord bot that logs chat or the console. Logging is set to true. Is there another set to get the commands to show in console/chat logs?

How is it done so that the id is not shown in the chat?

The show_id option in the config

Is there a way to create a chat that only the police can read?

@glitchdetector are you able to add ability for commands to show on chat log for discord bot? Would be most helpful especially when using anon rp commands.

Hey I really enjoy the script but the proximity commands do not show up in my discord server logs. Is there any way you can fix this issue? Thanks

Did you do anything to make them show up? This script doesn’t do that by default

There is an example pack that shows how this is done.
Add the event trigger in the commands you want to log or in the global callback.