Here you can find the hooks and functions you can use to integrate your addons with MQS, and how to add your own events and rewards.
| Hook | Realm | Arguments | Description |
|---|---|---|---|
MQS.QuestStarted |
Server | quest id, task id, ply | A player started a quest |
MQS.OnTaskSuccess |
Server | ply, quest id, quest, looped | A quest was completed. looped is true when a loop of a looped quest was completed |
MQS.OnTaskFail |
Server | ply, reason, quest id, quest | A quest failed |
MQS.QuestStoped |
Server | quest id, task id, ply | A quest ended for any reason |
MQS.QuestRewarded |
Server | quest, quest id, ply | The quest rewards were given |
MQS.PreventTaskStart |
Shared | ply, quest id, quest | Return true and an optional reason to block the quest start |
MQS.AllowJailTaskStart |
Shared | ply, quest id, quest | Return true to let wanted or arrested DarkRP players start the quest |
MQS.ProcessMission |
Server | ply, quest, task id, objective, objective id, task data | Called every tick for an active quest. Return true to pause the objective |
MQS.Hook.PostConfigLoad |
Shared | The MQS config was loaded |
Example
hook.Add("MQS.PreventTaskStart", "MyAddon.NoQuestsInEvent", function(ply, quest_id, quest)
if MyAddon.EventActive then
return true, "Quests are disabled during the event"
end
end)
Server MQS.StartTask( string quest_id, Player ply, any npc, boolean force )
Description
Starts a quest for a player. With force the start checks (NPC link, cooldowns, limits, teams) are skipped.
Server MQS.FailTask( Player ply, string reason )
Description
Fails the player's current quest. Without a reason, no notification is shown.
Server MQS.TaskSuccess( Player ply, boolean hide, boolean noreward )
Description
Completes the player's current quest. hide skips the success notification, noreward skips the quest rewards.
Server MQS.UpdateObjective( Player ply, number objective )
Description
Continues the player's quest with the next objective, or with the given objective number.
Shared MQS.HasQuest( Player ply )
Description
Returns the active quest of the player. On the client, the player is optional.
Returns
{quest = quest id, id = task id} or nilShared MQS.CanStartTask( string quest_id, Player ply, any npc, boolean force )
Returns
Shared MQS.QuestFinished( string quest_id, Player ply )
Returns
MQS.QuestStatusCheck(quest_id, ply) returns how many times the quest was completed.
Shared MQS.GetSData( Player ply, string key, any default )
Description
Returns stored player data, for example QuestList (completed quests) or CoolDown.
Server MQS.GiveRewards( Player ply, table rewards )
Description
Gives a reward table, in the same format as the quest rewards: {["DarkRP money"] = {500}}.
Server MQS.Notify( Player ply, string title, string text, number type )
Description
Shows a big quest notification. Types: 1 - yellow, 2 - red, 3 - green, 4 - blue. MQS.SmallNotify(text, ply, type) shows the gamemode's small notification.
Shared MQS.GetActiveVehicle( Player ply )
Description
Returns the vehicle the player is in. Works with default vehicles, simfphys, LFS and Glide.
An event has a server part that runs it and a client part for the editor. data is what the editor saves for the event.
-- Server (shared file)
MQS.Events["Give cash bag"] = function(task_id, ply, data, objective, quest_id)
local bag = ents.Create("my_cash_bag")
bag:SetPos(data[1])
bag:Spawn()
-- removed when the quest ends
bag.IsMQS = true
bag.task_id = task_id
table.insert(MQS.ActiveTask[task_id].misc_ents, bag:EntIndex())
end
-- Client
MSD.EventList["Give cash bag"] = {
icon = MSD.Icons48.cash,
data = {Vector(0, 0, 0)},
builUI = function(event, panel)
MSD.VectorSelectorList(panel, "Position", event[2][1], nil, nil, nil, true, function(vec)
event[2][1] = vec
end)
end
}
MQS.EvenCategory["Give cash bag"] = "Spawn" -- category in the add event menu
-- Server (shared file)
MQS.Rewards["My currency"] = {
check = function() return not MyCurrency end, -- return true to hide the reward
reward = function(ply, val)
MyCurrency.Add(ply, val[1])
end,
}
-- Client
MQS.RewardsList["My currency"] = {
data = {100},
builUI = function(data, panel)
MSD.TextEntry(panel, "static", nil, 1, 50, "", "Amount:", data[1], function(self, value)
data[1] = tonumber(value) or 0
end, true, nil, nil, true)
end
}
MQS.QuestEntTable[class] = function(ent, data) - custom setup for entities spawned by the Spawn entity event.MQS.NpcActions[flag] = function(ent, args, ply, data) - custom flags for the Spawn npc event.MQS.DB.AliasMaps["'map_a'"] = "'map_b'" - also load the quests of another map, for map versions with the same layout.