From c0b0714c35935fdd482bff77cd89509307c836fe Mon Sep 17 00:00:00 2001 From: n0tst3 <74063176+DeffoN0tSt3@users.noreply.github.com> Date: Fri, 22 Jul 2022 13:38:17 +0100 Subject: [PATCH 1/9] Added /do command --- client.lua | 73 ++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 54 insertions(+), 19 deletions(-) diff --git a/client.lua b/client.lua index 1e9245d..c178351 100644 --- a/client.lua +++ b/client.lua @@ -1,21 +1,18 @@ --- @desc Client-side /me handling --- @author Elio --- @version 3.0 - -local c = Config -- Pre-load the config -local lang = Languages[Config.language] -- Pre-load the language -local peds = {} + -- edit by n0tst3 + local c = Config -- Pre-load the config + local lang = Languages[Config.language] -- Pre-load the language + local peds = {} -- Localization -local GetGameTimer = GetGameTimer + local GetGameTimer = GetGameTimer -- @desc Draw text in 3d -- @param coords world coordinates to where you want to draw the text -- @param text the text to display -local function draw3dText(coords, text) + local function draw3dText(coords, text) local camCoords = GetGameplayCamCoord() local dist = #(coords - camCoords) - + -- Experimental math to scale the text down local scale = 200 / (GetGameplayCamFov() * dist) @@ -39,7 +36,7 @@ end -- @desc Display the text above the head of a ped -- @param ped the target ped -- @param text the text to display -local function displayText(ped, text) + local function displayMeText(ped, text) local playerPed = PlayerPedId() local playerPos = GetEntityCoords(playerPed) local targetPos = GetEntityCoords(ped) @@ -59,7 +56,7 @@ local function displayText(ped, text) while display do Wait(0) - local pos = GetOffsetFromEntityInWorldCoords(ped, 0.0, 0.0, 1.0) + local pos = GetOffsetFromEntityInWorldCoords(ped, 0.0, 0.0, 0.7) draw3dText(pos, peds[ped].text) display = GetGameTimer() <= peds[ped].time end @@ -70,19 +67,57 @@ local function displayText(ped, text) end end --- @desc Trigger the display of teh text for a player --- @param text text to display --- @param target the target server id -local function onShareDisplay(text, target) + local function displayDoText(ped, text) + local playerPed = PlayerPedId() + local playerPos = GetEntityCoords(playerPed) + local targetPos = GetEntityCoords(ped) + local dist = #(playerPos - targetPos) + local los = HasEntityClearLosToEntity(playerPed, ped, 17) + + if dist <= c.dist and los then + local exists = peds[ped] ~= nil + + peds[ped] = { + time = GetGameTimer() + c.time, + text = text + } + + if not exists then + local display = true + + while display do + Wait(0) + local pos = GetOffsetFromEntityInWorldCoords(ped, 0.0, 0.0, 0.45) + draw3dText(pos, peds[ped].text) + display = GetGameTimer() <= peds[ped].time + end + + peds[ped] = nil + end + + end +end + +local function onDoShareDisplay(text, target) + local player = GetPlayerFromServerId(target) + if player ~= -1 or target == GetPlayerServerId(PlayerId()) then + local ped = GetPlayerPed(player) + displayDoText(ped, text) + end +end + +local function onMeShareDisplay(text, target) local player = GetPlayerFromServerId(target) if player ~= -1 or target == GetPlayerServerId(PlayerId()) then local ped = GetPlayerPed(player) - displayText(ped, text) + displayMeText(ped, text) end end -- Register the event -RegisterNetEvent('3dme:shareDisplay', onShareDisplay) +RegisterNetEvent('3ddo:shareDisplay', onDoShareDisplay) +RegisterNetEvent('3dme:shareDisplay', onMeShareDisplay) -- Add the chat suggestion -TriggerEvent('chat:addSuggestion', '/' .. lang.commandName, lang.commandDescription, lang.commandSuggestion) +TriggerEvent('chat:addSuggestion', '/' .. lang.doCommandName, lang.doCommandDescription, lang.doCommandSuggestion) +TriggerEvent('chat:addSuggestion', '/' .. lang.meCommandName, lang.meCommandDescription, lang.meCommandSuggestion) From 397ba8b452600ab6b70047f5dd85590ab7b5d412 Mon Sep 17 00:00:00 2001 From: n0tst3 <74063176+DeffoN0tSt3@users.noreply.github.com> Date: Fri, 22 Jul 2022 13:38:56 +0100 Subject: [PATCH 2/9] Added /do --- server.lua | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/server.lua b/server.lua index c8df482..7663991 100644 --- a/server.lua +++ b/server.lua @@ -1,15 +1,19 @@ --- @desc Server-side /me handling --- @author Elio --- @version 3.0 - +-- edit by n0tst3 -- Pre-load the language local lang = Languages[Config.language] --- @desc Handle /me command +-- @desc Handle /do command +local function onDoCommand(source, args) + local text = "~b~* " .. lang.doPrefix .. table.concat(args, " ") .. " " + TriggerClientEvent('3ddo:shareDisplay', -1, text, source) +end + local function onMeCommand(source, args) - local text = "* " .. lang.prefix .. table.concat(args, " ") .. " *" + local text = "~r~** " .. lang.mePrefix .. table.concat(args, " ") .. " **" TriggerClientEvent('3dme:shareDisplay', -1, text, source) end --- Register the command -RegisterCommand(lang.commandName, onMeCommand) +-- Register the commands +RegisterCommand(lang.doCommandName, onDoCommand) + +RegisterCommand(lang.meCommandName, onMeCommand) From 3b0a559c585ec105664869218f280c8a33c28437 Mon Sep 17 00:00:00 2001 From: n0tst3 <74063176+DeffoN0tSt3@users.noreply.github.com> Date: Fri, 22 Jul 2022 13:40:33 +0100 Subject: [PATCH 3/9] Update fxmanifest.lua --- fxmanifest.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/fxmanifest.lua b/fxmanifest.lua index 1a5bf24..91efb68 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -1,10 +1,12 @@ fx_version 'cerulean' game 'gta5' -author 'Elio' -description '/me command but it\'s 3D printed' -version '3.0' +author '@Elio - Edit @n0tst3' +description '/me command with /do ' +version '3.1 n0tst3 edit' shared_script 'config.lua' client_script 'client.lua' server_script 'server.lua' + +lua54 'yes' From e4ddbb842536cd2bb8d63af508e66c997a96339e Mon Sep 17 00:00:00 2001 From: n0tst3 <74063176+DeffoN0tSt3@users.noreply.github.com> Date: Fri, 22 Jul 2022 13:45:18 +0100 Subject: [PATCH 4/9] Added Ger lang & Do command --- config.lua | 50 +++++++++++++++++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 13 deletions(-) diff --git a/config.lua b/config.lua index 02f1644..52e4662 100644 --- a/config.lua +++ b/config.lua @@ -1,10 +1,11 @@ +-- edit by n0tst3 -- @desc Shared config file -- @author Elio -- @version 2.0 -- Global configuration Config = { - language = 'en', + language = 'de', color = { r = 230, g = 230, b = 230, a = 255 }, -- Text color font = 0, -- Text font time = 5000, -- Duration to display the text (in ms) @@ -15,21 +16,44 @@ Config = { -- Languages available Languages = { ['en'] = { - commandName = 'me', - commandDescription = 'Display an action above your head.', - commandSuggestion = {{ name = 'action', help = '"scratch his nose" for example.'}}, - prefix = 'the person ' + doCommandName = 'do', + doCommandDescription = 'Describe or respond in roleplay.', + doCommandSuggestion = {{ name = 'action', help = '"Is the door open??" for example.'}}, + doPrefix = ' ' , -- Add prefix if required. i.e "The Person" + meCommandName = 'me', + meCommandDescription = 'Displays an action or emote your character is performing.', + meCommandSuggestion = {{ name = 'action', help = '"shoves his hand in his back pocket" for example.'}}, + mePrefix = ' ' -- Add prefix if required. i.e "The Person" }, ['fr'] = { - commandName = 'me', - commandDescription = 'Affiche une action au dessus de votre tête.', - commandSuggestion = {{ name = 'action', help = '"se gratte le nez" par exemple.'}}, - prefix = 'l\'individu ' + doCommandName = 'do', + doCommandDescription = 'Décrivez ou répondez dans le jeu de rôle..', + doCommandSuggestion = {{ name = 'action', help = '"La porte est-elle ouverte??" par exemple.'}}, + doPrefix = ' ' , -- Add prefix if required. i.e "The Person" + meCommandName = 'me', + meCommandDescription = 'Affiche une action ou une emote que votre personnage effectue.', + meCommandSuggestion = {{ name = 'action', help = '"met sa main dans sa poche arrièret" par exemple.'}}, + mePrefix = ' ' -- Add prefix if required. i.e "The Person" + }, + ['de'] = { + doCommandName = 'do', + doCommandDescription = 'Beschreiben oder antworten Sie im Rollenspiel.', + doCommandSuggestion = {{ name = 'action', help = '"Ist die Tür offen??" zum Beispiel.'}}, + doPrefix = ' ' , -- Add prefix if required. i.e "The Person" + meCommandName = 'me', + meCommandDescription = 'Zeigt eine Aktion oder ein Emote an, das Ihr Charakter ausführt.', + meCommandSuggestion = {{ name = 'action', help = '"schiebt seine Hand in seine Gesäßtasche" zum Beispiel.'}}, + mePrefix = ' ' -- Add prefix if required. i.e "The Person" }, ['dk'] = { - commandName = 'me', - commandDescription = 'Viser en handling over hovedet.', - commandSuggestion = {{ name = 'Handling', help = '"Tager en smøg op ad lommen" for eksempel.'}}, - prefix = 'Personen ' + doCommandName = 'do', + doCommandDescription = 'Beskriv eller svar i rollespil', + doCommandSuggestion = {{ name = 'action', help = '"Er døren åpen?" For eksempel.'}}, + doPrefix = ' ' , -- Add prefix if required. i.e "The Person" + meCommandName = 'me', + meCommandDescription = 'Viser en handling eller følelse karakteren din utfører', + meCommandSuggestion = {{ name = 'action', help = '"dytter hånden i baklommen" For eksempel.'}}, + mePrefix = ' ' -- Add prefix if required. i.e "The Person" }, } + From 683c0bec489dcf5208f90f30b672d5a36b7fc2c5 Mon Sep 17 00:00:00 2001 From: n0tst3 <74063176+DeffoN0tSt3@users.noreply.github.com> Date: Fri, 22 Jul 2022 14:06:09 +0100 Subject: [PATCH 5/9] added /do, change info --- README.md | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 7426928..e8d764b 100644 --- a/README.md +++ b/README.md @@ -1,35 +1,37 @@ -# 3D /me -A FiveM script written in LUA that implements the /me command with 3D printing. +# Standalone 3D /me & /do command +# Creds @Eblio - Edit by n0tst3 +A FiveM script written in LUA that implements the /me & /do command with 3D printing. +## ME Command The /me command allows you to display a specific action above the head of a player. It's particularly used for actions that couldn't have been done in game in a roleplay context. +/me + - +## DO Command +The /do command is used primarily in serious roleplay servers and is used to describe something in your enviroment or state a fact in roleplay. It is also used if you want to ask something roleplay wise. +example: /do is the door open? + + ## Installation * Download the resource ; * Drag and drop it into your resources folder ; -* Add ```ensure 3dme``` to your server configuration file. +* To Change language; Edit Config.lua > line 8 +* Add ```ensure 3d-me-do``` to your server configuration file. ## How to use -* In the chat, type /me followed by your action. +* /me & /do in chat. ## Options | Parameter | Line | Suggestion | | --- | --- | --- | -| Color of the text | ```config.lua``` : line 6 | ```color = { r = 230, g = 230, b = 230, a = 255 }``` | -| Font of the text | ```config.lua``` : line 7 | ```font = 0``` ([available fonts](https://imgur.com/a/oV3ciWs)) | | Time on screen | ```config.lua``` : line 8 | ```time = 5000``` | | Language | ```config.lua``` : line 4 | ```language = 'en'``` | -## Updates -To see the previous changelogs, please refer to the [FiveM forum post](https://forum.cfx.re/t/release-me-but-the-text-is-3d-printed/). - -#### V3.0 -* A lot of refactoring ; -* Some major optimizations ; -* Multiple `/me` do not stack anymore but get replaced ; +## n0tst3 edit +Added de lang, trans for do command +Added /do for a more immersive rp experience ## Note * This may not work if are you using a custom chat resource ; -* This could conflict with other /me scripts (disable them) ; * This script is fully standalone. From 6595fcfbf119fb50ea2825d456a1476caa5a8819 Mon Sep 17 00:00:00 2001 From: n0tst3 <74063176+DeffoN0tSt3@users.noreply.github.com> Date: Fri, 22 Jul 2022 14:07:17 +0100 Subject: [PATCH 6/9] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e8d764b..6f82347 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,8 @@ A FiveM script written in LUA that implements the /me & /do command with 3D prin ## ME Command The /me command allows you to display a specific action above the head of a player. It's particularly used for actions that couldn't have been done in game in a roleplay context. -/me +example: /me waves + ## DO Command From 295d320e25ec8f05cd5bbeba84dcd4481f4259b4 Mon Sep 17 00:00:00 2001 From: n0tst3 <74063176+DeffoN0tSt3@users.noreply.github.com> Date: Mon, 1 Aug 2022 17:00:24 +0100 Subject: [PATCH 7/9] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6f82347..9b8d03e 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Standalone 3D /me & /do command -# Creds @Eblio - Edit by n0tst3 +# Creds @Eblio modified @n0tst3 A FiveM script written in LUA that implements the /me & /do command with 3D printing. ## ME Command @@ -8,7 +8,7 @@ example: /me waves -## DO Command +## DO Command The /do command is used primarily in serious roleplay servers and is used to describe something in your enviroment or state a fact in roleplay. It is also used if you want to ask something roleplay wise. example: /do is the door open? From d75725b99e4295ed49236423bce328286edaa19a Mon Sep 17 00:00:00 2001 From: n0tst3 <74063176+DeffoN0tSt3@users.noreply.github.com> Date: Sun, 26 Mar 2023 14:07:55 +0100 Subject: [PATCH 8/9] Update client.lua simplified displayText --- client.lua | 83 +++++++++++++----------------------------------------- 1 file changed, 20 insertions(+), 63 deletions(-) diff --git a/client.lua b/client.lua index c178351..49bf528 100644 --- a/client.lua +++ b/client.lua @@ -1,22 +1,16 @@ -- edit by n0tst3 - local c = Config -- Pre-load the config - local lang = Languages[Config.language] -- Pre-load the language - local peds = {} + local Config = Config +local Languages = Languages +local c, lang = Config, Languages[Config.language] --- Localization - local GetGameTimer = GetGameTimer +local peds = {} --- @desc Draw text in 3d --- @param coords world coordinates to where you want to draw the text --- @param text the text to display - local function draw3dText(coords, text) +local function draw3dText(coords, text) local camCoords = GetGameplayCamCoord() local dist = #(coords - camCoords) - -- Experimental math to scale the text down local scale = 200 / (GetGameplayCamFov() * dist) - -- Format the text SetTextColour(c.color.r, c.color.g, c.color.b, c.color.a) SetTextScale(0.0, c.scale * scale) SetTextFont(c.font) @@ -24,50 +18,14 @@ SetTextDropShadow() SetTextCentre(true) - -- Diplay the text BeginTextCommandDisplayText("STRING") AddTextComponentSubstringPlayerName(text) SetDrawOrigin(coords, 0) EndTextCommandDisplayText(0.0, 0.0) ClearDrawOrigin() - -end - --- @desc Display the text above the head of a ped --- @param ped the target ped --- @param text the text to display - local function displayMeText(ped, text) - local playerPed = PlayerPedId() - local playerPos = GetEntityCoords(playerPed) - local targetPos = GetEntityCoords(ped) - local dist = #(playerPos - targetPos) - local los = HasEntityClearLosToEntity(playerPed, ped, 17) - - if dist <= c.dist and los then - local exists = peds[ped] ~= nil - - peds[ped] = { - time = GetGameTimer() + c.time, - text = text - } - - if not exists then - local display = true - - while display do - Wait(0) - local pos = GetOffsetFromEntityInWorldCoords(ped, 0.0, 0.0, 0.7) - draw3dText(pos, peds[ped].text) - display = GetGameTimer() <= peds[ped].time - end - - peds[ped] = nil - end - - end end - local function displayDoText(ped, text) +local function displayText(ped, text, yOffset) local playerPed = PlayerPedId() local playerPos = GetEntityCoords(playerPed) local targetPos = GetEntityCoords(ped) @@ -75,26 +33,25 @@ end local los = HasEntityClearLosToEntity(playerPed, ped, 17) if dist <= c.dist and los then - local exists = peds[ped] ~= nil - peds[ped] = { time = GetGameTimer() + c.time, - text = text + text = text, + yOffset = yOffset } - if not exists then - local display = true + if not peds[ped].exists then + peds[ped].exists = true - while display do - Wait(0) - local pos = GetOffsetFromEntityInWorldCoords(ped, 0.0, 0.0, 0.45) - draw3dText(pos, peds[ped].text) - display = GetGameTimer() <= peds[ped].time - end + Citizen.CreateThread(function() + while GetGameTimer() <= peds[ped].time do + local pos = GetOffsetFromEntityInWorldCoords(ped, 0.0, 0.0, peds[ped].yOffset) + draw3dText(pos, peds[ped].text) + Citizen.Wait(0) + end - peds[ped] = nil + peds[ped] = nil + end) end - end end @@ -102,7 +59,7 @@ local function onDoShareDisplay(text, target) local player = GetPlayerFromServerId(target) if player ~= -1 or target == GetPlayerServerId(PlayerId()) then local ped = GetPlayerPed(player) - displayDoText(ped, text) + displayText(ped, "~b~* " .. lang.doPrefix .. text .. " ", 0.45) end end @@ -110,7 +67,7 @@ local function onMeShareDisplay(text, target) local player = GetPlayerFromServerId(target) if player ~= -1 or target == GetPlayerServerId(PlayerId()) then local ped = GetPlayerPed(player) - displayMeText(ped, text) + displayText(ped, "~r~** " .. lang.mePrefix .. text .. " **", 0.7) end end From ca094160e7828d04fef1150e42353bdb1dbe79c9 Mon Sep 17 00:00:00 2001 From: n0tst3 <74063176+DeffoN0tSt3@users.noreply.github.com> Date: Sun, 26 Mar 2023 14:08:56 +0100 Subject: [PATCH 9/9] Update server.lua --- server.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/server.lua b/server.lua index 7663991..6ec41a8 100644 --- a/server.lua +++ b/server.lua @@ -1,15 +1,16 @@ -- edit by n0tst3 -- Pre-load the language +local Config = Config +local Languages = Languages local lang = Languages[Config.language] --- @desc Handle /do command local function onDoCommand(source, args) - local text = "~b~* " .. lang.doPrefix .. table.concat(args, " ") .. " " + local text = table.concat(args, " ") TriggerClientEvent('3ddo:shareDisplay', -1, text, source) end local function onMeCommand(source, args) - local text = "~r~** " .. lang.mePrefix .. table.concat(args, " ") .. " **" + local text = table.concat(args, " ") TriggerClientEvent('3dme:shareDisplay', -1, text, source) end