Skip to content

Commit

Permalink
chore: replace esx_rpchat with cc-chat
Browse files Browse the repository at this point in the history
  • Loading branch information
bitpredator committed Aug 10, 2024
1 parent 25e3ef2 commit e51e065
Show file tree
Hide file tree
Showing 13 changed files with 460 additions and 190 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007

Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.

Expand Down Expand Up @@ -631,8 +631,8 @@ to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

esx_rpchat
Copyright (C) 2015-2024 Jérémie N'gadi
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand All @@ -645,14 +645,14 @@ the "copyright" line and a pointer to where the full notice is found.
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
along with this program. If not, see <https://www.gnu.org/licenses/>.

Also add information on how to contact you by electronic and paper mail.

If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:

esx_rpchat Copyright (C) 2015-2024 Jérémie N'gadi
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
Expand All @@ -664,11 +664,11 @@ might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
<https://www.gnu.org/licenses/>.

The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
<https://www.gnu.org/licenses/why-not-lgpl.html>.
71 changes: 71 additions & 0 deletions server-data/resources/[esx_addons]/cc-chat/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<h4 align="center">
<img src="https://img.shields.io/github/release/Concept-Collective/cc-chat.png">
<img src="https://img.shields.io/github/last-commit/Concept-Collective/cc-chat">
<img src="https://img.shields.io/github/license/Concept-Collective/cc-chat.png">
<img src="https://img.shields.io/github/issues/Concept-Collective/cc-chat.png">
<img src="https://img.shields.io/github/contributors/Concept-Collective/cc-chat.png">
<a href="https://discord.gg/PSqXgg8v8M" title=""><img alt="Discord Status" src="https://discordapp.com/api/guilds/807309391849062480/widget.png"></a>
</h4>

<div align="center">
<img src="https://user-images.githubusercontent.com/24248108/164179346-a4f24916-7c9f-42db-b89e-6df85b01ca61.jpg">
<h1 align="center">🎨 CC Chat - Chat Theme</h1>
<p align="center">
CC Chat is a chat theme that includes a <a href="https://github.com/Concept-Collective/cc-rpchat">custom message template</a> for FiveM's default chat resource.
<br/>
<b><a href='https://discord.conceptcollective.net'>Discord</a> - <a href='https://cc-chat.conceptcollective.net/'>Documentation</a> - <a href="https://github.com/Concept-Collective/cc-chat/issues">Report Bug</a> - <a href="https://github.com/Concept-Collective/cc-chat/issues">Request Feature</a></b></h5>
</p>
<a href="https://discord.gg/PSqXgg8v8M" title=""><img alt="Discord Invite" src="https://discordapp.com/api/guilds/807309391849062480/widget.png?style=banner2"></a>
</div>

### 🖼️ Showcase

<details>
<summary>Screenshots</summary>
<br>
<img src="https://user-images.githubusercontent.com/24248108/163717930-36500cde-fa37-449a-b70b-ca25435b5493.png">
<img src="https://user-images.githubusercontent.com/24248108/163717928-fcd3c93a-622e-4ad2-b426-36ed15124af0.png">
<img src="https://user-images.githubusercontent.com/24248108/163717929-00984374-ac7f-4248-9631-96c6a715e819.png">
</details>

### ⚠️ Important Notice
**If CC Chat is a dependency for another resource you can ignore this notice.**

Please note that this resource **does not include** any pre-written commands or chat messages; you will need to **create them yourself**. It is designed for people who have some experience with scripting. Only those who have some idea of what they're doing will be given support.

### ✅ Features

