Snippet - /bed Command


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 :rp:

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.

Download: (1.2 KB)


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

    for k,v in ipairs(bedNames) do
        table.insert( bedHashes, GetHashKey(v))

RegisterCommand('bed', function()
        local playerPed = PlayerPedId()
        if isOnBed then
            isOnBed = false

        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

        if bed ~= nil and DoesEntityExist(bed) then
            if not HasAnimDictLoaded(animDict) then
            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, 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.

[HELP] Script for laying in hospital beds

vRP & ESX versions coming?

gud release… 6 starts


Strong Release! I would give you six out of five stars if it was already in C# but most plebs use lua sadly so it still dominates. I love little improvements like this given they make such a large impact to an RP scene.

EDIT; I would mention people only need to use this as a client resource in the __resource.lua file.


I would if it were to be something more elaborate :slight_smile:

For those that can’t figure this out, I’ve included a 1.2KB ready-to-go resource :stuck_out_tongue_winking_eye:

1 Like

@d0p3t Is there a way for us to do /bed ID TIME and people stay on the bed for that ammount of time ?


I try to use this command in pillbox medical but it doesn’t do anything. Any help would be appreciated


Does this work on every bed in game or only this one?


You can add any model at the top of the snippet.

Have you made sure that the bed model names you have in your Pillbox medical are in the bedNames array?


d0p3t I am very pleased to be using your script since it gives me a lot of RP , just to ask since im very new in this area, can you give me some tips or tell me what I can change to give the option to press [E] near the bed to lay down? kinda like it works with the Weelchair.