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.
Syntax
Section titled “Syntax”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) |
Returns
Section titled “Returns”boolean, string - accepted; the reason when not
Example
Section titled “Example”-- at the login: the quests saved by key when the player left (GetPlayerQuests' example), the key in place of the idGetDatabase():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)See also
Section titled “See also”GetPlayerQuests · GetQuestByKey · StartPlayerQuest · the Quests group of the index
