[Release] Toggle Ragdoll

So here’s a script that … toggles Ragdoll obviously.
There are 2 versions
One of them require you to type /rag in chat to toggle the script
The other can be toggled by pressing the key (U)

DOWNLOAD

Ragdoll Toggle via key “U”
Ragdoll Toggle via cmd “/rag”

OR

_resource.lua

-- Toggle Ragdoll written by JAF
-- Made for www.lacountyrp.com
-- Version 1.0.0

resource_manifest_version '77731fab-63ca-442c-a67b-abc70f28dfa5'

-- Add a client script 
client_script 'client.lua'

(Toggle Via Key “U”)
client.lua

local ragdoll = false
function setRagdoll(flag)
  ragdoll = flag
end
Citizen.CreateThread(function()
  while true do
    Citizen.Wait(0)
    if ragdoll then
      SetPedToRagdoll(GetPlayerPed(-1), 1000, 1000, 0, 0, 0, 0)
    end
  end
end)

ragdol = true
RegisterNetEvent("Ragdoll")
AddEventHandler("Ragdoll", function()
	if ( ragdol ) then
		setRagdoll(true)
		ragdol = false
	else
		setRagdoll(false)
		ragdol = true
	end
end)

Citizen.CreateThread(function()
 	while true do
 		Citizen.Wait(100)
 		if ( IsControlPressed(2, 303) ) then  --change key here
 			TriggerEvent("Ragdoll", source)
 		end
 	end
end)

(Toggle via command “/rag”)
client.lua

local ragdoll = false
function setRagdoll(flag)
  ragdoll = flag
end
Citizen.CreateThread(function()
  while true do
    Citizen.Wait(0)
    if ragdoll then
      SetPedToRagdoll(GetPlayerPed(-1), 1000, 1000, 0, 0, 0, 0)
    end
  end
end)

ragdol = true
RegisterNetEvent("Ragdoll")
AddEventHandler("Ragdoll", function()
	if ( ragdol ) then
		setRagdoll(true)
		ragdol = false
	else
		setRagdoll(false)
		ragdol = true
	end
end)

RegisterCommand("rag", function(source, args, raw) --change command here
    TriggerEvent("Ragdoll")
end, false) --False, allow everyone to run it(thnx @Havoc)

Enjoy!

6 Likes

Might want to change that :stuck_out_tongue:

2 Likes

yeah hahah thanks for pointing that out

No problem :slight_smile:

1 Like

i cant use /rag to ragdoll no errors pop up or anything it just doesnt ragdoll me
[edit] nvm how do i unragdoll?
[edit2] nvm found out how sorry about that

what would be the number to be 1 on the number pad to press?

Any way to remove the buttons on the controller from triggering it?

just use the /rag script one that he made.

1 Like

Is there a List of these keys? I really wanna change it To F6…

Replace the client.lua with the following code…

local ragdoll = false
function setRagdoll(flag)
  ragdoll = flag
end
Citizen.CreateThread(function()
  while true do
    Citizen.Wait(0)
    if ragdoll then
      SetPedToRagdoll(GetPlayerPed(-1), 1000, 1000, 0, 0, 0, 0)
    end
  end
end)

ragdol = true
RegisterNetEvent("Ragdoll")
AddEventHandler("Ragdoll", function()
	if ( ragdol ) then
		setRagdoll(true)
		ragdol = false
	else
		setRagdoll(false)
		ragdol = true
	end
end)

Citizen.CreateThread(function()
 	while true do
 		Citizen.Wait(100)
 		if ( IsControlPressed(2, 167) ) then  --change key here
 			TriggerEvent("Ragdoll", source)
 		end
 	end
end)

I changed it for you.

here is the documentation for fivem controls

I know it’s really easy to do, but you should release a new version that has both in one. Because some people like using buttons, and some people like using the commands and the developers of servers don’t want to many folders in their resources.

You could use this following client.lua script:

local ragdoll = false
function setRagdoll(flag)
  ragdoll = flag
end
Citizen.CreateThread(function()
  while true do
    Citizen.Wait(0)
    if ragdoll then
      SetPedToRagdoll(GetPlayerPed(-1), 1000, 1000, 0, 0, 0, 0)
    end
  end
end)

ragdol = true
RegisterNetEvent("Ragdoll")
AddEventHandler("Ragdoll", function()
	if ( ragdol ) then
		setRagdoll(true)
		ragdol = false
	else
		setRagdoll(false)
		ragdol = true
	end
end)

Citizen.CreateThread(function()
 	while true do
 		Citizen.Wait(100)
 		if ( IsControlPressed(2, 110) ) then
 			TriggerEvent("Ragdoll", source)
 		end
 	end
 end)

RegisterCommand("rag", function(source, args, raw) --change command here
    TriggerEvent("Ragdoll")
end, false) --False, allow everyone to run it(thnx @Havoc)

Hey can someone change the keybind from “U” to “I”

can anyone help me? when i go to join the server its says: Couldn’t load resource scripts: Couldn’t load resource scripts from resources:/scripts/: Could not open resource metadata file resources:/scripts//__resource.lua.

how do you unrag??

just imported this, it works to this date, but when you join the server, you start off ragdolled, is there a way to fix this?
sorry to bump an old thread

The U key one works but after I ragdoll I have to press it like 8 times to get back up:(

whre do i find this and remove it…cant seem to find the event anywhere in the ,lua scripts…

these can easily be edited by looking up what the control number is online and correspond that with want you would like it to be in the right file