SoundX 14 Report post Posted May 9, 2018 (edited) Hi all. I am posting this here as it took me some time to figure it out and maybe someone else wants to use it as well. - What we want to achieve: Mission shows a "[Completed]" flag in the quest log when we have collected all items - killed all mobs - In directory `/resource/script/MisSdk/` 1. File: ScriptSdk.lua: We will start a variable called `MissionSid = {}` in global variables definition, line ~=16 (below `Mission` variable): Spoiler -- Scripting system - Global Variables Page = {} -- global variable definition: NPC dialog Information Exchange = {} ExchangeX = {} FuncList = {} Trade = {} -- global variable definition: NPC Transaction Information Goods = {} -- global variable definition: NPC Cargo Transaction Information Mission = {} -- global variable definition: All mission information MissionSid = {} -- global variable definition: Mission ID corresponding to Task ID MisLogList = {} -- global variable definition: Mission information saved to logs and in function `DefineMission` we will cal the MissionSid with a misid index: Spoiler -- Register task profile function DefineMission( id, name, misid, show, mistp ) LG( "mission", "ID: "..id, " Name:"..name, " MisID:"..misid ) -- Set task profile MissionSid[misid] = id Mission[id] = {} Mission[id].id = misid -- Task Identification ID Mission[id].sid = id -- Script Task Index ID Mission[id].name = name 1. File: MissionSdk.lua: Here we will use the function `RefreshCompleteFlag` (used normally by random class quests, "A hunter's life" etc). First in the `RefreshCompleteFlag` function itself: The function defines a local called: `local mission`. We will start this local with the value of `Mission[sid]`, so replace `local mission` with `local mission = Mission[sid]`: Spoiler -- Refresh task status if is completed function RefreshCompleteFlag( character, sid ) PRINT( "RefreshCompleteFlag" ) if sid == nil or Mission[sid] == nil then PRINT( "RefreshCompleteFlag:incorrect quest script ID number,sid = "..sid ) SystemNotice( character, "RefreshCompleteFlag:incorrect quest script ID number,sid = "..sid ) return LUA_FALSE end local mission = Mission[sid] if Mission[sid].tp == NOMAL_MISSION then mission = Mission[sid] elseif Mission[sid].tp == RAND_MISSION then -- Random task has been accepted, check if can be deliver Then we need to use the `RefreshCompleteFlag` function in the `AddNextFlag` function: ( we added the line `RefreshCompleteFlag(character,MissionSid[id])` ): Spoiler function AddNextFlag( character, id, startflag, count ) if id == nil or startflag == nil or count == nil then SystemNotice( character, "AddNextFlag:Function parameter error!" ) end local num = 0 for i = 1, count, 1 do local ret = IsFlag( character, id, startflag + num ) if ret == LUA_FALSE then PRINT( "AddNextFlag: flag = ", startflag + num ) ret = SetFlag( character, id, startflag + num ) RefreshCompleteFlag(character,MissionSid[id]) I hope this can help someone. Sorry for my English and if there are mistakes/bad scripting/better way, please let me know Edited August 4, 2018 by SoundX 4 Quote Share this post Link to post Share on other sites
Skorpion 0 Report post Posted July 24, 2018 Congratulations on the topic! It worked here! Quote Share this post Link to post Share on other sites
SoundX 14 Report post Posted August 2, 2018 As two people have asked this, maybe this help the guide to be more complete: If you have custom quests in your server, and you don't register this quest on the client, you usually see the "Unknown quest" in an "Invalid type" section within the quest log: If you use the tweak described above, in some server files this might also reveal the Mission ID and see this as "Unknown Quest name ID [140]". This can be avoided easily though by adding the quest name to the client: Tales of Pirates Online\scripts\lua\mission\missioninfo.lua Add the quest name and type (1, normal, 2, story quest): -- AddMisData( <QUEST ID> , <QUEST NAME>, <QUEST TYPE 1 or 2>) AddMisData( 140 , "Revenge of the shrubs ", 1) And this should solve the problem Quote Share this post Link to post Share on other sites
Leba 12 Report post Posted August 2, 2018 In the OP, it would be easier to read if you used a brighter color for the keywords/files, as it looks fairly difficult to read on the dark background. Otherwise, great guide. 1 Quote Share this post Link to post Share on other sites
SolidusZA 3 Report post Posted June 30, 2023 Is it possible to change the word to Done instead of completed? Quote Share this post Link to post Share on other sites