This is a simple resource to remove your helmet on command, and then put it back on, on command.
I saw a community request this and despite it being a smaller resource I decided to quickly mock it up.
The resource also has the option to remove the auto bike helmets that your player puts on when getting on a motorbike, because the player will put on the regular bike helmet if you do /helmet off when on a bike.
I do not reccomend you put this in a standalone resource (as it is very small), it should be added to a single ācommandsā resource ideally.
Here is the code itself, for those of you who donāt want to download anything.
Client.lua
RemoveBikeHelmet = true --Change this to your liking, I reccomend that you leave this at true.
player = GetPlayerPed(-1)
RegisterCommand("helmet", function(source, args, raw) -- adjust command name here
if (args[1] == "off") then
SavedHelmet = GetPedPropIndex(player, 0) -- Get helmet ID of the source player
SavedHelmetTexture = GetPedPropTextureIndex(player, 0) -- Get helmet texture ID of the source player
ClearPedProp(player, 0)
else --if the text after helmet is anything but "off"
--TODO, use the saved ped helmet, and requip that.
SetPedPropIndex(player, 0, SavedHelmet, SavedHelmetTexture, true)
end
end, false) -- false, allow everyone to run it
if RemoveBikeHelmet then
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)
end```
local helmet = false
RegisterCommand("helmet", function(source, args, raw)
helmet = not helmet
if helmet then
-- Do stuff
else
-- Else do other stuff
end
end, false)
Should avoid you having to use args like on/off, just the command itself to ātoggleā it.
People just wanna view code instead of downloading crap into their PCā¦ no offense but Iām trying to take caution with downloading random things from the internet.
this isnt totally intended just to be used out of the box, itās a very small amount of code, but if every release tended to everyones needs thereād be 500 different versions of each release, I just figured this was the clearest way I could put it.
It would be really easy to change it to a bool toogle instead of the if then else tree, so feel free to, im not stopping you lol.
Is anyone else getting bug where they login to the server with the helmet on and the helmet script needs to be restarted in order to remove it? It happens every time.