From f3d9f500b7efe8424465b285746b1543ace74e2f Mon Sep 17 00:00:00 2001 From: Scully <51968381+Scullyy@users.noreply.github.com> Date: Thu, 18 Apr 2024 17:18:54 -0700 Subject: [PATCH] Update qbox multicharacter - Added config option for date formats. - Added optional searchable dropdown for nationalities including a config to define them. - Added male and female default ped instead of random peds. --- client/character.lua | 144 ++++++++++++++++++++++-------- config/client.lua | 202 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 310 insertions(+), 36 deletions(-) diff --git a/client/character.lua b/client/character.lua index 2bed01977..48e80396b 100644 --- a/client/character.lua +++ b/client/character.lua @@ -6,19 +6,84 @@ if config.characters.useExternalCharacters then return end local previewCam = nil local randomLocation = config.characters.locations[math.random(1, #config.characters.locations)] -local randomPedModels = { - `a_m_o_soucent_02`, - `mp_g_m_pros_01`, - `a_m_m_prolhost_01`, - `a_f_m_prolhost_01`, - `a_f_y_smartcaspat_01`, - `a_f_y_runner_01`, - `a_f_y_vinewood_04`, - `a_f_o_soucent_02`, - `a_m_y_cyclist_01`, - `a_m_m_hillbilly_02`, +local randomPeds = { + { + model = `mp_m_freemode_01`, + headOverlays = { + beard = {color = 0, style = 0, secondColor = 0, opacity = 1}, + eyebrows = {color = 0, style = 0, secondColor = 0, opacity = 1}, + chestHair = {color = 0, style = 0, secondColor = 0, opacity = 1}, + }, + components = { + {texture = 0, drawable = 0, component_id = 0}, + {texture = 0, drawable = 0, component_id = 1}, + {texture = 0, drawable = 0, component_id = 2}, + {texture = 0, drawable = 0, component_id = 5}, + {texture = 0, drawable = 0, component_id = 7}, + {texture = 0, drawable = 0, component_id = 9}, + {texture = 0, drawable = 0, component_id = 10}, + {texture = 0, drawable = 15, component_id = 11}, + {texture = 0, drawable = 15, component_id = 8}, + {texture = 0, drawable = 15, component_id = 3}, + {texture = 0, drawable = 34, component_id = 6}, + {texture = 0, drawable = 61, component_id = 4}, + }, + props = { + {prop_id = 0, drawable = -1, texture = -1}, + {prop_id = 1, drawable = -1, texture = -1}, + {prop_id = 2, drawable = -1, texture = -1}, + {prop_id = 6, drawable = -1, texture = -1}, + {prop_id = 7, drawable = -1, texture = -1}, + } + }, + { + model = `mp_f_freemode_01`, + headBlend = { + shapeMix = 0.3, + shapeFirst = 31, + }, + hair = { + style = 15, + }, + headOverlays = { + beard = {color = 0, style = 0, secondColor = 0, opacity = 1}, + eyebrows = {color = 0, style = 0, secondColor = 0, opacity = 1}, + chestHair = {color = 0, style = 0, secondColor = 0, opacity = 1}, + }, + components = { + {drawable = 0, component_id = 0, texture = 0}, + {drawable = 0, component_id = 1, texture = 0}, + {drawable = 0, component_id = 2, texture = 0}, + {drawable = 0, component_id = 5, texture = 0}, + {drawable = 0, component_id = 7, texture = 0}, + {drawable = 0, component_id = 9, texture = 0}, + {drawable = 0, component_id = 10, texture = 0}, + {drawable = 15, component_id = 3, texture = 0}, + {drawable = 15, component_id = 11, texture = 3}, + {drawable = 14, component_id = 8, texture = 0}, + {drawable = 15, component_id = 4, texture = 3}, + {drawable = 35, component_id = 6, texture = 0}, + }, + props = { + {prop_id = 0, drawable = -1, texture = -1}, + {prop_id = 1, drawable = -1, texture = -1}, + {prop_id = 2, drawable = -1, texture = -1}, + {prop_id = 6, drawable = -1, texture = -1}, + {prop_id = 7, drawable = -1, texture = -1}, + } + } } +local nationalities = {} + +if config.characters.limitNationalities then + CreateThread(function() + for i = 1, #config.characters.nationalities do + nationalities[#nationalities + 1] = {value = config.characters.nationalities[i]} + end + end) +end + local function setupPreviewCam() DoScreenFadeIn(1000) SetTimecycleModifier('hud_def_blur') @@ -49,24 +114,26 @@ local function destroyPreviewCam() FreezeEntityPosition(cache.ped, false) end +local function randomPed() + local ped = randomPeds[math.random(1, #randomPeds)] + lib.requestModel(ped.model, config.loadingModelsTimeout) + SetPlayerModel(cache.playerId, ped.model) + pcall(function() exports['illenium-appearance']:setPedAppearance(PlayerPedId(), ped) end) + SetModelAsNoLongerNeeded(ped.model) +end + ---@param citizenId? string local function previewPed(citizenId) - if not citizenId then - local model = randomPedModels[math.random(1, #randomPedModels)] - lib.requestModel(model, config.loadingModelsTimeout) - SetPlayerModel(cache.playerId, model) - return - end + if not citizenId then randomPed() return end local clothing, model = lib.callback.await('qbx_core:server:getPreviewPedData', false, citizenId) if model and clothing then lib.requestModel(model, config.loadingModelsTimeout) SetPlayerModel(cache.playerId, model) pcall(function() exports['illenium-appearance']:setPedAppearance(PlayerPedId(), json.decode(clothing)) end) + SetModelAsNoLongerNeeded(model) else - model = randomPedModels[math.random(1, #randomPedModels)] - lib.requestModel(model, config.loadingModelsTimeout) - SetPlayerModel(cache.playerId, model) + randomPed() end end @@ -80,6 +147,22 @@ end ---@return string[]? local function characterDialog() + local nationalityOption = config.characters.limitNationalities and { + type = 'select', + required = true, + icon = 'user-shield', + label = locale('info.nationality'), + default = 'American', + searchable = true, + options = nationalities + } or { + type = 'input', + required = true, + icon = 'user-shield', + label = locale('info.nationality'), + placeholder = 'Duck' + } + return lib.inputDialog(locale('info.character_registration_title'), { { type = 'input', @@ -95,13 +178,7 @@ local function characterDialog() label = locale('info.last_name'), placeholder = 'Jordan' }, - { - type = 'input', - required = true, - icon = 'user-shield', - label = locale('info.nationality'), - placeholder = 'Duck' - }, + nationalityOption, { type = 'select', required = true, @@ -122,11 +199,11 @@ local function characterDialog() required = true, icon = 'calendar-days', label = locale('info.birth_date'), - format = 'YYYY-MM-DD', + format = config.characters.dateFormat, returnString = true, - min = '1900-01-01', -- Has to be in the same in the same format as the format argument - max = '2006-12-31', -- Has to be in the same in the same format as the format argument - default = '2006-12-31' + min = config.characters.dateMin, + max = config.characters.dateMax, + default = config.characters.dateMax } }) end @@ -396,15 +473,12 @@ RegisterNetEvent('qbx_core:client:playerLoggedOut', function() end) CreateThread(function() - local model = randomPedModels[math.random(1, #randomPedModels)] while true do Wait(0) if NetworkIsSessionStarted() then pcall(function() exports.spawnmanager:setAutoSpawn(false) end) Wait(250) - lib.requestModel(model, config.loadingModelsTimeout) - SetPlayerModel(cache.playerId, model) - SetModelAsNoLongerNeeded(model) + randomPed() chooseCharacter() break end diff --git a/config/client.lua b/config/client.lua index c2741ab48..05971c34c 100644 --- a/config/client.lua +++ b/config/client.lua @@ -9,6 +9,207 @@ return { enableDeleteButton = true, -- Whether players should be able to delete characters themselves. startingApartment = true, -- If set to false, skips apartment choice in the beginning (requires qbx_spawn if true) + dateFormat = 'YYYY-MM-DD', + dateMin = '1900-01-01', -- Has to be in the same format as the dateFormat config + dateMax = '2006-12-31', -- Has to be in the same format as the dateFormat config + + limitNationalities = true, -- Setting this to false will allow people to enter whatever they want in the nationality field + nationalities = { + 'Afghan', + 'Albanian', + 'Algerian', + 'American', + 'Andorran', + 'Angolan', + 'Antiguans', + 'Argentinean', + 'Armenian', + 'Australian', + 'Austrian', + 'Azerbaijani', + 'Bahamian', + 'Bahraini', + 'Bangladeshi', + 'Barbadian', + 'Barbudans', + 'Belarusian', + 'Belgian', + 'Belizean', + 'Beninese', + 'Bhutanese', + 'Bolivian', + 'Bosnian', + 'Brazilian', + 'British', + 'Bruneian', + 'Bulgarian', + 'Burkinabe', + 'Burmese', + 'Burundian', + 'Cambodian', + 'Cameroonian', + 'Canadian', + 'Cape Verdean', + 'Central African', + 'Chadian', + 'Chilean', + 'Chinese', + 'Colombian', + 'Comoran', + 'Congolese', + 'Costa Rican', + 'Croatian', + 'Cuban', + 'Cypriot', + 'Czech', + 'Danish', + 'Djibouti', + 'Dominican', + 'Dutch', + 'East Timorese', + 'Ecuadorean', + 'Egyptian', + 'Emirian', + 'Equatorial Guinean', + 'Eritrean', + 'Estonian', + 'Ethiopian', + 'Fijian', + 'Filipino', + 'Finnish', + 'French', + 'Gabonese', + 'Gambian', + 'Georgian', + 'German', + 'Ghanaian', + 'Greek', + 'Grenadian', + 'Guatemalan', + 'Guinea-Bissauan', + 'Guinean', + 'Guyanese', + 'Haitian', + 'Herzegovinian', + 'Honduran', + 'Hungarian', + 'I-Kiribati', + 'Icelander', + 'Indian', + 'Indonesian', + 'Iranian', + 'Iraqi', + 'Irish', + 'Israeli', + 'Italian', + 'Ivorian', + 'Jamaican', + 'Japanese', + 'Jordanian', + 'Kazakhstani', + 'Kenyan', + 'Kittian and Nevisian', + 'Kuwaiti', + 'Kyrgyz', + 'Laotian', + 'Latvian', + 'Lebanese', + 'Liberian', + 'Libyan', + 'Liechtensteiner', + 'Lithuanian', + 'Luxembourger', + 'Macedonian', + 'Malagasy', + 'Malawian', + 'Malaysian', + 'Maldivan', + 'Malian', + 'Maltese', + 'Marshallese', + 'Mauritanian', + 'Mauritian', + 'Mexican', + 'Micronesian', + 'Moldovan', + 'Monacan', + 'Mongolian', + 'Moroccan', + 'Mosotho', + 'Motswana', + 'Mozambican', + 'Namibian', + 'Nauruan', + 'Nepalese', + 'New Zealander', + 'Nicaraguan', + 'Nigerian', + 'Nigerien', + 'North Korean', + 'Northern Irish', + 'Norwegian', + 'Omani', + 'Pakistani', + 'Palauan', + 'Panamanian', + 'Papua New Guinean', + 'Paraguayan', + 'Peruvian', + 'Polish', + 'Portuguese', + 'Qatari', + 'Romanian', + 'Russian', + 'Rwandan', + 'Saint Lucian', + 'Salvadoran', + 'Samoan', + 'San Marinese', + 'Sao Tomean', + 'Saudi', + 'Scottish', + 'Senegalese', + 'Serbian', + 'Seychellois', + 'Sierra Leonean', + 'Singaporean', + 'Slovakian', + 'Slovenian', + 'Solomon Islander', + 'Somali', + 'South African', + 'South Korean', + 'Spanish', + 'Sri Lankan', + 'Sudanese', + 'Surinamer', + 'Swazi', + 'Swedish', + 'Swiss', + 'Syrian', + 'Taiwanese', + 'Tajik', + 'Tanzanian', + 'Thai', + 'Togolese', + 'Tongan', + 'Trinbagonian', + 'Tunisian', + 'Turkish', + 'Tuvaluan', + 'Ugandan', + 'Ukrainian', + 'Uruguayan', + 'Uzbekistani', + 'Venezuelan', + 'Vietnamese', + 'Wallisian', + 'Welsh', + 'Yemenite', + 'Zambian', + 'Zimbabwean' + }, + profanityWords = { ['bad word'] = true }, @@ -39,7 +240,6 @@ return { camCoords = vec4(2268.24, 2925.02, -84.36, 90.88), } }, - }, discord = {