ESX
Suicide item allowing players to be killed off with RP instead of manually deleting a character.
We make sure only therapists and doctors are allowed to prescribe the pill.
Define database table and column where character data is stored using the config.
When player takes the pill they will be disconnected with a message, then database tables for their character info deleted.
change the item name from ‘deathpill’ to whatever item you want it to be in the server file at
ESX.RegisterUsableItem(‘deathpill’, function(source)
Suicide.zip (1.7 KB)
11 Likes
attempt to index a nil value (global ‘MySQL’) ?
1 Like
How about brother, did you find an answer?
@R1_Scripts
you have to add MySQL to the fxmanifest.
like this
server_scripts {
'config.lua',
'server/server.lua',
'@mysql-async/lib/MySQL.lua'
}
Id like this for qbcore if possibly.
i tried to convert but not sure im correct.
Hopefully you can review and include a config to choose what framework.
CLIENT LUA
local QBCore = exports['qb-core']:GetCoreObject() -- Assuming you have QBcore's shared object system in place
QBCore.Functions.CreateCallback('prp:isPlayerLoaded', function(source, cb)
local player = QBCore.Functions.GetPlayer(source)
cb(player ~= nil and player.PlayerData ~= nil)
end)
RegisterNetEvent('prp:perm')
AddEventHandler('prp:perm', function()
QBCore.Functions.TriggerCallback('prp:isPlayerLoaded', function(isPlayerLoaded)
if isPlayerLoaded then
TriggerServerEvent('prp:perm')
else
QBCore.Functions.Notify("Wait until you're fully loaded.", 'error')
end
end)
end)
SERVER LUA
local QBCore = exports['qb-core']:GetCoreObject()
QBCore.Functions.CreateUseableItem('deathpill', function(source)
TriggerClientEvent('prp:perm', source)
end)
RegisterServerEvent('prp:perm')
AddEventHandler('prp:perm', function()
local source = source -- Get the source player ID inside the event
for k, v in pairs(Config.PermTables) do
local query = "DELETE FROM " .. k .. " WHERE `" .. v .. "` = @identifier"
local params = { ['@identifier'] = QBCore.Functions.GetPlayer(source).PlayerData.citizenid }
QBCore.Functions.ExecuteSql(query, params)
end
QBCore.Functions.DropPlayer(source, 'YOU HAVE DIED', false)
end)