# Encrypted Chat

## Introduction

Encrypted Chat will allow players to view and post on an encrypted phone. This uses a social media style system that allows players to post messages with a custom username and profile picture.

{% hint style="info" %}
By default, the chat command `/darkweb` is used to open the phone, however, this can also be configured to any command or even set up to be opened by using an item.
{% endhint %}

Players can change their username, profile picture, and phone size on the settings page.

This is a standalone script, however, you can enable QBCore support within the config.

***

## Installation

* Download the power\_encryptedChat from Keymaster
* Run the .sql file in your database. It is located within the README folder.
* Add the files to your resources folder
* Ensure that the resource file will start (either ensure your resource in the server.cfg or inside a folder which is started on server start)
* Edit the config file to your needs
* Restart your server

***

## Configuration

Select the tab below for your framework to see the configuration options available.

{% tabs %}
{% tab title="QBCore" %}

```lua
useStandalone = false  

useQBCore = true 

resourceName = 'qb-core' -- Only change if you have renamed your QBCore file

useItem = false -- True if you want to have the encrypted chat opened by using an item
itemName = 'darkweb_phone' -- Name of the item (if left as default, you will need to create an item)

usingRealtime = false -- False is based on game time / True is based on real-time

usingTimezone = 'Europe/London' -- You can view the names of time zones here. https://momentjs.com/timezone/

enableCommand = true -- True if you want a chat command to open the encrypted chat

commandName = 'darkweb' -- Command used to open the chat. The default would be /darkweb

restrictFromJobs = true -- True means specified jobs will not be able to open encrypted chat

restrictedJobs = {
 ['police'] = true -- This will disable players with the police job from using the encrypted chat.
}

costPerMessage = 0 -- 0 is disabled / Any value over 0 is the price per message
```

{% endtab %}

{% tab title="Standalone" %}
{% hint style="danger" %}
When used as standalone, your player data will be stored based on Rockstar license and not by character ID.

This is not recommended for servers that allow multiple characters per player.
{% endhint %}

```lua
useStandalone = true

useQBCore = false

-- QBCore Only
-- resourceName = 'qb-core' -- Only change if you have renamed your QBCore file

-- useItem = false -- True if you want to have the encrypted chat opened by using an item
-- itemName = 'darkweb_phone' -- Name of the item (if left as default, you will need to create an item)

usingRealtime = false -- False is based on game time / True is based on real-time

usingTimezone = 'Europe/London' -- You can view the names of time zones here. https://momentjs.com/timezone/

enableCommand = true -- True if you want a chat command to open the encrypted chat

commandName = 'darkweb' -- Command used to open the chat. The default would be /darkweb

-- restrictFromJobs = true -- True means specified jobs will not be able to open encrypted chat

-- restrictedJobs = {
--  ['police'] = true -- This will disable players with the police job from using the encrypted chat.
-- }

costPerMessage = 0 -- 0 is disabled / Any value over 0 is the price per message
```

{% hint style="warning" %}
If you want to use an item with standalone, you will need to create a useable item that triggers the following client event:

```lua
power_encryptedChat:open
```

{% endhint %}
{% endtab %}
{% endtabs %}

***

## Editable files

### client.lua

#### Custom Notifications

If you would like to edit the notifications to add your own custom notifications or to match them to your other server notifications, you can edit them in the client.lua file. Default notifications are as follows:

```lua
-- Edit the below if you would like to change the notification type.
RegisterNetEvent('power_encryptedChat:newMessageNotfication')
AddEventHandler('power_encryptedChat:newMessageNotfication', function(username)
 TriggerEvent('chat:addMessage', {color = {255, 255, 255}, args = {"^8DARKWEB", 'New Post from '..username}})
end)

RegisterNetEvent('power_encryptedChat:notification')
AddEventHandler('power_encryptedChat:notification', function(message)
 TriggerEvent('chat:addMessage', {color = {255, 255, 255}, args = {"^8DARKWEB", message}})
end)
```

### server.lua

#### Discord Webhook

If you would like to add a discord webhook, you can add it to the server.lua. Be sure to change the CHANGEME to your webhook URL.

```lua
the-- Discord Webhook
-- Sends a copy of the darkweb message to discord as a chat message using the webhook.
local enableDiscordWebhook = true

-- Discord Webhook URL 
local discordWebhookURL = "https://discord.com/api/webhooks/CHANGEME"  

function discordMessage(data)
 if enableDiscordWebhook then 
  local embeds = {}
  if string.len(data.image) > 0 then 
   embeds = {{image = {url = data.image}}}
  end 
  PerformHttpRequest(discordWebhookURL, function(Error, Content, Head) end, 'POST', json.encode({username = data.username, embeds = embeds, content = data.message, avatar_url = data.picture}), {['Content-Type'] = 'application/json'})
 end 
end 
```

#### Money Management

If you would like the money taken from the cost per message to be added into a money management fund, you can add in your custom code in the server.lua here:

```lua
function moneyTakenForPost(source, costPerMessage)
 -- You can add your own code here to add money that is taken from the player to a management fund.
end 
```

***

### Emojis

The following emoji's can be used within the chat with the following text codes

```
:smile: - 😄
:joy: - 😂
:heart_eyes: - 😍
:sob: - 😭
:rolling_eyes: - 🙄
:weary: - 😩
:thinking: - 🤔
:blush: - 😊
:skull: - 💀
:unamused: - 😒
:kissing_heart: - 😘
:relieved: - 😌
:sleeping: - 😴
:s_smile: - 😅
:eyes: - 👀
:smirk: - 😏
:sunglasses: - 😎
:devil: - 😈
:flushed: - 😳
:grin: - 😁
:pensive: - 😔
:pray: - 🙏
:stuck_out_tongue: - 😛
:hug: - 🤗
:tired: - 😫
:confused: - 😕
:tongue_wink: - 😜
:innocent: - 😇
:raised_hands: - 🙌
:cry: - 😢
:heart_eyes_cat: - 😻
:yum: - 😋
:wink: - 😉
:slight_smile: - 🙂
:goat: - 🐐
:sleepy: - 😪
:crown: - 👑
:heart: - ❤️
:ok: - 👌
:tongue: - 👅
:ring: - 💍
:kiss: - 💋
:mask: - 😷
:money_face: - 🤑
:scream: - 😱
:flex: - 💪
:v: - ✌️
:poo: - 💩
:fist: - ✊
:cold_sweat: - 😰
:ghost: - 👻
:nerd: - 🤓
:bikini: - 👙
:hurt: - 🤕
:lipstick: - 💄
:nails: - 💅
:point_up: - ☝️
:wave: - 👋
:thumb_down: - 👎
:thumb_up 👍
:shock: - 😮
:vulcan: - 🖖
:call_me: - 🤙
:clown: - 🤡
:vomit: - 🤮
:rainbow: - 🌈
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.power-scripts.com/encrypted-chat.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
