XProject / x-radiolist

Radio List To Be Used With PMA-VOICE In FiveM
GNU General Public License v3.0
22 stars 10 forks source link

FIX FOR CHANGING NAME ON RADIO #11

Open DJJackal opened 1 month ago

DJJackal commented 1 month ago

Here is the original code in server/main.lua

if Config.UseRPName then if GetResourceState("es_extended"):find("start") then Framework.Object = exports["es_extended"]:getSharedObject() Framework.Initial = "esx" Framework.GetPlayer = Framework.Object.GetPlayerFromId Framework.GetPlayerName = function(source) local xPlayer = Framework.GetPlayer(source) return xPlayer and xPlayer.getName() or nil end elseif GetResourceState("qb-core"):find("start") then Framework.Object = exports["qb-core"]:GetCoreObject() Framework.Initial = "qb" Framework.GetPlayer = Framework.Object.Functions.GetPlayer Framework.GetPlayerName = function(source) local xPlayer = Framework.GetPlayer(source) return xPlayer and ("%s %s"):format(xPlayer.PlayerData.charinfo.firstname, xPlayer.PlayerData.charinfo.lastname) or nil end isPlayerAllowedToChangeName = function(source, notify) -- override isPlayerAllowedToChangeName local response = Config.LetPlayersSetTheirOwnNameInRadio local xPlayer = Framework.GetPlayer(source) if xPlayer then if Config.JobsWithCallsign[xPlayer.PlayerData?.job?.name] and xPlayer.PlayerData?.job?.onduty then response = false if notify then Config.Notification(source, "You cannot change your name on radio while on duty!", "error") end end end return response end end Framework.Object = nil -- free up the memory end

Change the whole above code to the following;

if Config.UseRPName then if GetResourceState("es_extended"):find("start") then Framework.Object = exports["es_extended"]:getSharedObject() Framework.Initial = "esx" Framework.GetPlayer = Framework.Object.GetPlayerFromId Framework.GetPlayerName = function(source) local xPlayer = Framework.GetPlayer(source) return xPlayer and xPlayer.getName() or nil end elseif GetResourceState("qb-core"):find("start") then Framework.Object = exports["qb-core"]:GetCoreObject() Framework.Initial = "qb" Framework.GetPlayer = Framework.Object.Functions.GetPlayer Framework.GetPlayerName = function(source) local xPlayer = Framework.GetPlayer(source) return xPlayer and ("%s %s"):format(xPlayer.PlayerData.charinfo.firstname, xPlayer.PlayerData.charinfo.lastname) or nil end end Framework.Object = nil -- free up the memory end

mahanmoulaei commented 1 month ago

What are you trying to achieve here?? The resource already lets players to change their name. you just need to setup the config properly

DJJackal commented 1 month ago

What are you trying to achieve here?? The resource already lets players to change their name. you just need to setup the config properly

No it didnt without making this change. Kept saying That the Player wasnt on Duty.

mahanmoulaei commented 1 month ago

Kept saying That the Player wasnt on Duty.

You could just remove the jobs from Config.JobsWithCallsign or set them to false. Easy as that.

DJJackal commented 1 month ago

Kept saying That the Player wasnt on Duty.

You could just remove the jobs from Config.JobsWithCallsign or set them to false. Easy as that.

We tried this and it did not work. This was the only way to let players change their name for us.