NabSlayer 12 Report post Posted November 24, 2017 (edited) Hello PkoDev I would know if is possible make quest which will require from Player to stay x hours online, and how make it? Have a nice Day! Edited November 24, 2017 by NabSlayer Quote Share this post Link to post Share on other sites
iZae 55 Report post Posted November 24, 2017 I'm not sure at all, and I can't check it but I think the online time was stored somewhere on the database. (I'm guessing this 'cause I remember seeing some sites that display the online time for every character on your account). Try to search inside DBs. In case you find it stored somewhere, you should use LuaSql extension and play with it. That may be not so helpful, but it is only a hint. Quote Share this post Link to post Share on other sites
Syntax 28 Report post Posted November 24, 2017 @NabSlayer Is this quest asking player to stay online for x hours ? or The quest can be activated after x hours stay online? Quote Share this post Link to post Share on other sites
NabSlayer 12 Report post Posted November 24, 2017 43 minutes ago, Syntax said: @NabSlayer Is this quest asking player to stay online for x hours ? or The quest can be activated after x hours stay online? For complete quest, Player need stay x hours online Quote Share this post Link to post Share on other sites
Syntax 28 Report post Posted November 25, 2017 SQL = {} SQL.Host = "hostname" SQL.User = "username" SQL.Pass = "password" function GetOnlineTime(role) local PlayerID = GetCharID(role) local String = "SELECT total_live_time FROM AccountServer.dbo.account_login WHERE id IN (SELECT act_id FROM GameDB.dbo.character WHERE cha_id = "..PlayerID..")" local Connect, ConnectID = LuaSQL("connect", SQL.Host, SQL.User, SQL.Pass) if Connect == 1 then local Success, Query = LuaSQL("query", ConnectID, String) if Success == 1 then local Data = LuaSQL("fetch", ConnectID, Query) Data = tonumber(Data["total_live_time"]) LuaSQL("freehandle", ConnectID, Query) LuaSQL("close", ConnectID) return Data end end end function HasOnlineTime(role,value) local OnlineTime = GetOnlineTime(role) if OnlineTime >= value then return LUA_TRUE end return LUA_FALSE end --MissionSdk.lua (ConditionsTest) elseif conditions[i].func == HasOnlineTime then local ret = HasOnlineTime( character, conditions[i].p1 ) if ret ~= LUA_TRUE then return LUA_FALSE end --Quest Scripts MisResultCondition(HasOnlineTime,3600) P.S: required LuaSQL 5 Quote Share this post Link to post Share on other sites
iZae 55 Report post Posted November 25, 2017 (edited) Cool, that's what I ment. If you want players to stay X time since they took the quest, you need to store the total_live_time (at the moment they begin the quest) into a file trough serialize, and then check: current total_live_time - stored total_live_time = time elapsed since you took the quest. if time elapsed == mission requirement then give reward. Edited November 25, 2017 by iZae Quote Share this post Link to post Share on other sites
ilusionbr 1 Report post Posted December 11, 2021 How to make time count after the player accept the quest? I wanna make a quest that the players need to wait a few moments before finish. Someone can help? Quote Share this post Link to post Share on other sites
V3ct0r 2,117 Report post Posted December 15, 2021 Hello @ilusionbr! Add the following code to the file vairable.lua: -- Table with the time of taking quests by characters if (quest_table_guard == nil) then quest_table_guard = true quest_table = { } end functions.lua -- Quest added event AddMission__Original = AddMission AddMission = function(role, id, param) -- Call original AddMission function local ret = AddMission__Original(role, id, param) -- Check the result if ( ret == LUA_TRUE ) then -- Add the quest to the table quest_table[id] = quest_table[id] or {} -- Remember the time when the character took the quest quest_table[id][ GetRoleID(role) ] = os.time() end -- Return original result return ret end -- Check that some time expired since character taken the quest function MissionTimeExpired(role, id, t) -- Check that quest exists in the table if ( quest_table[id] == nil ) then -- Quest not found return LUA_TRUE end -- Get character ID local cha_id = GetRoleID(role) -- Check that the character has the quest if ( quest_table[id][cha_id] == nil ) then -- Character doesn't have the quest ?! return LUA_TRUE end -- Calculte time delta local delta = ( os.time() - quest_table[id][cha_id] ) -- Check that t seconds expired since quest started if ( delta >= t ) then -- Remove character from table quest_table[id][cha_id] = nil -- Condition is completed return LUA_TRUE end -- Condition is not completed return LUA_FALSE end and MissionSdk.lua (ConditionsTest() function): . . . elseif conditions[i].func == MissionTimeExpired then local ret = MissionTimeExpired( character, conditions[i].p1, conditions[i].p2 ) if ret ~= LUA_TRUE then PRINT( "ConditionsTest: MissionTimeExpired = false" ) return LUA_FALSE end . . . Now you can use the expired time condition in quest scripts: MisResultCondition(MissionTimeExpired, <quest_id>, <time_in_seconds_to_wait>) 1 1 Quote Some useful links / Полезные ссылки Tips for making a topic in 'Questions & Help' / Рекомендации по созданию тем в разделе "Помощь" Server Advertising Section Rules / Правила раздела "Реклама серверов" Available e-mail domains for registration / Допустимые e-mail домены для регистрации User groups / Группы пользователей User ranks / Звания пользователей "Broken" pictures on the forum / "Битые" изображения на форуме Beware of scammers! / Осторожно, мошенники! My developments / Мои разработки Mods for client and server / Моды для клиента и сервера PKOdev.NET website for Tales of Pirates Server / PKOdev.NET веб-обвязка для сервера Пиратии I do not provide any help in private messages and outside the forum. Use 'Questions & Help' section please. Thank you for understanding! Я не оказываю какую-либо помощь в личных сообщениях и вне форума. Пожалуйста, используйте раздел "Пиратия: Помощь". Благодарю за понимание! Share this post Link to post Share on other sites
ilusionbr 1 Report post Posted December 25, 2021 Hello @V3ct0r , Thanks for you help! It worked! Quote Share this post Link to post Share on other sites
V3ct0r 2,117 Report post Posted December 27, 2021 On 12/25/2021 at 9:03 PM, ilusionbr said: Hello @V3ct0r , Thanks for you help! It worked! Great! Note that all data about the time of taking quests by characters will be lost when the server is restarted. You need to come up with a mechanism for saving the table 'quest_table' to a file or database if this is critical. Also, NPCs that give and accept a quest with this condition must be within the same GameServer instance. Quote Some useful links / Полезные ссылки Tips for making a topic in 'Questions & Help' / Рекомендации по созданию тем в разделе "Помощь" Server Advertising Section Rules / Правила раздела "Реклама серверов" Available e-mail domains for registration / Допустимые e-mail домены для регистрации User groups / Группы пользователей User ranks / Звания пользователей "Broken" pictures on the forum / "Битые" изображения на форуме Beware of scammers! / Осторожно, мошенники! My developments / Мои разработки Mods for client and server / Моды для клиента и сервера PKOdev.NET website for Tales of Pirates Server / PKOdev.NET веб-обвязка для сервера Пиратии I do not provide any help in private messages and outside the forum. Use 'Questions & Help' section please. Thank you for understanding! Я не оказываю какую-либо помощь в личных сообщениях и вне форума. Пожалуйста, используйте раздел "Пиратия: Помощь". Благодарю за понимание! Share this post Link to post Share on other sites