Server

Functions - Serverside

MSK.Register

Register Server Callback (MSK.Trigger)

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

-- Example
MSK.Register("msk_testing:serverCallback:1", function(source, a, b, c)
    print(source, a, b, c)
    return a, b, c
end)

MSK.Register("msk_testing:serverCallback:2", function(source, cb, a, b, c)
    print(source, a, b, c)
    cb(a, b, c)
    print('Have fun!')
end)

MSK.Trigger

Trigger Client Callback (MSK.Register)

local data = MSK.Trigger("Callback_Name", source, arg1, arg2, ...)

-- Example
local a, b, c = MSK.Trigger("msk_testing:clientCallback", source, '123', '456', '789')
print(a, b, c)

MSK.AddWebhook

Discord Webhook

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

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

-- Example
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.

Parameters source - string/number - The Player Server ID title - string - Title message - string - Message Text info - string - Optional - Default: general time - number <miliseconds> - Optional - Default: 5000

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

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

MSK.AdvancedNotification

Shows a Picture Notification

Parameters source - string/number - The Player Server ID text - string - Text title - string - Title subtitle - string - Subtitle icon - string - Optional - Default: CHAR_HUMANDEFAULT flash - boolean - Optional - Default: true icontype - number - Optional - Default: 1

-- 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.HasItem

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

Parameters itemName - string - The item name

Retuns hasItem - table <name, label, count> - If the player has the item

local hasItem = 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
print(hasItem.name, hasItem.label, hasItem.count)

MSK.GetPlayer

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

Parameters playerData - table <source, identifier, citizenid, phone> - Player Data

Retuns Player - table - The PlayerData

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

MSK.GetPlayers

Get all the Players on the server.

Parameters key - string - Optional value - string - Optional

Retuns Players - table <key, Player> - The PlayerData

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