- Custom text input box
- Custom suggestions box
- A ready-to-use chat template
- Anti-spam system
- [Font Awesome](https://fontawesome.com/) icons (v6.2.1)
- Completely customisable
- Free Forever

### 🛠 Installation
Official guide to installing **CC Chat**.

**Dependencies**
- [Chat](https://github.com/citizenfx/cfx-server-data/tree/master/resources/%5Bgameplay%5D/chat)

**Download**
- Download the [latest releases](https://github.com/Concept-Collective/cc-chat/releases/latest) of cc-chat.

**Install**
- Create a new folder in your resources folder named ``cc-chat``
- Extract the archive's contents to your ``cc-chat`` folder.
- ensure ``cc-chat`` anywhere after the default ``chat`` resource in your ``server.cfg``.

### 🙋 Support
- [Discord](https://discord.conceptcollective.net)

--------
### License
For an updated license, check the ``License`` file. That file will always overrule anything mentioned in the ``readme.md``

cc-chat - Concept Collective

Copyright © 2022 Concept Collective. All rights reserved.

You can use and edit this code to your liking as long as you don't ever claim it to be your own code and always provide proper credit. You're not allowed to sell cc-chat or any code you take from it. If you want to release your own version of cc-chat, you have to link the original GitHub repo, or release it via a Forked repo.
23 changes: 23 additions & 0 deletions server-data/resources/[esx_addons]/cc-chat/client/main.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
function getTimestamp()
local meridiem = 'AM'
year , month , day , hour , minute , second = ''
if GetGameName() == 'fivem' then
year , month , day , hour , minute , second = GetLocalTime()
elseif GetGameName() == 'redm' then
year , month , day , hour , minute , second = GetPosixTime()
end
if hour >= 13 then
hour = hour - 12
meridiem = 'PM'
end
if hour == 12 then
meridiem = 'PM'
end
if minute <= 9 then
minute = '0' .. minute
end
timestamp = hour .. ':' .. minute .. ' ' .. meridiem
return timestamp
end

exports('getTimestamp', getTimestamp)
26 changes: 26 additions & 0 deletions server-data/resources/[esx_addons]/cc-chat/fxmanifest.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
version '1.4.1'
author 'Concept Collective'
description 'A chat theme for FiveM'

lua54 'yes'

server_script 'server/main.lua'
client_script 'client/main.lua'

dependency 'chat'

file 'theme/style.css'

chat_theme 'ccChat' {
styleSheet = 'theme/style.css',
msgTemplates = {
ccChat = '<div id="notification" class="noisy"><div id="color-box" style="background-color: {0} !important;" class="noisy"></div><div id="info"><div id="top-info"><div id="left-info"><h1 id="title"><i class="{1}"></i></h1><h2 id="sub-title">{2}</h2></div><h2 id="time">{3}</h2></div><div id="bottom-info"><br><p id="text">{4}</p></div></div>'
}
}

exports {
'getTimestamp'
}

game 'common'
fx_version 'adamant'
62 changes: 62 additions & 0 deletions server-data/resources/[esx_addons]/cc-chat/server/main.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
local svConfig = {}

-- Configuration
svConfig.versionChecker = true -- Version Checker
svConfig.supportChecker = true -- Support Checker (If you use exports, it is recommended that you leave this on)

-- Script
AddEventHandler('onResourceStart', function(resourceName)
if (GetCurrentResourceName() ~= resourceName) then
return
end
if GetCurrentResourceName() ~= 'cc-chat' and svConfig.supportChecker == true then
print('^6[Warning]^0 For better support, it is recommended that "'..GetCurrentResourceName().. '" be renamed to "cc-chat"')
end
if svConfig.versionChecker == true then
PerformHttpRequest('https://api.github.com/repos/Concept-Collective/cc-chat/releases/latest', function (err, data, headers)
if data == nil then
print('An error occurred while checking the version. Your firewall may be blocking access to "github.com". Please check your firewall settings and ensure that "github.com" is allowed to establish connections.')
return
end

local data = json.decode(data)
if data.tag_name ~= 'v'..GetResourceMetadata(GetCurrentResourceName(), 'version', 0) then
print('\n^1================^0')
print('^1CC Chat ('..GetCurrentResourceName()..') is outdated!^0')
print('Current version: (^1v'..GetResourceMetadata(GetCurrentResourceName(), 'version', 0)..'^0)')
print('Latest version: (^2'..data.tag_name..'^0) '..data.html_url)
print('Release notes: '..data.body)
print('^1================^0')
end
end, 'GET', '')
end
end)

-- Antispam System (Beta)
local users = {}
function checkSpam(source, message)
local BlockedStatus = false

-- Checks if the user has sent a message before
if users[source] == nil then
users[source] = {time = os.time()}
return false
end

-- Check if the user has sent messages too quickly
if os.time() - users[source].time < 2 then
BlockedStatus = true
end

-- Check if the message is a repeat of the last message
if message == users[source].lastMessage then
BlockedStatus = true
end

-- Update the user's information in the table
users[source] = {lastMessage = message, time = os.time()}

return BlockedStatus
end

exports('checkSpam', checkSpam)
Loading

0 comments on commit e51e065

Please sign in to comment.