A person on the FiveM Discord asked for a /bed
command, probably due to the influx of popular Twitch streamers lately using this command.
Good for hospital
Here’s a snippet of my version of the /bed
command. I believe it’s not complicated enough for the #development:releases category, so I’ll put it here.
Video: https://streamable.com/eaosk
Screenshot: https://i.d0p3t.nl/u/0ihxvZ5V3y.png
Download: bedcommand.zip (1.2 KB)
Snippet:
bedNames = { 'v_med_bed1', 'v_med_bed2'} -- Add more model strings here if you'd like
bedHashes = {}
animDict = 'missfbi5ig_0'
animName = 'lyinginpain_loop_steve'
isOnBed = false
CreateThread(function()
for k,v in ipairs(bedNames) do
table.insert( bedHashes, GetHashKey(v))
end
end)
RegisterCommand('bed', function()
Citizen.CreateThread(function()
local playerPed = PlayerPedId()
if isOnBed then
ClearPedTasksImmediately(playerPed)
isOnBed = false
return
end
local playerPos = GetEntityCoords(playerPed, true)
local bed = nil
for k,v in ipairs(bedHashes) do
bed = GetClosestObjectOfType(playerPos.x, playerPos.y, playerPos.z, 4.0, v, false, false, false)
if bed ~= 0 then
break
end
end
if bed ~= nil and DoesEntityExist(bed) then
if not HasAnimDictLoaded(animDict) then
RequestAnimDict(animDict)
end
local bedCoords = GetEntityCoords(bed)
SetEntityCoords(playerPed, bedCoords.x , bedCoords.y, bedCoords.z, 1, 1, 0, 0)
SetEntityHeading(playerPed, GetEntityHeading(bed) + 180.0)
TaskPlayAnim(playerPed,animDict, animName, 8.0, 1.0, -1, 45, 1.0, 0, 0, 0)
isOnBed = true
end
end)
end, false)
The models I used for this are from [Release] Hospital props
On the second bed the player does hover due to collision. Up to you to fix this if you want to, I just put this together real quick.