is there a script which allows hats to stay on in when you are in a vehicle?
Did you ever find a way to get hats to stay on inside a vehicle besides equiping the outfit again when inside a vehicle.
no i didnt
The following may work although it has not been tested.
Try downloading dpClothing+ (1.0.3) Clothing Variations and Toggles (Gloves, Vest, Top, Hair, Bag and more) Once you have added it into your server, get inside the vehicle use the default ( Y ) to pull up the GUI, Or alternatively use the following command /hat
This may or may not allow you to have it on inside the vehicle you’ll have to test it out. I do not believe that there is a script that is just for allowing you to keep hat on inside of a vehicle at this time.
I have to do /hat when outside the vehicle then do /hat when inside the vehicle to put the hat on inside the vehicle If I wan’t to do that method just not worth doing.
Detect when a player enters/exists a vehicle, then call your /hat function or similar to put hat on;
local wasInVehicle = false
Citizen.CreateThread(function()
while true do
Citizen.Wait(10)
local inVehicle = IsPedInAnyVehicle(PlayerPedId(), false)
if inVehicle and not wasInVehicle then
wasInVehicle = true -- Entered vehicle
-- Call hat function
elseif wasInVehicle and not inVehicle then
wasInVehicle = false -- Left vehicle
end
end
end)
I did something similar for my server, but my code is designed around my own framework, so it’s no good for you. But basically, with this method tailored to also check if they have a hat and that hat was on before they got in the vehicle, it will auto put it back on when they get in. So consider that approach.
How simple would it be for me to add that to a non esx, normal fx server I don’t know any lua lol. I would prolly pay $ for such a simple script lmao.
I want to not need to use the /hat script, I just want the hat to remain on your head when you enter the vehicle.
I feel like its one of those client.lua scripts that cfx forums won’t let you release because their code is too small, but I dont know what the native for it would be - I know it exists because ive seen it in big servers like doj :\
You don’t need ESX or any hat script, really.
It can utilise those, but it doesn’t need them.
Just use the SetPedPropIndex native when they enter the vehicle, which you can do by using the code in my response above.
Where in the code you you put that? Just where it says – Call hat function?
are you able to add it in where it is neccesary please
bump?
Will program the function into it and send the code below. Using dpclothing’s functions!
omg thank you
I still can’t find the code for the character to keep his hat in the vehicle
Hi
first save helmet static var
SavedHelmet = GetPedPropIndex(player, 0) – Get helmet ID of the source player|
SavedHelmetTexture = GetPedPropTextureIndex(player, 0) – Get helmet texture ID of the source player|
after running task TaskEnterVehicle after run SetPedPropIndex(player, 0, SavedHelmet ,SavedHelmetTexture , true)
working :]
I still do not find it I will continue looking
guy I full scripts` :]
look 2022-09-10 16-02-45 ;]
resmon 0.00 msc :]
Is this all client.lua?
Citizen.CreateThread(function()
local hat = 0
local texture = 0
local timer = 0
local me = PlayerPedId()
while true do
Wait(1000)
me = PlayerPedId()
if not IsPedInAnyVehicle(me,true) then
hat = GetPedPropIndex(me,0)
texture = GetPedPropTextureIndex(me,0)
else
timer = GetGameTimer()
while not IsPedInAnyVehicle(me,false) or timer + 2000 < GetGameTimer() do
Wait(0)
end
if IsPedInAnyVehicle(me,false) then
SetPedPropIndex(me,0, hat, texture, 0)
while IsPedInAnyVehicle(me,false) do
Wait(1000)
end
end
end
end
end)