Serverside

This functions are serverside ONLY

MSK.Register

MSK.RegisterServerCallback still works but it's using a outdated method.

Register Synchron Server Callback (MSK.Trigger)

MSK.Register("Callback_Name", function(source, ...)
    return ...
end)

MSK.TriggerClientCallback

Trigger Synchron Client Callback (MSK.RegisterClientCallback)

local data = MSK.TriggerClientCallback("Callback_Name", source, ...)

Example

local value1, value2  = 'Test', 'Test2'
local data, data2 = MSK.TriggerClientCallback("Callback_Name", source, value1, value2)
print(data, data2) -- Output: 'Test', 'Test2'

MSK.AddWebhook

Discord Webhook

MSK.AddWebhook(webhook, botColor, botName, botAvatar, title, description, fields, footer, time)

Example

If you don't want to use f.e. footer then set footer = false to deactivate the footer.

webhook = "https://discordapp.com/api/webhooks/101088",
botColor = "6205745", -- https://www.mathsisfun.com/hexadecimal-decimal-colors.html
botName = "MSK Scripts",
botAvatar = "https://i.imgur.com/PizJGsh.png",
title = "MSK Scripts - Webhook Script",
description = "Test Beschreibung",
fields = {
    {name = "Title", value = 'Description', inline = true},
    {name = "Title", value = 'Description', inline = true},
},
footer = {
    text = "© MSK Scripts", 
    link = "https://i.imgur.com/PizJGsh.png"
},
time = "%d/%m/%Y %H:%M:%S" -- format: "day/month/year hour:minute:second"

MSK.Notification

Show a Notification. info and duration is optional. Look at Flipz-Alert for better understanding.

MSK.Notification(source, title, message, info, duration)

Example

MSK.Notification(source, 'Title', 'This is a Notification', 'general', 5000)

MSK.AdvancedNotification

Shows a Picture Notification

-- flash and iconType are optional
MSK.AdvancedNotification(source, text, title, subtitle, icon, flash, icontype)

Example

MSK.AdvancedNotification(source, 'This is a Notification', 'Title', 'Subtitle', 'CHAR_HUMANDEFAULT', true, 1)

MSK.RegisterCommand

Register a Command with a few functions

MSK.RegisterCommand(name, groups, cb, console, framework, suggestion)

Example

MSK.RegisterCommand('testCommand', 'admin', cb, console, framework, suggestion)
MSK.RegisterCommand({'command1, command2', ...}, {'group1', 'group2', ...}, cb, console, framework, suggestion)
MSK.RegisterCommand('testCommand', 'admin', function(source, args, rawCommand)
    if not args.playerId then args.playerId = source end
    MSK.Notification(args.playerId, 'Command send successfully')
end, false --[[console]], false --[[framework]], {help = 'Just a Test Command', arguments = {
    {name = 'playerId', help = 'PlayerID', action = 'playerId', val = false},
}})

MSK.RegisterCommand('testCommand', 'admin', function(xPlayer, args, rawCommand)
    local targetPlayer = args.playerId
    MSK.Notification(targetPlayer.source, 'Command send successfully')
end, false --[[console]], true --[[framework]], {help = 'Just a Test Command', arguments = {
    {name = 'playerId', help = 'PlayerID', action = 'playerId', val = true},
}})

Argument Action

console = true -- Command can be executed in console
console = false -- Command can not be executed in console

framework = true -- Use xPlayer
framework = false -- Use source

action = false -- string or whatever
action = 'number' -- only number is allowed
action = 'playerId' -- only a playerId as a number is allowed

val = true -- arguments has to be used
val = false -- argument is optional but you have to set it as last argument

MSK.HasItem

Checks if you have the item in your inventory (only for ESX or QBCore)

MSK.HasItem(xPlayer, item)

Example

local xPlayer = ESX.GetPlayerFromId(source) -- ESX
local xPlayer = QBCore.Functions.GetPlayer(source) -- QBCore
local hasItem = MSK.HasItem(xPlayer, 'bread') -- returns: name, label, count

MSK.GetPlayer

Get the Player from PlayerId, Identifier, CitizenId or Phone. This works for ESX and QBCore.

local xPlayer = MSK.GetPlayer({source = playerId})
local xPlayer = MSK.GetPlayer({identifier = playerIdentifier})
local xPlayer = MSK.GetPlayer({citizenid = playerCitizenId})
local xPlayer = MSK.GetPlayer({phone = 123456789})

MSK.GetPlayers

Get all the Players on the server.

local Players = MSK.GetPlayers() -- returns all players on the server
local Players = MSK.GetPlayers('job', 'police') -- returns only players with that specified job
local Players = MSK.GetPlayers('gang', 'bloods') -- returns only players with that specified gang *(Only QBCore)*
local Players = MSK.GetPlayers('group', 'admin') -- returns only player that have the group/permission 'admin'

Last updated