GetPlayerQuests
Every quest a player holds, in the order they got them.
Syntax
Section titled “Syntax”GetPlayerQuests(pid)| Parameter | Type | |
|---|---|---|
pid |
number | the player |
Returns
Section titled “Returns”table - {{id =, key =, state =, objectives = {state, ...}}, ...} (key is nil for a quest without one)
Example
Section titled “Example”-- saved by key, as one batch: an id lasts one server run (SetPlayerQuest's example gives them back)function OnPlayerDisconnect(pid, reason) local name = GetPlayerName(pid) local batch = { { "DELETE FROM player_quests WHERE name = @n", { n = name } } } for _, q in ipairs(GetPlayerQuests(pid)) do if q.key then batch[#batch + 1] = { "INSERT INTO player_quests (name, quest_key, state, objectives) VALUES (@n, @k, @s, @o)", { n = name, k = q.key, s = q.state, o = table.concat(q.objectives, ",") } } end end GetDatabase():Batch(batch)endSee also
Section titled “See also”SetPlayerQuest · GetQuestByKey · GetPlayerQuest · the Quests group of the index
