Skip to content

SetPlayerQuest

Sets a player’s whole record of a quest at once - a restore at a login.

The player gets the quest when they do not hold it yet (the limits apply). Objectives left out of the list are hidden. Silent unless silent is false: a restore shows no banner.

SetPlayerQuest(pid, id, state, objectives [, silent])
Parameter Type
pid number the player
id number|string the quest’s id or key
state string "active", "done" or "failed"
objectives table each objective’s state in order, {"done", "active", ...}
silent boolean false = with the HUD’s banners (optional)

boolean, string - accepted; the reason when not

-- at the login: the quests saved by key when the player left (GetPlayerQuests' example), the key in place of the id
GetDatabase():Query("SELECT quest_key, state, objectives FROM player_quests WHERE name = @n", { n = GetPlayerName(pid) },
function(rows, err)
if err then Log("quests: " .. err) return end
for _, row in ipairs(rows) do
local objectives = {}
for s in string.gmatch(row.objectives or "", "[^,]+") do objectives[#objectives + 1] = s end
SetPlayerQuest(pid, row.quest_key, row.state, objectives)
end
end)

GetPlayerQuests · GetQuestByKey · StartPlayerQuest · the Quests group of the index