Skip to content

GetPlayerQuests

Every quest a player holds, in the order they got them.

GetPlayerQuests(pid)
Parameter Type
pid number the player

table - {{id =, key =, state =, objectives = {state, ...}}, ...} (key is nil for a quest without one)

-- 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)
end

SetPlayerQuest · GetQuestByKey · GetPlayerQuest · the Quests group of the index