How To Make Player Suicide With Chat Command

Hey, I am looking for a way to make a ped suicide with a chat command such as “/suicide” or “/killself”. In order to make suicide easier then going to vMenu>Player Options>Commit Suicide. Thanks!

The original code from vMenu for commiting suicide can be found here:

A basic version would look something like this (untested):

local function OnSuicide()
    RequestAnimDict('mp_suicide')
    while not HasAnimDictLoaded('mp_suicide') do
        Citizen.Wait(0)
    end

    local Ped = PlayerPedId()

    SetCurrentPedWeapon(Ped, GetHashKey('weapon_unarmed'), true)
    ClearPedTasks(Ped)
    TaskPlayAnim(Ped, 'MP_SUICIDE', 'pill', 8.0, -8.0, -1, 270540800, 0, false, false, false)

    while true do
        Citizen.Wait(0)
        local Time = GetEntityAnimCurrentTime(Ped, 'MP_SUICIDE', 'pill')
        if Time > 0.536 then
            ClearEntityLastDamageEntity(Ped)
            SetEntityHealth(Ped, 0)
            break
        end
    end

end
RegisterCommand('suicide', OnSuicide)

(Thanks to @Vespura for the code from vMenu)

Thank you! I am going to test this out today

You need it with animation or you need just a command that kills player?

A Animation would make it look nice, I am trying to just figure out how to make it so if ped has pistol then they animate a suicide by pistol then health set to 0 and if they have no pistol then they take a pill with animation then health set to 0

Look at the source code of vMenu if you want the version for the pistol.

4 Likes