Callbacks

Server Callback Functions

Killstore Core makes it easy to handle server callbacks across various frameworks by providing unified functions. These are implemented in the Ks_Core/custom/*.lua directory, allowing flexibility and compatibility with ESX, QB-Core, and standalone setups.

Obtaining Server Callbacks

Server-Side (custom/server.lua): The Ks_ServerCallback function is used to register server callbacks for your scripts. Depending on the framework defined in Server.Framework, it selects the appropriate method automatically:

function Ks_ServerCallback(...)
    if Server.Framework == 'esx' then
        return Framework.RegisterServerCallback(...)
    elseif Server.Framework == 'qb-core' then
        return Framework.Functions.CreateCallback(...)
    elseif Server.Framework == 'standalone' then
        return Framework.TriggerCallback(...)
    else
        _Error("Unknown framework to function Ks_ServerCallback.")
    end
end

Client-Side (custom/client.lua): The Ks_TriggerCallback function allows client-side scripts to trigger server callbacks in a framework-agnostic way. It also adapts based on the framework specified:

function Ks_TriggerCallback(...)
    if Server.Framework == 'esx' then
        return Framework.TriggerServerCallback(...)
    elseif Server.Framework == 'qb-core' then
        return Framework.Functions.TriggerCallback(...)
    elseif Server.Framework == 'standalone' then
        return Framework.TriggerCallback(...)
    else
        _Error("Unknown framework specified in Server.Framework. Must be 'esx', 'qb-core', or 'standalone'.")
    end
end

Last updated