HumanTree92 / esx_extraitems

Extra Items for FiveM ESX Legacy
http://velocitientertainment.com/
47 stars 30 forks source link

How to EUP the Armor for Male/Female #32

Closed johnsoul777 closed 3 years ago

johnsoul777 commented 3 years ago

Hello friend I have a question, I would like to have different bulletproof vests for men and women, I use the EUP package and obviously the models do not match, I had to change the code to make it work like this,

`RegisterNetEvent('esx_extraitems:bulletproof') AddEventHandler('esx_extraitems:bulletproof', function() local playerPed = GetPlayerPed(-1)

SetPedComponentVariation(playerPed, 9, 27, 5)
AddArmourToPed(playerPed, 100)
SetPedArmour(playerPed, 100)

end)`

the question is the following, how can I make the script differentiate between a male ped and a female ped?

the only difference is that for women it is number 29 instead of 27

Questions Have you made changes to anything in client/main.lua or server/main.lua?: Yes Have you looked through the Closed Topics?: Yes Have you looked through the Wiki?: Yes Are you using a Pre-Installed ESX? If Yes who?: no Are you using es_extended? If Yes what Version? (Example: 1.2): no Are you using Essentialmode?: no Are you using ExtendedMode?: yes Are you using OneSync?: yes Linux or Windows?: Windows

johnsoul777 commented 3 years ago

this is a man

image

this is a women

image

obviously I would like women to be like that

image

johnsoul777 commented 3 years ago

I had thought that this could solve it, in fact now the woman receives her corresponding bulletproof, but in the man it does not work

RegisterNetEvent('esx_extraitems:bulletproof')
AddEventHandler('esx_extraitems:bulletproof', function()
    local playerPed = GetPlayerPed(-1)
    local playerPedM = PlayerPedId('mp_m_freemode_01')
    local playerPedF = PlayerPedId('mp_f_freemode_01')

    SetPedComponentVariation(playerPedM, 9, 27, 5)
    SetPedComponentVariation(playerPedF, 9, 29, 5)
    AddArmourToPed(playerPed, 100)
    SetPedArmour(playerPed, 100)
end)

I can't think of any solution, I'm stuck ...

HumanTree92 commented 3 years ago

You can do something like

TriggerEvent('skinchanger:getSkin', function(skin)
    if skin.sex == 0 then
        SetPedComponentVariation(playerPed, 9, 27, 5)
    else
        SetPedComponentVariation(playerPed, 9, 29, 5)
    end
end)
johnsoul777 commented 3 years ago

Puedes hacer algo como

TriggerEvent ( ' skinchanger: getSkin ' , function ( skin )
   if skin. Sex  ==  0  then 
      SetPedComponentVariation ( playerPed , 9 , 27 , 5 )
   else 
      SetPedComponentVariation ( playerPed , 9 , 29 , 5 )
   end 
end )

forgive me, I'm trying to learn LUA, but my English is very bad, would this be correct?

RegisterNetEvent('esx_extraitems:bulletproof')
AddEventHandler('esx_extraitems:bulletproof', function(skin)
    local playerPed = GetPlayerPed(-1)

    if skin.sex == 0 then 
        SetPedComponentVariation ( playerPed , 9 , 27 , 5 )
    else 
        SetPedComponentVariation ( playerPed , 9 , 29 , 5 )
    end 

    AddArmourToPed(playerPed, 100)
    SetPedArmour(playerPed, 100)
end)

because it's not working for me ...

HumanTree92 commented 3 years ago

You have to have TriggerEvent('skinchanger:getSkin', function(skin) with the end)

johnsoul777 commented 3 years ago

Tienes que tener TriggerEvent ('skinchanger: getSkin', function (skin) con el final)

I am an idiot, now I have seen my failure, a thousand million thanks, now it works perfect, I leave a copy of the code in case someone else has the same problem

RegisterNetEvent('esx_extraitems:bulletproof')
AddEventHandler('esx_extraitems:bulletproof', function()
    local playerPed = GetPlayerPed(-1)

    TriggerEvent('skinchanger:getSkin', function(skin)
        if skin.sex == 0 then  
          SetPedComponentVariation (playerPed, 9, 27, 5)
        else  
          SetPedComponentVariation (playerPed, 9, 29, 5)
        end  
    end)

    AddArmourToPed(playerPed, 100)
    SetPedArmour(playerPed, 100)
end)

Have a happy new year friend!