MSK Scripts
TebexGithubDiscordMusiker15
  • MSK Scripts
    • Welcome
  • Common Issues
    • Keymaster
  • Miscellaneous
    • Change Notifications
  • Scripts
    • MSK Core
      • Installation
      • Functions
        • Client
          • Ace Permission
          • Commands
          • Coords
          • Player
          • Points
          • Request
          • Scaleform
          • UI
            • Input
            • Numpad
            • Progressbar
            • TextUI
          • Vehicle
        • Shared
          • String
          • Math
          • Table
          • Timeout
          • Vector
        • Server
          • Ace Permission
          • Ban System
          • Commands
          • Player
          • Scaleform
          • UI
            • Input
            • Numpad
            • Progressbar
            • TextUI
    • MSK Banking
      • Installation
        • Paycheck Transaction
      • Config
      • Exports
        • Client
        • Server
      • Events
        • Client
        • Server
      • Server Callbacks
    • MSK EngineToggle
      • Guides
      • Exports
        • Client
      • Event Handler
        • Client
        • Server
    • MSK Fuel
      • Config
      • Exports
        • Client
    • MSK Garage
      • Config
      • Exports
        • Client
    • MSK Handcuffs
      • Guides
        • General Edits for Jobs
        • Jaksam Job Creator
        • Multichar
        • ox_inventory
      • Config
      • Admin Commands
      • Exports
        • Client
        • Server
      • Events
        • Client
        • Server
      • Event Handlers
    • MSK Radio
      • Config
      • Exports
        • Client
        • Server
      • Events
        • Server
    • MSK Simcard
      • Installation
        • Config.Database
      • Config
    • MSK VehicleKeys
      • Guides
        • Installation
        • Integrations
      • Config
      • Admin Commands
      • Exports
        • Client
        • Server
    • MSK Whitelist
      • Config
      • Exports
        • Client
        • Server
    • MSK Weaponammo
Powered by GitBook
On this page
  1. Scripts
  2. MSK Core
  3. Functions
  4. Server

Commands

MSK.RegisterCommand

Parameters commandName - string or table - The Command callback - function - Function to execute properties - boolean or table - Data Properties

Description Parameter: properties

  • allowConsole - boolean - Allow to execute in server console - Optional, default: true

  • showSuggestion - boolean - Show chat suggestion - Optional, default: true

  • restricted - boolean or string or table - Restrict Command to specific groups with ace permission

  • help - string - Chat suggestion

  • params - table - Paramter for the command

Parameter: params

  • name - string - name of the argument

  • type - string - type of the argument - number, string, playerId, any, player - player is only returning the playerData for ESX or QBCore

  • help - string - chat suggestion of the argument

  • optional - boolean? - Is the Argment optional? Has to be the last argument! - Optional, default: false

MSK.RegisterCommand(commandName, callback, properties)

-- Example 1
MSK.RegisterCommand('testCommand', function(source, args, raw)    
    local targetId, time, reason = args.playerId, args.time, args.reason
    
    if not reason then 
        reason = 'Unknown reason'
    end
    
    print(('Player with ID %s was banned by Player %s for Reason %s until %s'):format(playerId, source, reason, time))
end, {
    allowConsole = true,
    showSuggestion = true,
    restricted = {'superadmin', 'admin'},
    help = 'This is a Test Command',
    params = {
        {name = "playerId", type = 'playerId', help = "Target players server id"},
        {name = "time", type = 'string', help = "Ban Time"},
        {name = "reason", type = 'string', help = "Ban Reason", optional = true},
    }
})

-- Example 2 -> Framwork based (Only ESX and QBCore)
MSK.RegisterCommand('testCommand', function(Player, args, raw)    
    local Target = args.player
    
    -- ESX
    print(Player.source) -- PlayerId of the Executer
    print(Target.source) -- PlayerId of the Arguments playerId
    
    -- QBCore
    print(Player.PlayerData.source) -- PlayerId of the Executer
    print(Target.PlayerData.source) -- PlayerId of the Arguments playerId
end, {
    allowConsole = true,
    showSuggestion = true,
    returnPlayer = true, -- Return the Frameworks PlayerData
    restricted = {'superadmin', 'admin'},
    help = 'This is a Test Command',
    params = {
        {name = "player", type = 'player', help = "random argument"},
    }
})

-- As an Export:
exports.msk_core:RegisterCommand(commandName, callback, properties)

Last updated 6 months ago