[HELP] Need a line of code translated to QBCore

I am trying to use this chat script: nb-rpchat
The only problem is I cant seem to figure out how to make the chat say my players name instead of my steam name, I was told the line of code that must be edited is:

local sendername = GetPlayerName(player)

What do I need to replace this line of code with to display my players name for QBCore?

1 Like

Clientside :

local myData = QBCore.Functions.GetPlayerData()
local sendername = myData.charinfo.firstname… " "…myData.charinfo.lastname

Serverside :

local Player = QBCore.Functions.GetPlayer(source)
local sendername = Player.PlayerData.charinfo.firstname… " "…Player.PlayerData.charinfo.lastname

it should work

I figured it would be something like this, but the script is a shared script. I tried both of the lines of code and neither work, it just stops messages from showing up all together.

Clientside :

local myData = QBCore.Functions.GetPlayerData()
local sendername = myData.charinfo.firstname.." "..myData.charinfo.lastname

Serverside :

local Player = QBCore.Functions.GetPlayer(source)
local sendername = Player.PlayerData.charinfo.firstname.." "..Player.PlayerData.charinfo.lastname

You have type “…” not “…”

true , tired lol


i tried both lines of code and this is what it says, does it not work because its a shared script or did i do something wrong? the code looks like this:

    Chat["local"] = function(player,message)
        local message = message or ""
        local myData = QBCore.Functions.GetPlayerData()
        local sendername = myData.charinfo.firstname.." "..myData.charinfo.lastname
		local string = _U("local", sendername, message) 
        ProxDetector(20.0,player,string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5)
    end  

@Darek_Affinitix @AecyM

Add this at top

local QBCore = exports['qb-core']:GetCoreObject()

In your function Chat[“local”]

local Player = QBCore.Functions.GetPlayer(player)
local sendername = Player.PlayerData.charinfo.firstname.." "..Player.PlayerData.charinfo.lastname

Thank you so much for the help

1 Like

your welcome!

2 Likes