Skip to content

Commit

Permalink
chore: esx_rpchat new commands available
Browse files Browse the repository at this point in the history
New commands introduced
- /twt
- /anontwt
- /me
- /do
  • Loading branch information
bitpredator committed Jun 23, 2024
1 parent fc96bc5 commit 2004c78
Show file tree
Hide file tree
Showing 19 changed files with 109 additions and 80 deletions.
4 changes: 2 additions & 2 deletions server-data/resources/[esx_addons]/esx_rpchat/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ 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-2022 Jérémie N'gadi
Copyright (C) 2015-2024 Jérémie N'gadi

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 @@ -652,7 +652,7 @@ 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-2022 Jérémie N'gadi
esx_rpchat Copyright (C) 2015-2024 Jérémie N'gadi
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 Down
8 changes: 3 additions & 5 deletions server-data/resources/[esx_addons]/esx_rpchat/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
<h1 align='center'>[ESX] RP Chat</a></h1><p align='center'><b><a href='https://discord.esx-framework.org/'>Discord</a> - <a href='https://esx-framework.org/'>Website</a> - <a href='https://docs.esx-framework.org/legacy/installation'>Documentation</a></b></h5>
<h1 align='center'>[ESX] RP Chat</a></h1><p align='center'><b><a href='https://discord.esx-framework.org/'>Discord</a> - <a href='https://documentation.esx-framework.org/legacy/installation'>Documentation</a></b></h5>

This Resource adds a proximity chat along with a few cool commands such as `/me` , `/ooc`

> *Note: Elon Musk Not Included*
This Resource adds a proximity chat along with a few cool commands such as `/me` , `/ooc` and `/twt`

# Legal

esx_rpchat - Chat closely with your friends.

Copyright (C) 2015-2022 Jérémie N'gadi
Copyright (C) 2015-2024 Jérémie N'gadi

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 the Free Software Foundation, either version 3 Of the License, Or (at your option) any later version.

Expand Down
37 changes: 26 additions & 11 deletions server-data/resources/[esx_addons]/esx_rpchat/client/main.lua
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
RegisterNetEvent("esx_rpchat:sendProximityMessage")
AddEventHandler("esx_rpchat:sendProximityMessage", function(playerId, title, message, color)
local player = PlayerId()
local target = GetPlayerFromServerId(playerId)
local player = PlayerId()
local target = GetPlayerFromServerId(playerId)

local playerPed = PlayerPedId()
local targetPed = GetPlayerPed(target)
local playerCoords = GetEntityCoords(playerPed)
local targetCoords = GetEntityCoords(targetPed)
local playerPed = PlayerPedId()
local targetPed = GetPlayerPed(target)
local playerCoords = GetEntityCoords(playerPed)
local targetCoords = GetEntityCoords(targetPed)

if target ~= -1 then
if target == player or #(playerCoords - targetCoords) < 20 then
TriggerEvent("chat:addMessage", { args = { title, message }, color = color })
end
end
if target ~= -1 then
if target == player or #(playerCoords - targetCoords) < 20 then
TriggerEvent("chat:addMessage", { args = { title, message }, color = color })
end
end
end)

CreateThread(function()
TriggerEvent("chat:addSuggestion", "/twt", TranslateCap("twt_help"), { { name = TranslateCap("generic_argument_name"), help = TranslateCap("generic_argument_help") } })
TriggerEvent("chat:addSuggestion", "/anontwt", TranslateCap("twtanon_help"), { { name = TranslateCap("generic_argument_name"), help = TranslateCap("generic_argument_help") } })
TriggerEvent("chat:addSuggestion", "/me", TranslateCap("me_help"), { { name = TranslateCap("generic_argument_name"), help = TranslateCap("generic_argument_help") } })
TriggerEvent("chat:addSuggestion", "/do", TranslateCap("do_help"), { { name = TranslateCap("generic_argument_name"), help = TranslateCap("generic_argument_help") } })
end)

AddEventHandler("onResourceStop", function(resource)
if resource == GetCurrentResourceName() then
TriggerEvent("chat:removeSuggestion", "/twt")
TriggerEvent("chat:removeSuggestion", "/me")
TriggerEvent("chat:removeSuggestion", "/do")
end
end)
4 changes: 2 additions & 2 deletions server-data/resources/[esx_addons]/esx_rpchat/config.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Config = {}

Config.Locale = "it"
Config.Locale = GetConvar("esx:locale", "it")
Config.OnlyFirstname = false
Config.EnableESXIdentity = true -- RP names
Config.EnableESXIdentity = false -- RP names
5 changes: 3 additions & 2 deletions server-data/resources/[esx_addons]/esx_rpchat/fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ fx_version("adamant")

game("gta5")

description("ESX RP Chat")
description("Adds Command for RP, such as: /me, /do, /OOC and more")
lua54("yes")

version("1.0.0")
version("1.0.1")

shared_script("@es_extended/imports.lua")

Expand Down
5 changes: 0 additions & 5 deletions server-data/resources/[esx_addons]/esx_rpchat/locales/cs.lua

This file was deleted.

5 changes: 0 additions & 5 deletions server-data/resources/[esx_addons]/esx_rpchat/locales/de.lua

This file was deleted.

5 changes: 0 additions & 5 deletions server-data/resources/[esx_addons]/esx_rpchat/locales/el.lua

This file was deleted.

