gpt-4-0314· OpenAI
WildChat-4.8M (AI2)
fivem scripting how would I create an event which when triggered removes all weapons…
- User
fivem scripting how would I create an event which when triggered removes all weapons from peds hand so they can't access it in vehicles
- Assistant
To create an event that removes all weapons from peds' hands when triggered, and ensuring they can't access them in vehicles, follow these steps:
- Start by creating a new script file for your FiveM server. You can name it
remove_weapons.lua. - In the script, first, add a server event listener that will handle the removing of the weapons for the peds when triggered.
RegisterServerEvent('removeAllWeapons') AddEventHandler('removeAllWeapons', function() local src = source TriggerClientEvent('removeAllWeaponsClient', src) end)- Next, create a client event that will handle the removal of weapons from peds and vehicles.
RegisterNetEvent('removeAllWeaponsClient') AddEventHandler('removeAllWeaponsClient', function() local player = PlayerId() local vehicle = GetVehiclePedIsIn(player, false) if vehicle then SetEntityAsMissionEntity(vehicle, true, true) for i=-1, 14 do local ped = GetPedInVehicleSeat(vehicle, i) if DoesEntityExist(ped) then RemoveAllPedWeapons(ped, true) end end else local ped = GetPlayerPed(-1) RemoveAllPedWeapons(ped, true) end end) - Start by creating a new script file for your FiveM server. You can name it
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.