# CM Notification

## -----INSTALLATION------

## STEP 1 - Drag And Drop

Drag cm-notification into your resources folder.

## STEP 2 - Add SQL

```sql
CREATE TABLE IF NOT EXISTS `cm_notify` (
  `identifier` varchar(65) DEFAULT NULL,
  `position` longtext DEFAULT NULL,
  UNIQUE KEY `identifier` (`identifier`) USING HASH
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
```

## STEP 3 - Edit Functions Lua

IF Framework is QB Core - Go to qb-core/client/functions.lua

IF Framework is ESX - Go to es\_extended/client/functions.lua

## STEP 4 - Find Function

IF Framework is QB Core - Find this function QBCore.Functions.Notify

IF Framework is ESX - Find this function ESX.ShowNotification

## STEP 5 - Replace Code

* FOR QB Core

Replace QBCore.Functions.Notify function with the code down below

function QBCore.Functions.Notify(text, texttype, length)

```lua
function QBCore.Functions.Notify(text, texttype, length)
    if type(text) == "table" then
        local ttext = text.text or 'Placeholder'
        local caption = text.caption or 'Placeholder'
        texttype = texttype or 'info'
        length = length or 5000
        exports['cm-notification']:Alert(caption, ttext, length, texttype)
    else
        texttype = texttype or 'info'
        length = length or 5000
        exports['cm-notification']:Alert("NOTIFICATION", text, length, texttype)
    end
end
```

* FOR ESX

Replace ESX.ShowNotification function with the code down below

function ESX.ShowNotification(text, texttype, length)

<pre class="language-lua"><code class="lang-lua"><strong>function ESX.ShowNotification(text, texttype, length)
</strong>    if type(text) == "table" then
        local ttext = text.text or 'Placeholder'
        local caption = text.caption or 'Placeholder'
        texttype = texttype or 'info'
        length = length or 5000
        exports['cm-notification']:Alert(caption, ttext, length, texttype)
    else
        texttype = texttype or 'info'
        length = length or 5000
        exports['cm-notification']:Alert("NOTIFICATION", text, length, texttype)
    end
end
</code></pre>

## -----INFORMATION------

### Information - 1 How to use events or exports

{% hint style="danger" %}
IMPORTANT NOTE : This requires lua knowledge and a bit html, css knowledge (only if you want to color some texts )
{% endhint %}

* If you want to trigger the notification from the client side you can use the example down below According to this example
* 1st parameter is the title of notify you want to display
* 2nd parameter is the text you want to display
* 3rd parameter is how long time notification will be displayed on the screen
* 4th parameter is the notification type (more types can be find in notification types category)

```lua
exports['cm-notification']:Alert("Title", "Message", Time, 'type')
```

* If you want to trigger the notification from server side use the example down below Only things change here are TriggerEvent needs to be replaced with TriggerClientEvent and source (id) of a player you want to show notification

```lua
TriggerClientEvent('cm-notification:Alert', source, "Title", "Message", Time, 'type')
```

### Information - 2 Notification Types

* success
* info
* warning
* error
* announcement

## Preview

{% embed url="<https://cdn.discordapp.com/attachments/1127448823036399666/1135869254466543637/Temp_5.png>" %}

## TEBEX

<https://shopcm.tebex.io/category/cm-series>

### Discord

<https://discord.gg/vgHzAv7u>
