Disable the bike helmet

Hello. I’ve been searching for this but i have not had any success finding it. I’m searching for something to disable the automatic bike helmet that the character puts on whenever he gets onto a motorcycle. I would love to have this on my Roleplay Server. Thanks.

1 Like

RemovePedHelmet should do the job.
(You’ll have to do it in a loop, and detect when the player is on a bike.)

1 Like

Thanks! I’m kinda new to the GTA scriping though. You have any ideas on a simple snippet?

You need a basic loop, where you constantly look whether the player is driving a vehicle; and when he does, you remove the helmet.
The loop doesn’t have to be terribly tight (about one check every 1/10 of a second should be enough):

Citizen.CreateThread( function()
  while true do
    Citizen.Wait(100)		
    local playerPed = GetPlayerPed(-1)
    local playerVeh = GetVehiclePedIsUsing(playerPed)

    if gPlayerVeh ~= 0 then RemovePedHelmet(playerPed,true) end
  end	
end)

It’s a bit overkill to have a resource just for this, but if you’re just starting out, this might be a good place to begin experimenting (so I have attached one).

Imgur

nohelmet.zip (519 Bytes)

4 Likes

Thanks dude!

1 Like

thank you from me aswell!

Does we have any native for disable helmet?
Cause this loop isn’t good. Character always trying to put helmet on his head if the bike doesn’t move and trying and trying …
The truth is we’ll don’t have helmet but the animation repeat in loop :frowning:

1 Like

https://runtime.fivem.net/doc/natives/#_0x1913FE4CBF41C463

Use a config flag?

3 Likes

Anyone got it to work fully without the loop? Actually forgot that.

Citizen.CreateThread( function()
  while true do
    Citizen.Wait(0)		--Edit this if the resource is using too much resources.   
    local playerVeh = GetVehiclePedIsUsing(player)
    if PlayerVeh ~= 0 then SetPedConfigFlag(player, 35, false) end
  end	
end)

I slipped SetPedHelmet into this code below that enables PvP and it works perfect

AddEventHandler("playerSpawned", function(spawn)
	SetCanAttackFriendly(GetPlayerPed(-1), true, false)
  NetworkSetFriendlyFireOption(true)
  SetPedCanRagdollFromPlayerImpact(GetPlayerPed(-1), true)
--NO HELMET--
  SetPedHelmet(GetPlayerPed(-1), false)
end)
3 Likes

nohelmet.lua (292 Bytes) __resource.lua (98 Bytes)

make a folder called nohelmet put these files in it. go to server cfg and add start nohelmet

this is a combination of everything people was talking about and non of it was working for me , this version works for me, some of the code might be redundant, im not a coder, when something works its pure luck

5 Likes

Thanks dude, actually works. =D

1 Like

you are welcome, trying to pay back some kindness that i got a while back… open hunting season against trolls and people that just say “google it” :slight_smile:

4 Likes

Big ups!

Any reason why when i do the following, it sort of constantly does the animation of putting the helmet on and off? would there be anyway to stop it from doing this?

*Citizen.CreateThread( function()*

*    while true do*

*        Citizen.Wait(100)        *

*        local playerPed = GetPlayerPed(-1)*
*        local playerVeh = GetVehiclePedIsUsing(playerPed)*
*        if gPlayerVeh ~= 0 then RemovePedHelmet(playerPed,true) end*
*    end*
*end)*

is there a way to make it so this only happen on a certain vehicle? i have a scooter that mimics a bike but i rather not wear a helmet when riding the scooter

Does someone have a working script for this? The ones listed on here don’t work.

Citizen.CreateThread( function()
  while true do Wait(0)	
	SetPedConfigFlag(PlayerPedId(), 35, false)
  end
end)
3 Likes

Hello my comment just above to put customer rating obviously