Fix(CharacterSelection/client): Issue with fivem-appearance

This commit is contained in:
Andyyy7666
2022-08-11 19:49:08 +02:00
parent 31fa7ae3a4
commit 2342e9f7eb

View File

@@ -32,6 +32,21 @@ function startChangeAppearence()
end, config) end, config)
end end
-- Set the player to creating the ped if they haven't already.
function setCharacterClothes(character)
if config.enableAppearance then
if not character.clothing or next(character.clothing) == nil then
changeAppearence = true
else
changeAppearence = false
exports["fivem-appearance"]:setPlayerModel(character.clothing.model)
local ped = PlayerPedId()
exports["fivem-appearance"]:setPedTattoos(ped, character.clothing.tattoos)
exports["fivem-appearance"]:setPedAppearance(ped, character.clothing.appearance)
end
end
end
function tablelength(table) function tablelength(table)
local count = 0 local count = 0
for _ in pairs(table) do for _ in pairs(table) do
@@ -89,7 +104,7 @@ AddEventHandler("onResourceStart", function(resourceName)
if (GetCurrentResourceName() ~= resourceName) then if (GetCurrentResourceName() ~= resourceName) then
return return
end end
Citizen.Wait(2000) Wait(2000)
start(false) start(false)
end) end)
@@ -120,22 +135,6 @@ AddEventHandler("ND:returnCharacters", function(characters)
SetDisplay(true, "ui", background, characters) SetDisplay(true, "ui", background, characters)
end) end)
-- Set the player to creating the ped if they haven't already.
RegisterNetEvent("ND:setCharacter")
AddEventHandler("ND:setCharacter", function(character)
if config.enableAppearance then
if next(character.clothing) == nil then
changeAppearence = true
else
changeAppearence = false
exports["fivem-appearance"]:setPlayerModel(character.clothing.model)
local ped = PlayerPedId()
exports["fivem-appearance"]:setPedTattoos(ped, character.clothing.tattoos)
exports["fivem-appearance"]:setPedAppearance(ped, character.clothing.appearance)
end
end
end)
-- Selecting a player from the iu. -- Selecting a player from the iu.
RegisterNUICallback("setMainCharacter", function(data) RegisterNUICallback("setMainCharacter", function(data)
local characters = NDCore.Functions.GetCharacters() local characters = NDCore.Functions.GetCharacters()
@@ -195,15 +194,15 @@ end)
-- Teleporting using ui. -- Teleporting using ui.
RegisterNUICallback("tpToLocation", function(data) RegisterNUICallback("tpToLocation", function(data)
local ped = PlayerPedId() local ped = PlayerPedId()
FreezeEntityPosition(ped, false)
SetEntityCoords(ped, tonumber(data.x), tonumber(data.y), tonumber(data.z), false, false, false, false) SetEntityCoords(ped, tonumber(data.x), tonumber(data.y), tonumber(data.z), false, false, false, false)
FreezeEntityPosition(ped, true) FreezeEntityPosition(ped, true)
SwitchInPlayer(ped) SwitchInPlayer(ped)
Citizen.Wait(500) Wait(500)
SetDisplay(false, "ui") SetDisplay(false, "ui")
Citizen.Wait(500) Wait(500)
FreezeEntityPosition(ped, false) FreezeEntityPosition(ped, false)
SetEntityVisible(ped, true, 0) SetEntityVisible(ped, true, 0)
setCharacterClothes(NDCore.Functions.GetSelectedCharacter())
if config.enableAppearance and changeAppearence then if config.enableAppearance and changeAppearence then
startChangeAppearence() startChangeAppearence()
end end
@@ -213,18 +212,18 @@ end)
RegisterNUICallback("tpDoNot", function(data) RegisterNUICallback("tpDoNot", function(data)
local ped = PlayerPedId() local ped = PlayerPedId()
local character = NDCore.Functions.GetCharacters()[data.id] local character = NDCore.Functions.GetCharacters()[data.id]
FreezeEntityPosition(ped, false) if character.lastLocation and next(character.lastLocation) ~= nil then
if next(character.lastLocation) ~= nil then
SetEntityCoords(ped, character.lastLocation.x, character.lastLocation.y, character.lastLocation.z, false, false, false, false) SetEntityCoords(ped, character.lastLocation.x, character.lastLocation.y, character.lastLocation.z, false, false, false, false)
FreezeEntityPosition(ped, true)
end end
Citizen.Wait(500)
FreezeEntityPosition(ped, true)
SwitchInPlayer(ped) SwitchInPlayer(ped)
Citizen.Wait(500) Wait(500)
SetDisplay(false, "ui") SetDisplay(false, "ui")
Citizen.Wait(500) Wait(500)
FreezeEntityPosition(ped, false)
SetEntityVisible(ped, true, 0) SetEntityVisible(ped, true, 0)
FreezeEntityPosition(ped, false)
Wait(100)
setCharacterClothes(NDCore.Functions.GetSelectedCharacter())
if config.enableAppearance and changeAppearence then if config.enableAppearance and changeAppearence then
startChangeAppearence() startChangeAppearence()
end end
@@ -233,11 +232,11 @@ end)
-- Change character command -- Change character command
RegisterCommand(config.changeCharacterCommand, function() RegisterCommand(config.changeCharacterCommand, function()
SwitchOutPlayer(PlayerPedId(), 0, 1) SwitchOutPlayer(PlayerPedId(), 0, 1)
Citizen.Wait(2000) Wait(2000)
FreezeEntityPosition(ped, true) FreezeEntityPosition(ped, true)
SetEntityVisible(ped, false, 0) SetEntityVisible(ped, false, 0)
SetDisplay(true, "ui") SetDisplay(true, "ui")
end, false) end, false)
-- chat suggestions -- chat suggestions
TriggerEvent("chat:addSuggestion", "/" .. config.changeCharacterCommand, "Switch your framework character.") TriggerEvent("chat:addSuggestion", "/" .. config.changeCharacterCommand, "Switch your framework character.")