QBCore.Commands = {} QBCore.Commands.List = {} QBCore.Commands.Add = function(name, help, arguments, argsrequired, callback, permission) -- [name] = command name (ex. /givemoney), [help] = help text, [arguments] = arguments that need to be passed (ex. {{name="id", help="ID of a player"}, {name="amount", help="amount of money"}}), [argsrequired] = set arguments required (true or false), [callback] = function(source, args) callback, [permission] = rank or job of a player QBCore.Commands.List[name:lower()] = { name = name:lower(), permission = permission ~= nil and permission:lower() or "user", help = help, arguments = arguments, argsrequired = argsrequired, callback = callback, } end QBCore.Commands.Refresh = function(source) local Player = QBCore.Functions.GetPlayer(tonumber(source)) if Player ~= nil then for command, info in pairs(QBCore.Commands.List) do if QBCore.Functions.HasPermission(source, "god") or QBCore.Functions.HasPermission(source, QBCore.Commands.List[command].permission) then TriggerClientEvent('chat:addSuggestion', source, "/"..command, info.help, info.arguments) end end end end QBCore.Commands.Add("tp", "TP To Player or Coords (Admin Only)", {{name="id/x", help="ID of player or X position"}, {name="y", help="Y position"}, {name="z", help="Z position"}}, false, function(source, args) if (args[1] ~= nil and (args[2] == nil and args[3] == nil)) then -- tp to player local Player = QBCore.Functions.GetPlayer(tonumber(args[1])) if Player ~= nil then TriggerClientEvent('QBCore:Command:TeleportToPlayer', source, Player.PlayerData.source) else TriggerClientEvent('QBCore:Notify', source, "Player is not online!", "error") end else -- tp to location if args[1] ~= nil and args[2] ~= nil and args[3] ~= nil then local x = tonumber(args[1]) local y = tonumber(args[2]) local z = tonumber(args[3]) TriggerClientEvent('QBCore:Command:TeleportToCoords', source, x, y, z) else TriggerClientEvent('QBCore:Notify', source, "Not every argument has been entered (x, y, z)", "error") end end end, "admin") QBCore.Commands.Add("addpermission", "Give Player Permissions (God Only)", {{name="id", help="ID of player"}, {name="permission", help="Permission level"}}, true, function(source, args) local Player = QBCore.Functions.GetPlayer(tonumber(args[1])) local permission = tostring(args[2]):lower() if Player ~= nil then QBCore.Functions.AddPermission(Player.PlayerData.source, permission) else TriggerClientEvent('QBCore:Notify', source, "Player is not online!", "error") end end, "god") QBCore.Commands.Add("removepermission", "Remove Players Permissions (God Only)", {{name="id", help="ID of player"}}, true, function(source, args) local Player = QBCore.Functions.GetPlayer(tonumber(args[1])) if Player ~= nil then QBCore.Functions.RemovePermission(Player.PlayerData.source) else TriggerClientEvent('QBCore:Notify', source, "Player is not online!", "error") end end, "god") QBCore.Commands.Add("car", "Spawn Vehicle (Admin Only)", {{name="model", help="Model name of the vehicle"}}, true, function(source, args) TriggerClientEvent('QBCore:Command:SpawnVehicle', source, args[1]) end, "admin") QBCore.Commands.Add("debug", "Toggle Debug Mode (Admin Only)", {}, false, function(source, args) TriggerClientEvent('koil-debug:toggle', source) end, "admin") QBCore.Commands.Add("dv", "Delete Vehicle (Admin Only)", {}, false, function(source, args) TriggerClientEvent('QBCore:Command:DeleteVehicle', source) end, "admin") QBCore.Commands.Add("tpm", "TP To Marker (Admin Only)", {}, false, function(source, args) TriggerClientEvent('QBCore:Command:GoToMarker', source) end, "admin") QBCore.Commands.Add("givemoney", "Give A Player Money (Admin Only)", {{name="id", help="Player ID"},{name="moneytype", help="Type of money (cash, bank, crypto)"}, {name="amount", help="Amount of money"}}, true, function(source, args) local Player = QBCore.Functions.GetPlayer(tonumber(args[1])) if Player ~= nil then Player.Functions.AddMoney(tostring(args[2]), tonumber(args[3])) else TriggerClientEvent('QBCore:Notify', source, "Player is not online!", "error") end end, "admin") QBCore.Commands.Add("setmoney", "Set Players Money Amount (Admin Only)", {{name="id", help="Player ID"},{name="moneytype", help="Type of money (cash, bank, crypto)"}, {name="amount", help="Amount of money"}}, true, function(source, args) local Player = QBCore.Functions.GetPlayer(tonumber(args[1])) if Player ~= nil then Player.Functions.SetMoney(tostring(args[2]), tonumber(args[3])) else TriggerClientEvent('QBCore:Notify', source, "Player is not online!", "error") end end, "admin") QBCore.Commands.Add("setjob", "Set A Players Job (Admin Only)", {{name="id", help="Speler ID"}, {name="job", help="Job name"}}, true, function(source, args) local Player = QBCore.Functions.GetPlayer(tonumber(args[1])) if Player ~= nil then Player.Functions.SetJob(tostring(args[2])) else TriggerClientEvent('QBCore:Notify', source, "Player is not online!", "error") end end, "admin") QBCore.Commands.Add("job", "Check Your Job", {}, false, function(source, args) local Player = QBCore.Functions.GetPlayer(source) TriggerClientEvent('QBCore:Notify', source, "Job: "..Player.PlayerData.job.label) end) QBCore.Commands.Add("setgang", "Set A Players Gang (Admin Only)", {{name="id", help="Player ID"}, {name="job", help="Name of a gang"}}, true, function(source, args) local Player = QBCore.Functions.GetPlayer(tonumber(args[1])) if Player ~= nil then Player.Functions.SetGang(tostring(args[2])) else TriggerClientEvent('QBCore:Notify', source, "Player is not online!", "error") end end, "admin") QBCore.Commands.Add("gang", "Check Your Gang", {}, false, function(source, args) local Player = QBCore.Functions.GetPlayer(source) if Player.PlayerData.gang.name ~= "geen" then TriggerClientEvent('QBCore:Notify', source, "Gang: "..Player.PlayerData.gang.label) else TriggerClientEvent('QBCore:Notify', source, "No Gang Affiliation", "error") end end) QBCore.Commands.Add("clearinv", "Clear Players Inventory (Admin Only)", {{name="id", help="Player ID"}}, false, function(source, args) local playerId = args[1] ~= nil and args[1] or source local Player = QBCore.Functions.GetPlayer(tonumber(playerId)) if Player ~= nil then Player.Functions.ClearInventory() else TriggerClientEvent('QBCore:Notify', source, "Player is not online!", "error") end end, "admin") QBCore.Commands.Add("ooc", "OOC Chat Message", {}, false, function(source, args) local message = table.concat(args, " ") TriggerClientEvent("QBCore:Client:LocalOutOfCharacter", -1, source, GetPlayerName(source), message) local Players = QBCore.Functions.GetPlayers() local Player = QBCore.Functions.GetPlayer(source) for k, v in pairs(QBCore.Functions.GetPlayers()) do if QBCore.Functions.HasPermission(v, "admin") then if QBCore.Functions.IsOptin(v) then TriggerClientEvent('chatMessage', v, "OOC " .. GetPlayerName(source), "normal", message) TriggerEvent("qb-log:server:CreateLog", "ooc", "OOC", "white", "**"..GetPlayerName(source).."** (CitizenID: "..Player.PlayerData.citizenid.." | ID: "..source..") **Message:** " ..message, false) end end end end)