# Client

## MSK.Register

Register Client Callback *(*[*MSK.Trigger*](https://docu.msk-scripts.de/scripts/msk-core/server#msk.triggerclientcallback)*)*

```lua
MSK.Register("Callback_Name", function(playerId, arg1, arg2, ...)
    return ...
end)

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

-- As an Export:
expoorts.msk_core:Register("msk_testing:clientCallback", function(source, a, b, c)
    print(source, a, b, c)
    return a, b, c
end)
```

## MSK.Trigger

Trigger Server Callback *(*[*MSK.Register*](https://docu.msk-scripts.de/scripts/msk-core/server#msk.register)*)*

```lua
local data = MSK.Trigger("Callback_Name", ...)

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

-- As an Export:
local a, b, c = expoorts.msk_core:Trigger("msk_testing:serverCallback:1", '123', '456', '789')
```

## MSK.TriggerCallback

Trigger Server Callback *(*[*MSK.Register*](https://docu.msk-scripts.de/scripts/msk-core/server#msk.register)*)*

```lua
local data = MSK.TriggerCallback("Callback_Name", ...)

-- Example
local a, b, c = MSK.TriggerCallback("msk_testing:serverCallback:2", '123', '456', '789')
print(a, b, c)

-- As an Export:
local a, b, c = expoorts.msk_core:TriggerCallback("msk_testing:serverCallback:2", '123', '456', '789')
```

## MSK.RegisterCommand

It's the same as the Native RegisterCommand but it will check if the player has AcePermission.

```lua
MSK.RegisterCommand('your_command', function(source, args, raw)
    -- Do something here
end, true --[[true = ace check; false = no ace check]])

-- As an Export:
expoorts.msk_core:RegisterCommand('your_command', function(source, args, raw)
    -- Do something here
end, true --[[true = ace check; false = no ace check]])
```

## MSK.Notification

Show a Notification.\
You can use farbcodes like: `~g~`

<details>

<summary>Preview</summary>

<img src="https://1100044979-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6IG4qpnsvwJ4tB5edczg%2Fuploads%2FZUIMJwos6UMuLpnf88Q3%2FScreenshot_283.png?alt=media&#x26;token=7aa7ddec-88e7-4afb-becf-96e84ec62d6f" alt="" data-size="original">

</details>

<mark style="color:red;">**Parameters**</mark>\
**title** - `string` - Title\
**message** - `string` - Message Text\
**info** - `string` - Optional - Default: general\
**time** - `number <miliseconds>` - Optional - Default: 5000

```lua
MSK.Notification(title, message, info, duration)

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

-- As an Export:
exports.msk_core:Notification(title, message, info, duration)
```

## MSK.HelpNotification

Show a Help Notification

<mark style="color:red;">**Parameters**</mark>\
**text** - `string` - Text

```lua
MSK.HelpNotification(text)

-- Example
MSK.HelpNotification('Press ~g~E~s~ to open')

-- As an Export:
exports.msk_core:HelpNotification(text)
```

## MSK.AdvancedNotification

Show a Picture Notification

<mark style="color:red;">**Parameters**</mark>\
**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

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

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

-- As an Export:
exports.msk_core:AdvancedNotification(text, title, subtitle, icon, flash, icontype)
```

## MSK.Draw3DText

Draw a 3D Text *(size and font is optional)*

Needs to be executed every frame!

<mark style="color:red;">**Parameters**</mark>\
**location** - `table <x, y, z> / vector3` - Location\
**text** - `string` - Text\
**size** - `number` - Optional - Default: 1\
**font** - `number` - Optional - Default: 0

```lua
MSK.Draw3DText(location, text, size, font)

-- Example
local location = GetEntityCoords(PlayerPedId())
MSK.Draw3DText(location, 'This is the Label Text', 1, 0)
MSK.Draw3DText(location, 'This is the Label Text')

-- As an Export:
exports.msk_core:Draw3DText(location, text, size, font)
```

## MSK.DrawGenericText

Draw Generic Text.

Needs to be executed every frame!

<mark style="color:red;">**Parameters**</mark>\
**text** - `string` - Text\
**outline** - `boolean` - Text Outline\
**font** - `number` - Text Font - ***Optional, default: 0***\
**size** - `float` - Text Size - ***Optional, default: 0.34***\
**color** - `table <r, g, b, a>` - Text Color - ***Optional, default: white***\
**position** - `string` - Text Position on the Screen - ***Optional, default: bottom center***

```lua
MSK.DrawGenericText(text, outline, font, size, color, position)

-- Example
local color = {r = 255, g = 255, b = 255, a = 255}
local position = {width = 0.50, height = 0.90}
MSK.DrawGenericText('Test', true, 0, 0.34, color, position)

-- As an Export:
exports.msk_core:DrawGenericText(text, outline, font, size, color, position)
```

## MSK.HasItem

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

<mark style="color:red;">**Parameters**</mark>\
**itemName** - `string` - The item name

<mark style="color:green;">**Returns**</mark>\
**hasItem** - `table <name, label, count>` - If the player has the item

```lua
local hasItem = MSK.HasItem(itemName)

-- Example
local hasItem = MSK.HasItem('bread') -- returns: name, label, count
print(hasItem.name, hasItem.label, hasItem.count)

-- As an Export:
local hasItem = exports.msk_core:HasItem(itemName)
```

## MSK.GetPedMugshot

Get the PedMugshot from a specific Ped.

<mark style="color:red;">**Parameters**</mark>\
**playerPed** - `number` - The Player Ped\
**transparent** - `boolean` - Transparent Background

```lua
local mugshot, mugshotStr = MSK.GetPedMugshot(playerPed, transparent)
UnregisterPedheadshot(mugshot) -- You have to call this to delete the unregister the mugshot after use

-- Example
local mugshot, mugshotStr = MSK.GetPedMugshot(PlayerPedId(), true)
MSK.AdvancedNotification('Message', 'Title', 'Subtitle', mugshotStr)
UnregisterPedheadshot(mugshot)

-- As an Export:
local mugshot, mugshotStr = exports.msk_core:GetPedMugshot(playerPed, transparent)
```

## MSK.Subtitle

Shows a text at the center-bottom.\
You can use farbcodes like: `~g~`

<details>

<summary>Preview</summary>

<img src="https://1100044979-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6IG4qpnsvwJ4tB5edczg%2Fuploads%2F8gzslO62RpCsWlGll5LC%2Fmsk_subtitle.png?alt=media&#x26;token=e8dc77d8-2483-4106-993d-e1c52e310545" alt="" data-size="original">

</details>

<mark style="color:red;">**Parameters**</mark>\
**text** - `string` - The message text\
**duration** - `number <miliseconds>` - Duration in miliseconds - ~~**Optional:**~~ ~~`default: 8000`~~

```lua
MSK.Subtitle(text, duration)

-- Example
MSK.Subtitle('This is a Subtitle by ~g~MSK Scripts~s~', 8000)

-- As an Export:
exports.msk_core:Subtitle(text, duration)
```

## MSK.Spinner

Shows a Loading Spinner at the right-bottom

<details>

<summary>Preview</summary>

Type 4

<img src="https://1100044979-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6IG4qpnsvwJ4tB5edczg%2Fuploads%2FIRpG6Bg3LIRyusMZdse0%2Fmsk_spinner_4.png?alt=media&#x26;token=d0197e46-6d87-4603-906f-a1a91f45e7bb" alt="" data-size="original">

Type 5

<img src="https://1100044979-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6IG4qpnsvwJ4tB5edczg%2Fuploads%2FSkuHM7rXIFSdhVtytcGZ%2Fmsk_spinner_5.png?alt=media&#x26;token=e3bf6567-0233-4df1-8184-365d618df467" alt="" data-size="original">

</details>

<mark style="color:red;">**Parameters**</mark>\
**text** - `string` - The message text\
**typ** - `number` - The Spinner Type - **Optional:** `default: 4`\
**duration** - `number <miliseconds>` - Duration in miliseconds - **Optional:** `default: 5000`

```lua
MSK.Spinner(text, typ, duration)

-- Example: Orange Spinner
MSK.Spinner('This is a Spinner by MSK Scripts', 4, 8000)
-- Example: White Spinner
MSK.Spinner('This is a Spinner by MSK Scripts', 5, 8000)

-- As an Export:
exports.msk_core:Spinner(text, typ, duration)
```
