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:trueshowSuggestion -
boolean- Show chat suggestion - Optional, default:truerestricted -
booleanorstringortable- Restrict Command to specific groups with ace permissionhelp -
string- Chat suggestionparams -
table- Paramter for the command
Parameter: params
name -
string- name of the argumenttype -
string- type of the argument -number,string,playerId,any,player-playeris only returning the playerData for ESX or QBCorehelp -
string- chat suggestion of the argumentoptional -
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