mirror of
https://github.com/ND-Framework/ND_Core.git
synced 2026-08-18 22:36:03 +01:00
fixed bugs
* fixed the issue where an edited character wouldn't update in the editing menu. * fixed amount of characters displaying correctly. * improved some old code.
This commit is contained in:
@@ -10,18 +10,24 @@ function tablelength(table)
|
|||||||
return count
|
return count
|
||||||
end
|
end
|
||||||
|
|
||||||
function SetDisplay(bool, typeName, bg)
|
function SetDisplay(bool, typeName, bg, characters)
|
||||||
|
local characterAmount = characters
|
||||||
|
if not characterAmount then
|
||||||
|
characterAmount = NDCore.Functions.GetCharacters()
|
||||||
|
end
|
||||||
if not bg then
|
if not bg then
|
||||||
background = config.backgrounds[math.random(1, #config.backgrounds)]
|
background = config.backgrounds[math.random(1, #config.backgrounds)]
|
||||||
end
|
end
|
||||||
|
print(tablelength(characterAmount))
|
||||||
SetNuiFocus(bool, bool)
|
SetNuiFocus(bool, bool)
|
||||||
SendNUIMessage({
|
SendNUIMessage({
|
||||||
type = typeName,
|
type = typeName,
|
||||||
background = background,
|
background = background,
|
||||||
status = bool,
|
status = bool,
|
||||||
serverName = NDCore.Config.serverName,
|
serverName = NDCore.Config.serverName,
|
||||||
characterAmount = tablelength(NDCore.Characters) .. "/" .. NDCore.Config.characterLimit
|
characterAmount = tablelength(characterAmount) .. "/" .. NDCore.Config.characterLimit
|
||||||
})
|
})
|
||||||
|
Wait(500)
|
||||||
if config.characterSelectionAopDisplay then
|
if config.characterSelectionAopDisplay then
|
||||||
SendNUIMessage({
|
SendNUIMessage({
|
||||||
type = "aop",
|
type = "aop",
|
||||||
@@ -31,19 +37,14 @@ function SetDisplay(bool, typeName, bg)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function start(switch)
|
function start(switch)
|
||||||
TriggerServerEvent("ND_CharacterSelection:checkPerms")
|
|
||||||
TriggerServerEvent("ND:GetCharacters")
|
TriggerServerEvent("ND:GetCharacters")
|
||||||
|
TriggerServerEvent("ND_CharacterSelection:checkPerms")
|
||||||
if switch then
|
if switch then
|
||||||
local ped = PlayerPedId()
|
local ped = PlayerPedId()
|
||||||
SwitchOutPlayer(ped, 0, 1)
|
SwitchOutPlayer(ped, 0, 1)
|
||||||
FreezeEntityPosition(ped, true)
|
FreezeEntityPosition(ped, true)
|
||||||
SetEntityVisible(ped, false, 0)
|
SetEntityVisible(ped, false, 0)
|
||||||
end
|
end
|
||||||
SendNUIMessage({
|
|
||||||
type = "onStart",
|
|
||||||
maxStartingBank = NDCore.Config.startingBank,
|
|
||||||
maxStartingCash = NDCore.Config.startingCash
|
|
||||||
})
|
|
||||||
if config.characterSelectionAopDisplay then
|
if config.characterSelectionAopDisplay then
|
||||||
SendNUIMessage({
|
SendNUIMessage({
|
||||||
type = "aop",
|
type = "aop",
|
||||||
@@ -77,23 +78,10 @@ end)
|
|||||||
RegisterNetEvent("ND:returnCharacters")
|
RegisterNetEvent("ND:returnCharacters")
|
||||||
AddEventHandler("ND:returnCharacters", function(characters)
|
AddEventHandler("ND:returnCharacters", function(characters)
|
||||||
SendNUIMessage({
|
SendNUIMessage({
|
||||||
type = "refresh"
|
type = "refresh",
|
||||||
|
characters = json.encode(characters)
|
||||||
})
|
})
|
||||||
for _, character in pairs(characters) do
|
SetDisplay(true, "ui", background, characters)
|
||||||
SendNUIMessage({
|
|
||||||
type = "character",
|
|
||||||
id = character.id,
|
|
||||||
firstName = character.firstName,
|
|
||||||
lastName = character.lastName,
|
|
||||||
dateOfBirth = character.dob,
|
|
||||||
gender = character.gender,
|
|
||||||
twtName = character.twt,
|
|
||||||
department = character.job,
|
|
||||||
startingCash = character.cash,
|
|
||||||
startingBank = character.bank
|
|
||||||
})
|
|
||||||
end
|
|
||||||
SetDisplay(true, "ui", background)
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- Selecting a player from the iu.
|
-- Selecting a player from the iu.
|
||||||
|
|||||||
Reference in New Issue
Block a user