Hi there i recently installed the 3d rp text which gives a message above players head and for some reason when typing like / me it appears in every players screen above their heads i can post the script here later as i am not home at this moment . If you have a fix let me know. Thanks. I know little about coding*
Make sure you have the most current version.
Hi thanks . You are talking about the manifest right? Where can i check the current version?
v2.0 is most current. After looking through his resource a few things needs to be changed.
Line 30 in client.lua he references -1 on 2nd parameter for TriggerClientEvent. -1 = everyone. That needs to be the player itself.
line 30 should read
TriggerClientEvent('3dme:shareDisplay', source, text)
The script you are running still runs the deprecated __resource.lua. It will still work for the time being but every coder/scripter needs to make the change over making an fxmanifest.lua in place of their __resource.lua.
For an example, you could delete his __resource.lua, put this in a file named fxmanifest.lua
fx_version 'bodacious'
games { 'gta5' }
author 'Elio'
description '3D /me'
version '2.0'
server_scripts {
'server.lua'
}
client_scripts {
'client.lua'
}
Allright thanks. When i get home ill try it out
hey so im trying it now and still doesnt work i type /me and its in everyones above head .
SERVER.LUA
RegisterCommand(‘rp’, function(source, args, rawCommand)
local playerPed = GetPlayerPed(-1)
local msg = table.concat(args, " ")
TriggerClientEvent(‘sendMessageRp’, -1, playerPed, GetPlayerName(source), msg)
end)
RegisterCommand(‘try’, function(source, args, rawCommand)
local playerPed = GetPlayerPed(-1)
local msg = table.concat(args, " ")
TriggerClientEvent(‘sendMessageTry’, -1, playerPed, GetPlayerName(source), msg, math.random(1, 2))
end)
RegisterCommand(‘do’, function(source, args, rawCommand)
local playerPed = GetPlayerPed(-1)
local msg = table.concat(args, " ")
TriggerClientEvent(‘sendMessageDo’, -1, playerPed, GetPlayerName(source), msg)
end)
RegisterCommand(‘me’, function(source, args, rawCommand)
local playerPed = GetPlayerPed(-1)
local msg = table.concat(args, " ")
TriggerClientEvent(‘sendMessageMe’, -1, playerPed, GetPlayerName(source), msg)
end)
RegisterCommand(‘loc’, function(source, args, rawCommand)
local playerPed = GetPlayerPed(-1)
local msg = table.concat(args, " ")
TriggerClientEvent(‘sendMessageLoc’, -1, playerPed, GetPlayerName(source), msg)
end)
CLIENT.LUA
local messages = {}
local offset = 0.125
local chat = false – if you want messages to be duplicated in chat
local messagesColor = {164, 98, 193, 215} – r,g,b,a
local function DrawText3D(x ,y, z, text, color)
local r,g,b,a = {255, 255, 255, 215}
if color then
r,g,b,a = table.unpack(color)
end
local onScreen, _x, _y = World3dToScreen2d(x, y, z)
local p = GetGameplayCamCoords()
local distance = GetDistanceBetweenCoords(p.x, p.y, p.z, x, y, z, 1)
local scale = (1 / distance) * 2
local fov = (1 / GetGameplayCamFov()) * 100
local scale = scale * fov
if onScreen then
SetTextScale(0.5, 0.5)
SetTextFont(4)
SetTextProportional(1)
SetTextColour(r, g, b, a)
SetTextEntry("STRING")
SetTextCentre(1)
AddTextComponentString(text)
DrawText(_x,_y)
local factor = (string.len(text)) / 270
DrawRect(_x,_y+0.0125, 0.015+ factor, 0.04, 49, 54, 64, 215)
end
end
local function AddMessage(type, msg, color, owner, timeout)
if not messages[owner] then
messages[owner] = {}
end
table.insert(messages[owner], {
type = type,
msg = msg,
color = color
})
SetTimeout(timeout, function()
table.remove(messages[owner], 1)
if #messages[owner] == 0 then
messages[owner] = nil
end
end)
end
Citizen.CreateThread(function()
while true do
for k,v in pairs(messages) do
for i,d in pairs(messages[k]) do
local x,y,z = table.unpack(GetEntityCoords(k))
z = z + 0.9 + offset*i
DrawText3D(x, y, z, d.type..' | '..d.msg, d.color)
end
end
Wait(0)
end
end)
RegisterNetEvent(‘sendMessageRp’)
AddEventHandler(‘sendMessageRp’, function(id, name, message)
local monid = PlayerId()
local sonid = GetPlayerFromServerId(id)
if sonid == monid then
if chat then
TriggerEvent('chatMessage', "", {255, 0, 0}, " ^6 [*sign language*] | " .. name .." ".."^6 " .. message )
end
AddMessage('[*sign language*]', message, {255, 255, 255, 215}, PlayerPedId(), 10000)
elseif GetDistanceBetweenCoords(GetEntityCoords(PlayerPedId()), GetEntityCoords(GetPlayerPed(sonid)), true) < 7.01 and HasEntityClearLosToEntity(PlayerPedId(), GetPlayerPed(sonid), 17) == 1 then
if chat then
TriggerEvent('chatMessage', "", {255, 0, 0}, " ^6 [*sign language*] | " .. name .." ".."^6 " .. message )
end
AddMessage('[*sign language*]', message, {255, 255, 255, 215}, GetPlayerPed(sonid), 10000)
end
end)
RegisterNetEvent(‘sendMessageMe’)
AddEventHandler(‘sendMessageMe’, function(id, name, message)
local monid = PlayerId()
local sonid = GetPlayerFromServerId(id)
if sonid == monid then
if chat then
TriggerEvent('chatMessage', "", {255, 0, 0}, " ^6 Me | " .. name .." ".."^6 " .. message )
end
AddMessage('Me', message, {161, 102, 255, 215}, PlayerPedId(), 10000)
elseif GetDistanceBetweenCoords(GetEntityCoords(PlayerPedId()), GetEntityCoords(GetPlayerPed(sonid)), true) < 7.01 and HasEntityClearLosToEntity(PlayerPedId(), GetPlayerPed(sonid), 17) == 1 then
if chat then
TriggerEvent('chatMessage', "", {255, 0, 0}, " ^6 Me | " .. name .." ".."^6 " .. message )
end
AddMessage('Me', message, {161, 102, 255, 215}, GetPlayerPed(sonid), 10000)
end
end)
RegisterNetEvent(‘sendMessageDo’)
AddEventHandler(‘sendMessageDo’, function(id, name, message)
local monid = PlayerId()
local sonid = GetPlayerFromServerId(id)
if sonid == monid then
if chat then
TriggerEvent('chatMessage', "", {255, 0, 0}, " ^6 do | " .. message .." ".."^6 ((" .. name .. "))")
end
AddMessage('do', message, {255, 180, 89, 215}, PlayerPedId(), 10000)
elseif GetDistanceBetweenCoords(GetEntityCoords(PlayerPedId()), GetEntityCoords(GetPlayerPed(sonid)), true) < 7.01 and HasEntityClearLosToEntity(PlayerPedId(), GetPlayerPed(sonid), 17) == 1 then
if chat then
TriggerEvent('chatMessage', "", {255, 0, 0}, " ^6 do | " .. message .." ".."^6 ((" .. name .. "))")
end
AddMessage('do', message, {255, 180, 89, 215}, GetPlayerPed(sonid), 10000)
end
end)
RegisterNetEvent(‘sendMessageTry’)
AddEventHandler(‘sendMessageTry’, function(id, name, message, result)
local monid = PlayerId()
local sonid = GetPlayerFromServerId(id)
local resultMessages = {"^2Success", "^1Failure"}
local resultMessage = resultMessages[result]
if sonid == monid then
if chat then
TriggerEvent('chatMessage', "", {255, 0, 0}, " ^6 try | " .. name .." ".."^6 " .. message .. " ((".. resultMessage .."^6))")
end
AddMessage('try', message.."^7 (("..string.sub(resultMessage, 3).."))", {0, 200, 207, 215}, PlayerPedId(), 10000)
elseif GetDistanceBetweenCoords(GetEntityCoords(PlayerPedId()), GetEntityCoords(GetPlayerPed(sonid)), true) < 7.01 and HasEntityClearLosToEntity(PlayerPedId(), GetPlayerPed(sonid), 17) == 1 then
if chat then
TriggerEvent('chatMessage', "", {255, 0, 0}, " ^6 try | " .. name .." ".."^6 " .. message .. " ((".. resultMessage .."^6))")
end
AddMessage('try', message.."^7 (("..string.sub(resultMessage, 3).."))", {0, 200, 207, 215}, GetPlayerPed(sonid), 10000)
end
end)
RegisterNetEvent(‘sendMessageLoc’)
AddEventHandler(‘sendMessageLoc’, function(id, name, message)
local monid = PlayerId()
local sonid = GetPlayerFromServerId(id)
if sonid == monid then
TriggerEvent('chatMessage', "", {255, 0, 0}, "^1 [LOCAL] | ^4" .. name ..": ^7 " .. message)
elseif GetDistanceBetweenCoords(GetEntityCoords(PlayerPedId()), GetEntityCoords(GetPlayerPed(sonid)), true) < 7.01 and HasEntityClearLosToEntity(PlayerPedId(), GetPlayerPed(sonid), 17) == 1 then
TriggerEvent('chatMessage', "", {255, 0, 0}, "^1 [LOCAL] | ^4" .. name ..": ^7 " .. message)
end
end)
Everything that says -1 = everyone. Change that to source or get the player itself that typed the /me command.
Also chatMessage is deprecated for client-side as well and needs to be changed to chat:addMessage
https://docs.fivem.net/docs/scripting-manual/migrating-from-deprecated/chat-messages/
It would be better just to re-write the resource itself.
Server. Lua was re rewritten by someone cause i was getting system /me is not valid command. Now it works. After that everyone started to get the message instead of just me. And oh gosh i know very little of coding . But i will change the chatmessage to chat:addchatmessage. Could you give it a bet look to the server.lua if anything is wrong there? And thanks man i rally want this to be fully working
My friend wrote hello and it appears on my head
All the stuff that references -1 is everyone and not just the player itself. Change everything that says -1 to source. Just keep that in mind. I wrote a small example of grabbing player coordinates and properly sending it to chat to the person that typed the command. Maybe you can learn from my example to you.
-- Command Test
function cmdTest (source, args, rawCommand)
local myArgs = table.concat(args, " ")
local player = GetPlayerName(source)
local ped = GetPlayerPed(source)
local coords = GetEntityCoords(ped, false)
local x, y, z = table.unpack(coords)
local heading = GetEntityHeading(ped)
print("player: "..player)
print("ped: "..ped)
print("x: "..x..", y: "..y..", z: "..z..", heading: "..heading)
-- if source == 1 then it is a player. If source == 0 then it is console. We can add an if statement later, this was just for demonstration.
print("source: "..source)
-- Check to see if any arguments were passed. If so, then show what was passed
if args[1] ~= nil then
print("args: "..myArgs)
end
print("rawCommand: "..rawCommand)
-- We can use this to send to player's chat, as only client-side of this function is deprecated.
TriggerClientEvent("chatMessage", source, player.."'s POS", {255, 255, 0}, "x: "..x..", y: "..y..", z: "..z..", heading: "..heading)
-- heck we can even add some html to format our message
TriggerClientEvent("chat:addMessage", source, {
template = '<h3>Player Information</h3><hr><b><font color=red>Player Name</font></b>: <font color=yellow>{0}</font><br><b><font color=red>Arguments</font></b>: <font color=yellow>{1}</font>',
args = { player, myArgs }})
-- Add an embeded image in chat
TriggerClientEvent("chat:addMessage", source, {
template = '<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABmJLR0QA/wD/AP+gvaeTAAAJqklEQVRoge2YbYwV1RnHf+fMzJ37fvf17rrvLCyggICIStQqRlDRtmoLlqRKtBppk/qhnyQ2Kf1km2rTfrAppqktSX2jsYk2FbUmbG19AytKqQgLLC+7wC57l/s+996ZOf0wd4Fl997dLtqkCf8vZ+49zzzP/39mnvM8Z+ASLuES/q8h/pfB7l957RqB2IpSFko8srX3/der2iqeFUIElMu3K9nqXx7diZBCvOC6KgqAUFuAjorGii0KWpVSSE28ANRM6vPLIFoJrlL5sWshRLCarRQidvY+V+Uq2n0x1KYH4YoHhZBnNE1SFw2ZT3xr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sLtHUUyWYkjiswdEUo4kxI3DGcGPDqQqTWdT8eiMh3DsboPViL7QgCpkFHUz1CCALBSCUahRkL8FTwGIorgK+M/aXp6mwNqIaTgwb5nGTI8vHjV7ulKj8fTZM01YWpj4bOrnqsoWLbk6gWY8oTmXiUEjr3oOidkvF5GB3ROTHgw1WCPx9vRCGIBE06m+uZ19FMQyx8lrwQgqaOWZPHn+JQM60zsXiYBJJVRVv77QXFcgKU8la+/7AJwPaBBo5m/fgMnbZ4HeGAOSFP4u1dhCKT56oS4t1q8ab1Xej7d8wxH3i+4fls3rp7Vn2GDctPsqglM8Eum5EcP2qSy0oU8PpAIx+ORJFS0B6vQ06SKLqh07O4YsujlOO8UI3blN+FfviNVT2O1P6QzlnLB08nsctVszVW4NrOFFe2pAm7NnZaYJXbi2RJ509HmujP+tGkpKO5jqDpm+BbCMHCFTcSb6201avXbl13f9WOtKqAx9euXiaQbwJ1AK6rSKQyjKSy2BeciX1SEdRtSq4ka3uVzO/zXhtz8v2duUuupr1n/qRzQFJztCUr16/vn5GAx9feNkcgdgGxyeYz+QJZq+C1wraNUuA4LlIKpBTUhEPEa8KT7u3+YJB5V11Dw2VtlcLnlFB3rlp7/45q5KFKDkRitVsdx56UPEAgHKZxKu/nQdMNQpEo9c0tNLV1IXVtUjuhVJ+r6etWfXP9x9PxW1HA4htWXuMPhv4LihcHx3FOSKn/rBhJ/GrNmseqFq/zUVHAiUMHfxRvb98sKzQoM4ZASSFsV7kZp2QfMfzm6wFf4KVb12/45AuNcwmXcAmXcAnTwX8ASqKbZVGNPOwAAAAASUVORK5CYII=" height="16"> <b>{0}</b>: {1}',
args = { 'shortybsd', 'Leave the poor snails alone!' }})
end
RegisterCommand("test", cmdTest)
For the resource you are using, I would re-write the entire thing. I am a bit different than most of the guys here. I for one do not put functions inside functions inside other functions aka First-Class functions or Nested functions. It looks horrible. Also, I put mostly everything I can in server-side and I only pass TriggerClientEvent/TriggerServerEvent when I have no other choice.
The example I made you above is all server side. Maybe you can learn and understand a bit of that.
Your server.lua should be something like this
RegisterCommand('rp', function(source, args, rawCommand)
local playerPed = GetPlayerPed(source)
local msg = table.concat(args, " ")
TriggerClientEvent('sendMessageRp', -1, playerPed, GetPlayerName(source), msg)
end)
RegisterCommand('try', function(source, args, rawCommand)
local playerPed = GetPlayerPed(source)
local msg = table.concat(args, " ")
TriggerClientEvent('sendMessageTry', -1, playerPed, GetPlayerName(source), msg, math.random(1, 2))
end)
RegisterCommand('do', function(source, args, rawCommand)
local playerPed = GetPlayerPed(source)
local msg = table.concat(args, " ")
TriggerClientEvent('sendMessageDo', -1, playerPed, GetPlayerName(source), msg)
end)
RegisterCommand('me', function(source, args, rawCommand)
local playerPed = GetPlayerPed(source)
local msg = table.concat(args, " ")
TriggerClientEvent('sendMessageMe', source, playerPed, GetPlayerName(source), msg)
end)
RegisterCommand('loc', function(source, args, rawCommand)
local playerPed = GetPlayerPed(source)
local msg = table.concat(args, " ")
TriggerClientEvent('sendMessageLoc', -1, playerPed, GetPlayerName(source), msg)
end)
Notice in the above code, all 4 commands sends them globally/drawtext globally on every character. If the /me works like intended and the others spam all players. Just change -1 to source on the 3 other commands. /restart your_resource and you should be good.
Yup i see now . And it makes sense. I think that the guy whi rewrote it for me thought that sendmessage would be the same as chatmessage which makes sense putting -1 if that means everyone. Okay one more thing i learned i will change all that when i get home thanks much appreciated shorty. Ill keep you updated on the result
If that doesn’t work let me know. I might have to switch it back to all global players, then run an if check on the coordinates of the player that typed the command to only force that player to display info over his/her head.