Advertisement
deadx2

Untitled

Aug 7th, 2017
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.78 KB | None | 0 0
  1. quest achievementsystem begin
  2.     state start begin
  3.        
  4.         when login begin
  5.             cmdchat("ACHIEVEMENTS QID#"..q.getcurrentquestindex())
  6.             achievements.check_if_first()
  7.             achievements.create_categorys()
  8.             achievements.load_achievements()
  9.             achievements.load_last_finished_achievements()
  10.             achievements.set_achievementshop_categories()
  11.             achievements.load_achievementshop_items()
  12.             loop_timer('achievements_level_flogin_check', 5)
  13.             loop_timer('achievementstime_achievements_flogin_check', 1)
  14.         end
  15.        
  16.         when logout or disconnect begin
  17.             cleartimer('time_achievements')
  18.         end
  19.        
  20.         when button begin
  21.             cmdchat('ACHIEVEMENTS INPUT#1')
  22.             local ashop = split2(input(cmdchat('ACHIEVEMENTS SEND#')), '#')
  23.             cmdchat('ACHIEVEMENTS INPUT#0')
  24.             if ashop[1] == 'BUY_ITEM' then
  25.                 achievements.buy_achievementshop_item(tonumber(ashop[2]), tonumber(ashop[3]))
  26.             end
  27.         end
  28.        
  29.         when levelup begin
  30.             local info_level = achievements.get_next_achievement("level", 'Level')
  31.             if type(info_level) ~= 'table' then return end
  32.             cmdchat(string.format('ACHIEVEMENTS UPDATE_ACHIEVEMENT#%d#%d', 1, pc.get_level()))
  33.             cmdchat('ACHIEVEMENTS REFRESH_ACHIEVEMENTS#')
  34.             if pc.get_level() >= info_level[1] then
  35.                 achievements.set_finished(1, info_level[1], info_level[2], 0)
  36.                 achievements.set_ap(info_level[2])
  37.                 achievements.setf("level", achievements.getf("level")+1)
  38.             end
  39.         end
  40.        
  41.         when kill with not npc.is_pc() and not npc.is_boss() and not npc.is_metin() begin
  42.             local npcRace = npc.get_race()
  43.             local achievementMobInfo,mobInfo,mobKills = achievements.getAchievementInfo(npcRace, 'Mobs'),achievements.getf(string.format("mob_info_%d", npcRace))+1,achievements.getf(string.format("mob_kills_%d", npcRace))+1
  44.             if table.getn(achievementMobInfo) < mobInfo then return end
  45.             cmdchat('ACHIEVEMENTS UPDATE_ACHIEVEMENT#2#'..mobKills..'#'..npcRace)
  46.             cmdchat('ACHIEVEMENTS REFRESH_ACHIEVEMENTS#')
  47.             achievementMobInfo = achievementMobInfo[mobInfo]
  48.             achievements.setf(string.format("mob_kills_%d", npcRace), mobKills)
  49.             if mobKills >= achievementMobInfo[1] then
  50.                 achievements.set_finished(2, achievementMobInfo[1], achievementMobInfo[2], npcRace)
  51.                 achievements.set_ap(achievementMobInfo[2])
  52.                 achievements.setf(string.format("mob_info_%d", npcRace), mobInfo)
  53.             end
  54.         end
  55.        
  56.         when 1091.kill begin
  57.             local npcRace = npc.get_race()
  58.             local achievementMob2Info,mob2Info,mob2Kills = achievements.getAchievementInfo(npcRace, 'Mobs2'),achievements.getf(string.format("mob2_info_%d", npcRace))+1,achievements.getf(string.format("mob2_kills_%d", npcRace))+1
  59.             if table.getn(achievementMob2Info) < mob2Info then return end
  60.             cmdchat('ACHIEVEMENTS UPDATE_ACHIEVEMENT#7#'..mob2Kills..'#'..npcRace)
  61.             cmdchat('ACHIEVEMENTS REFRESH_ACHIEVEMENTS#')
  62.             achievementMob2Info = achievementMob2Info[mob2Info]
  63.             achievements.setf(string.format("mob2_kills_%d", npcRace), mob2Kills)
  64.             if mob2Kills >= achievementMob2Info[1] then
  65.                 achievements.set_finished(7, achievementMob2Info[1], achievementMob2Info[2], npcRace)
  66.                 achievements.set_ap(achievementMob2Info[2])
  67.                 achievements.setf(string.format("mob2_info_%d", npcRace), mob2Info)
  68.             end
  69.         end
  70.        
  71.         when 5191.kill begin
  72.             local npcRace = npc.get_race()
  73.             local achievementMob3Info,mob3Info,mob3Kills = achievements.getAchievementInfo(npcRace, 'Mobs3'),achievements.getf(string.format("mob3_info_%d", npcRace))+1,achievements.getf(string.format("mob3_kills_%d", npcRace))+1
  74.             if table.getn(achievementMob3Info) < mob3Info then return end
  75.             cmdchat('ACHIEVEMENTS UPDATE_ACHIEVEMENT#6#'..mob3Kills..'#'..npcRace)
  76.             cmdchat('ACHIEVEMENTS REFRESH_ACHIEVEMENTS#')
  77.             achievementMob3Info = achievementMob3Info[mob3Info]
  78.             achievements.setf(string.format("mob2_kills_%d", npcRace), mob3Kills)
  79.             if mob3Kills >= achievementMob3Info[1] then
  80.                 achievements.set_finished(6, achievementMob3Info[1], achievementMob3Info[2], npcRace)
  81.                 achievements.set_ap(achievementMob3Info[2])
  82.                 achievements.setf(string.format("mob3_info_%d", npcRace), mob3Info)
  83.             end
  84.         end
  85.        
  86.         when kill with npc.is_boss() begin
  87.             local npcRace = npc.get_race()
  88.             local achievementBossInfo,bossInfo,bossKills = achievements.getAchievementInfo(npcRace, 'Bosses'),achievements.getf(string.format("boss_info_%d", npcRace))+1,achievements.getf(string.format("boss_kills_%d", npcRace))+1
  89.             if table.getn(achievementBossInfo) < bossInfo then return end
  90.             cmdchat('ACHIEVEMENTS UPDATE_ACHIEVEMENT#3#'..bossKills..'#'..npcRace)
  91.             cmdchat('ACHIEVEMENTS REFRESH_ACHIEVEMENTS#')
  92.             achievementBossInfo = achievementBossInfo[bossInfo]
  93.             achievements.setf(string.format("boss_kills_%d", npcRace), bossKills)
  94.             if bossKills >= achievementBossInfo[1] then
  95.                 achievements.set_finished(3, achievementBossInfo[1], achievementBossInfo[2], npcRace)
  96.                 achievements.set_ap(achievementBossInfo[2])
  97.                 achievements.setf(string.format("boss_info_%d", npcRace), bossInfo)
  98.             end
  99.         end
  100.        
  101.         when 9001.kill begin
  102.             local npcRace = npc.get_race()
  103.             local achievementMetinInfo,metinInfo,metinKills = achievements.getAchievementInfo(npcRace, 'Metins'),achievements.getf(string.format("metin_info_%d", npcRace))+1,achievements.getf(string.format("metin_kills_%d", npcRace))+1
  104.             if table.getn(achievementMetinInfo) < metinInfo then return end
  105.             cmdchat('ACHIEVEMENTS UPDATE_ACHIEVEMENT#4#'..metinKills..'#'..npcRace)
  106.             cmdchat('ACHIEVEMENTS REFRESH_ACHIEVEMENTS#')
  107.             achievementMetinInfo = achievementMetinInfo[metinInfo]
  108.             achievements.setf(string.format("metin_kills_%d", npcRace), metinKills)
  109.             if metinKills >= achievementMetinInfo[1] then
  110.                 achievements.set_finished(4, achievementMetinInfo[1], achievementMetinInfo[2], npcRace)
  111.                 achievements.set_ap(achievementMetinInfo[2])
  112.                 achievements.setf(string.format("metin_info_%d", npcRace), metinInfo)
  113.             end
  114.         end
  115.  
  116.         when kill with npc.is_pc() begin
  117.             local pvp,info_pvp = achievements.getf("pc_kills")+1,achievements.get_next_achievement("pvp", 'Pvp')
  118.             achievements.setf("pc_kills", pvp)
  119.             if type(info_pvp) ~= 'table' then return end
  120.             cmdchat(string.format('ACHIEVEMENTS UPDATE_ACHIEVEMENT#%d#%d', 6, pvp))
  121.             cmdchat('ACHIEVEMENTS REFRESH_ACHIEVEMENTS#')
  122.             if pvp >= info_pvp[1] then
  123.                 achievements.set_finished(6, info_pvp[1], info_pvp[2], 0)
  124.                 achievements.set_ap(info_pvp[2])
  125.                 achievements.setf("pvp", achievements.getf("pvp")+1)
  126.             end
  127.         end
  128.  
  129.         when time_achievements.timer begin
  130.             chat('time_achievements: 180sec')
  131.             local info_time = achievements.get_next_achievement("time", 'PlayedTime')
  132.             if type(info_time) ~= 'table' then return end
  133.             cmdchat(string.format('ACHIEVEMENTS UPDATE_ACHIEVEMENT#%d#%d', 5, pc.get_playtime()))
  134.             cmdchat('ACHIEVEMENTS REFRESH_ACHIEVEMENTS#')
  135.             if pc.get_playtime() >= info_time[1] then
  136.                 achievements.set_finished(5, info_time[1], info_time[2], 0)
  137.                 achievements.set_ap(info_time[2])
  138.                 achievements.setf("time", achievements.getf("time")+1)
  139.             end
  140.         end
  141.        
  142.         when achievementstime_achievements_flogin_check.timer begin
  143.             cleartimer('achievementstime_achievements_flogin_check') loop_timer('achievementstime_achievements_flogin_check', 10)
  144.             local info_time = achievements.get_next_achievement("time", 'PlayedTime')
  145.             if type(info_time) ~= 'table' then cleartimer('achievementstime_achievements_flogin_check') loop_timer('time_achievements', 60*3) return end
  146.             if pc.get_playtime() >= info_time[1] then
  147.                 achievements.set_finished(5, info_time[1], info_time[2], 0)
  148.                 achievements.set_ap(info_time[2])
  149.                 achievements.setf("time", achievements.getf("time")+1)
  150.             end
  151.         end
  152.        
  153.         when achievements_level_flogin_check.timer begin
  154.             local info_level = achievements.get_next_achievement("level", 'Level')
  155.             if type(info_level) ~= 'table' then cleartimer('achievements_level_flogin_check') return end
  156.             if pc.get_level() >= info_level[1] then
  157.                 achievements.set_finished(1, info_level[1], info_level[2], 0)
  158.                 achievements.set_ap(info_level[2])
  159.                 achievements.setf("level", achievements.getf("level")+1)
  160.             end
  161.         end
  162.  
  163.     end
  164. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement