I’m very new to developing and right now I’m trying to convert GitHub - kibook/poodlechat: Chat resource for Poodle's Palace FiveM/RedM server so that it will work with QBCore. All I need to change is a few lines of code so that when I type in the chat, it will show my character name based on QBCore instead of the framework “VORP”
Please share code next time, not screenshots. But here you go.
Replace;
local VORP = ServerConfig.Framework == 'VORP' and exports.vorp_core:vorpAPI()
With;
ESX = nil
TriggerEvent("esx:getSharedObject", function(obj) ESX = obj end)
And replace;
function GetName(source)
if VORP then
local char = VORP.getCharacter(source)
return char.firstname .. ' ' .. char.lastname
elseif HasNickname(source) then
return GetNickname(source)
else
return GetRealName(source)
end
end
With;
function GetName(source)
return ESX.GetPlayerFromId(source).getName()
end
Never mind. I just helped someone with ESX, so I went into autopilot and wrote it for ESX, not QBCore. Sorry about that.
They should be replaced with this;
QBCore = exports["qb-core"]:GetCoreObject()
function GetName(source)
local Player = QBCore.Functions.GetPlayer(source)
return Player.PlayerData.charinfo.firstname.." "..Player.PlayerData.charinfo.lastname
end
1 Like
Thanks for the help, but now im getting this error
Heres what my code looks like:
QBCore = exports["qb-core"]:GetCoreObject()
function GetRealName(source)
local Player = QBCore.Functions.GetPlayer(source)
return Player.charinfo.firstname.." "..Player.charinfo.lastname or '?'
end
function GetName(source)
if QBCore then
local Player = QBCore.Functions.GetPlayer(source)
return Player.charinfo.firstname.." "..Player.charinfo.lastname
end
end
1 Like
Sorry, it should be;
Player.PlayerData.charinfo
Not Player.charinfo
Okay now I’m really confused, that fixes the attempt to index a nil value error, but now I’m seeing this:
and heres how the code looks now:
QBCore = exports["qb-core"]:GetCoreObject()
function GetRealName(source)
local Player = QBCore.Functions.GetPlayer(source)
return Player.PlayerData.charinfo.firstname.." "..Player.PlayerData.charinfo.lastname or '?'
end
function GetName(source)
local Player = QBCore.Functions.GetPlayer(source)
return Player.PlayerData.charinfo.firstname.." "..Player.PlayerData.charinfo.lastname
end
EDIT: I just had to add local to the beginning, thanks so much for your help your awesome!
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.