[Release] Toggle Ragdoll

release
roleplay
toggle
ragdoll
scripting

#1

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!


#2

Might want to change that :stuck_out_tongue:


#3

yeah hahah thanks for pointing that out


#4

No problem :slight_smile:


#5

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