diff --git a/resources/[inventory]/nordi_backpack/client.lua b/resources/[inventory]/nordi_backpack/client.lua index 194b82def..ec0d89ef6 100644 --- a/resources/[inventory]/nordi_backpack/client.lua +++ b/resources/[inventory]/nordi_backpack/client.lua @@ -1,11 +1,87 @@ local QBCore = exports['qb-core']:GetCoreObject() --- Debug function to print all clothing components +-- Get character gender (0 = male, 1 = female) using model hash +function GetCharacterGender() + local ped = PlayerPedId() + local modelHash = GetEntityModel(ped) + + -- List of female model hashes + local femaleModels = { + `mp_f_freemode_01`, -- MP Female + `a_f_m_beach_01`, `a_f_m_bevhills_01`, `a_f_m_bevhills_02`, + `a_f_m_bodybuild_01`, `a_f_m_business_02`, `a_f_m_downtown_01`, + `a_f_m_eastsa_01`, `a_f_m_eastsa_02`, `a_f_m_fatbla_01`, + `a_f_m_fatwhite_01`, `a_f_m_ktown_01`, `a_f_m_ktown_02`, + `a_f_m_prolhost_01`, `a_f_m_salton_01`, `a_f_m_skidrow_01`, + `a_f_m_soucent_01`, `a_f_m_soucent_02`, `a_f_m_soucentmc_01`, + `a_f_m_tourist_01`, `a_f_m_trampbeac_01`, `a_f_m_tramp_01`, + `a_f_o_genstreet_01`, `a_f_o_indian_01`, `a_f_o_ktown_01`, + `a_f_o_salton_01`, `a_f_o_soucent_01`, `a_f_o_soucent_02`, + `a_f_y_beach_01`, `a_f_y_bevhills_01`, `a_f_y_bevhills_02`, + `a_f_y_bevhills_03`, `a_f_y_bevhills_04`, `a_f_y_business_01`, + `a_f_y_business_02`, `a_f_y_business_03`, `a_f_y_business_04`, + `a_f_y_eastsa_01`, `a_f_y_eastsa_02`, `a_f_y_eastsa_03`, + `a_f_y_epsilon_01`, `a_f_y_fitness_01`, `a_f_y_fitness_02`, + `a_f_y_genhot_01`, `a_f_y_golfer_01`, `a_f_y_hiker_01`, + `a_f_y_hippie_01`, `a_f_y_hipster_01`, `a_f_y_hipster_02`, + `a_f_y_hipster_03`, `a_f_y_hipster_04`, `a_f_y_indian_01`, + `a_f_y_juggalo_01`, `a_f_y_runner_01`, `a_f_y_rurmeth_01`, + `a_f_y_scdressy_01`, `a_f_y_skater_01`, `a_f_y_soucent_01`, + `a_f_y_soucent_02`, `a_f_y_soucent_03`, `a_f_y_tennis_01`, + `a_f_y_tourist_01`, `a_f_y_tourist_02`, `a_f_y_vinewood_01`, + `a_f_y_vinewood_02`, `a_f_y_vinewood_03`, `a_f_y_vinewood_04`, + `a_f_y_yoga_01`, `g_f_importexport_01`, `g_f_y_ballas_01`, + `g_f_y_families_01`, `g_f_y_lost_01`, `g_f_y_vagos_01`, + `s_f_m_fembarber`, `s_f_m_maid_01`, `s_f_m_shop_high`, + `s_f_m_sweatshop_01`, `s_f_y_airhostess_01`, `s_f_y_bartender_01`, + `s_f_y_baywatch_01`, `s_f_y_cop_01`, `s_f_y_factory_01`, + `s_f_y_hooker_01`, `s_f_y_hooker_02`, `s_f_y_hooker_03`, + `s_f_y_migrant_01`, `s_f_y_movprem_01`, `s_f_y_ranger_01`, + `s_f_y_scrubs_01`, `s_f_y_sheriff_01`, `s_f_y_shop_low`, + `s_f_y_shop_mid`, `s_f_y_stripper_01`, `s_f_y_stripper_02`, + `s_f_y_stripperlite`, `s_f_y_sweatshop_01`, `u_f_m_corpse_01`, + `u_f_m_miranda`, `u_f_m_promourn_01`, `u_f_o_moviestar`, + `u_f_o_prolhost_01`, `u_f_y_bikerchic`, `u_f_y_comjane`, + `u_f_y_corpse_01`, `u_f_y_corpse_02`, `u_f_y_hotposh_01`, + `u_f_y_jewelass_01`, `u_f_y_mistress`, `u_f_y_poppymich`, + `u_f_y_princess`, `u_f_y_spyactress` + } + + -- Check if the model is in the female list + for _, hash in ipairs(femaleModels) do + if hash == modelHash then + return 1 -- Female + end + end + + -- Check specifically for MP Female model (most common) + if modelHash == `mp_f_freemode_01` then + return 1 -- Female + end + + -- Check specifically for MP Male model (most common) + if modelHash == `mp_m_freemode_01` then + return 0 -- Male + end + + -- Alternative method: check player data if available + local Player = QBCore.Functions.GetPlayerData() + if Player and Player.charinfo and Player.charinfo.gender then + return Player.charinfo.gender == 1 and 1 or 0 + end + + -- Default to male if we can't determine + return 0 +end + +-- Debug function to print all clothing components with improved gender detection function PrintAllClothingComponents() local ped = PlayerPedId() local components = {} - local gender = IsPedMale(ped) and 0 or 1 + local gender = GetCharacterGender() + local modelHash = GetEntityModel(ped) + print("Character Model Hash: " .. modelHash) print("Character Gender: " .. (gender == 0 and "Male" or "Female")) -- Component IDs: 0=face, 1=mask, 2=hair, 3=torso, 4=leg, 5=bag, 6=shoes, 7=accessory, 8=undershirt, 9=kevlar, 10=badge, 11=torso2 @@ -46,13 +122,7 @@ RegisterCommand('checkclothing', function() }) end, false) --- Get character gender (0 = male, 1 = female) -function GetCharacterGender() - local ped = PlayerPedId() - return IsPedMale(ped) and 0 or 1 -end - --- Check if player has a backpack equipped with gender detection +-- Check if player has a backpack equipped with improved gender detection function CheckForBackpack() local ped = PlayerPedId() local gender = GetCharacterGender()