I need help with a command

I am trying to make a / command that gives certain weapons. like /police and it gives you a pistol. But I can’t figure out how to make the command. Could someone help me?

Hey :slight_smile:

You can do the following in a client file :

RegisterCommand("weapons", function(source,args,rawCommand)

    if (args[1] ~= nil) then

        if (args[1] == "police") then
            local ped = PlayerPedId()
            GiveWeaponToPed(ped,0x1B06D571,50,false,false)
        end

    else

        TriggerEvent('chat:addMessage', {
            color = { 255, 0, 0},
            multiline = true,
            args = {"System", "~r~You need to specify the loadout as an argument !"}
          })

    end

end, false)

The command will be :

/weapons police

You can add multiple loadouts by adding multiple conditions so people will be able to choose the loadout like :

/weapons guards
/weapons army
/weapons gang

Yeah thanks for that just one question. Is there any way you could make it so it’s like /police and not the weapons part.

RegisterCommand("police", function(source)
    local ped = PlayerPedId()
    GiveWeaponToPed(ped, 0x1B06D571, 50, false, false)
end)