6 changes: 6 additions & 0 deletions server-data/resources/[esx_addons]/esx_rpchat/locales/en.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
Locales["en"] = {
["ooc_prefix"] = "OOC | %s",
["twt_help"] = "send a tweet",
["twt_prefix"] = "^0[^4Twitter^0] (^5@%s^0)",
["me_help"] = "personal action",
["me_prefix"] = "me | %s",
["do_help"] = "RP information",
["do_prefix"] = "do | %s",
["generic_argument_name"] = "message",
["generic_argument_help"] = "the message",
}
5 changes: 0 additions & 5 deletions server-data/resources/[esx_addons]/esx_rpchat/locales/es.lua

This file was deleted.

5 changes: 0 additions & 5 deletions server-data/resources/[esx_addons]/esx_rpchat/locales/fi.lua

This file was deleted.

4 changes: 0 additions & 4 deletions server-data/resources/[esx_addons]/esx_rpchat/locales/fr.lua

This file was deleted.

5 changes: 0 additions & 5 deletions server-data/resources/[esx_addons]/esx_rpchat/locales/hu.lua

This file was deleted.

6 changes: 6 additions & 0 deletions server-data/resources/[esx_addons]/esx_rpchat/locales/it.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
Locales["it"] = {
["ooc_prefix"] = "OOC | %s",
["twt_help"] = "Invia tweet",
["twt_prefix"] = "^0[^4Twitter^0] (^5@%s^0)",
["me_help"] = "Azione Personale",
["me_prefix"] = "me | %s",
["do_help"] = "Azione RP",
["do_prefix"] = "fa | %s",
["generic_argument_name"] = "Messaggio",
["generic_argument_help"] = "il messaggio",
}
5 changes: 0 additions & 5 deletions server-data/resources/[esx_addons]/esx_rpchat/locales/nl.lua

This file was deleted.

5 changes: 0 additions & 5 deletions server-data/resources/[esx_addons]/esx_rpchat/locales/pl.lua

This file was deleted.

5 changes: 0 additions & 5 deletions server-data/resources/[esx_addons]/esx_rpchat/locales/sl.lua

This file was deleted.

5 changes: 0 additions & 5 deletions server-data/resources/[esx_addons]/esx_rpchat/locales/sr.lua

This file was deleted.

65 changes: 61 additions & 4 deletions server-data/resources/[esx_addons]/esx_rpchat/server/main.lua
Original file line number Diff line number Diff line change
@@ -1,13 +1,70 @@
AddEventHandler("chatMessage", function(playerId, _, message)
AddEventHandler("chatMessage", function(playerId, playerName, message)
if string.sub(message, 1, string.len("/")) ~= "/" then
CancelEvent()

local playerName
playerName = GetRealPlayerName(playerId)
TriggerClientEvent("chat:addMessage", -1, { args = { _U("ooc_prefix", playerName), message }, color = { 128, 128, 128 } })
TriggerClientEvent("chat:addMessage", -1, { args = { TranslateCap("ooc_prefix", playerName), message }, color = { 128, 128, 128 } })
end
end)

RegisterCommand("twt", function(playerId, args, rawCommand)
if playerId == 0 then
print("[^1ERROR^7] This Command Cannot Be Used By The Console!")
else
args = table.concat(args, " ")

local playerName = GetRealPlayerName(playerId)

TriggerClientEvent("chat:addMessage", -1, { args = { TranslateCap("twt_prefix", playerName), args }, color = { 0, 153, 204 } })
end
end, false)

RegisterCommand("anontwt", function(playerId, args, rawCommand)
if playerId == 0 then
print("[^1ERROR^7] This Command Cannot Be Used By The Console!")
else
args = table.concat(args, " ")

local playerName = GetRealPlayerName(playerId)

TriggerClientEvent("chat:addMessage", -1, { args = { TranslateCap("twt_prefix", "Anonymous"), args }, color = { 0, 153, 204 } })
end
end, false)

RegisterCommand("me", function(playerId, args, rawCommand)
if playerId == 0 then
print("[^1ERROR^7] This Command Cannot Be Used By The Console!")
else
args = table.concat(args, " ")
local playerName = GetRealPlayerName(playerId)

TriggerClientEvent("esx_rpchat:sendProximityMessage", -1, playerId, TranslateCap("me_prefix", playerName), args, { 255, 0, 0 })
end
end, false)

RegisterCommand("do", function(playerId, args, rawCommand)
if playerId == 0 then
print("[^1ERROR^7] This Command Cannot Be Used By The Console!")
else
args = table.concat(args, " ")
local playerName = GetRealPlayerName(playerId)

TriggerClientEvent("esx_rpchat:sendProximityMessage", -1, playerId, TranslateCap("do_prefix", playerName), args, { 0, 0, 255 })
end
end, false)

RegisterCommand("msg", function(source, args, user)
if GetPlayerName(tonumber(args[1])) then
local player = tonumber(args[1])
table.remove(args, 1)

TriggerClientEvent("chat:addMessage", player, { args = { "^1PM from " .. GetPlayerName(source) .. "[" .. source .. "]: ^7" .. table.concat(args, " ") }, color = { 255, 153, 0 } })
TriggerClientEvent("chat:addMessage", source, { args = { "^1PM SEND TO " .. GetPlayerName(player) .. "[" .. player .. "]: ^7" .. table.concat(args, " ") }, color = { 255, 153, 0 } })
else
TriggerClientEvent("chatMessage", source, "SYSTEM", { 255, 0, 0 }, "Specified Player Does Not Exist!")
end
end, false)

function GetRealPlayerName(playerId)
local xPlayer = ESX.GetPlayerFromId(playerId)

Expand All @@ -19,7 +76,7 @@ function GetRealPlayerName(playerId)
return xPlayer.getName()
end
else
return xPlayer.getName()
return GetPlayerName(playerId)
end
else
return GetPlayerName(playerId)
Expand Down

0 comments on commit 2004c78

Please sign in to comment.