gpt-4-0314· openai
Suzhen/CodeChat
fivem scripting remove being able to pistol whip other players
- User
fivem scripting remove being able to pistol whip other players
- Assistant
To remove the ability for players to pistol whip other players in FiveM, you can create a script that disables the melee action when a player has a pistol equipped. You can create a new script file called "disable_pistol_whip.lua" and add the following code:
-- Create a table to store disabled weapons (pistols in this case) local disabledWeapons = { "WEAPON_PISTOL", "WEAPON_COMBATPISTOL", "WEAPON_APPISTOL", "WEAPON_STUNGUN", "WEAPON_SNSPISTOL", "WEAPON_HEAVYPISTOL", "WEAPON_PISTOL50", "WEAPON_MARKSMANPISTOL", "WEAPON_REVOLVER", "WEAPON_DOUBLEACTION", "WEAPON_CERAMICPISTOL", "WEAPON_NAVYREVOLVER", } Citizen.CreateThread(function() while true do Citizen.Wait(0) -- Get the player's current weapon hash local ped = GetPlayerPed(-1) local currentWeapon = GetSelectedPedWeapon(ped) -- Loop through the disabledWeapons table to check for match for i, weapon in ipairs(disabledWeapons) do if GetHashKey(weapon) == currentWeapon then -- Disable melee action (pistol whip) with the matched weapon DisablePlayerFiring(ped, true) SetPedCanSwitchWeapon(ped, false) end end end end)