Aigo 56 Posted October 1, 2021 Share Posted October 1, 2021 Hello! I have this daily quest script that works well. It give the player a daily quest based on its level, but the reward its always the same. Someone know how can i make it to give rewards based on the lvl like the "function works" does? Thank you! quest daily_quest begin state start begin when login with pc.getqf('daily_day') ~= tonumber(os.date('%d', os.time())) or pc.getqf('daily_month') ~= tonumber(os.date('%m', os.time())) begin local w,c = {},daily_quest.works() for i = 1, table.getn(c) do if pc.get_level() >= c[i][1] and pc.get_level() <= c[i][2] then table.insert(w,i) end end if table.getn(w) == 0 then chat('Actualmente no hay nuevas misiones!') return end pc.setqf('daily_number', w[number(1,table.getn(w))]) pc.setqf('daily_day', tonumber(os.date('%d', os.time()))) pc.setqf('daily_month', tonumber(os.date('%m', os.time()))) pc.setqf('daily_counter', 0) set_state(daily_run) end end state daily_run begin when letter begin send_letter('Mision Diaria: '..os.date('%A', os.time())) end when button or info begin say("Este es el texto para la mision diaria.") say("") say_reward('Derrotar: '..mob_name(daily_quest.works()[pc.getqf('daily_number')][3])) say_reward('Cantidad: '..daily_quest.works()[pc.getqf('daily_number')][4]..' times') say_reward('Derrotados: '..pc.getqf('daily_counter')) end when kill with npc.get_race() == daily_quest.works()[pc.getqf('daily_number')][3] begin pc.setqf('daily_counter', pc.getqf('daily_counter')+1) if pc.getqf('daily_counter') >= daily_quest.works()[pc.getqf('daily_number')][4] then say('Felicidades, mision completada con exito!') say('Recompensa:') local z = number(1,table.getn(daily_quest.rewards()[1])) say(daily_quest.rewards()[1][z]..' Yang!') pc.change_money(daily_quest.rewards()[1][z]) pc.setqf('daily_counter', 0) pc.setqf('daily_number', 0) clear_letter() set_state(start) end end function rewards() local t = { [1] = {200000}, } return t end function works() local t = { [1] = {1,10,103,100}, [2] = {10,15,110,100}, [3] = {15,20,111,100}, [4] = {20,25,301,100}, [5] = {25,30,301,200}, [6] = {30,35,404,100}, } return t end end end Link to comment Share on other sites More sharing options...
Active+ Member HFWhite 532 Posted October 1, 2021 Active+ Member Share Posted October 1, 2021 you can use if pc.get_level() < 125 then Link to comment Share on other sites More sharing options...
Aigo 56 Posted October 1, 2021 Author Share Posted October 1, 2021 3 hours ago, SCOOB said: you can use if pc.get_level() < 125 then Sorry, im not really sure how to use it >.< Link to comment Share on other sites More sharing options...
Aigo 56 Posted October 4, 2021 Author Share Posted October 4, 2021 up Link to comment Share on other sites More sharing options...
Contributor Solution TMP4 11115 Posted October 4, 2021 Contributor Solution Share Posted October 4, 2021 On 10/1/2021 at 1:48 PM, Aigo said: Sorry, im not really sure how to use it >.< You're not sure because this quest is very fcked up regarding that rewards array. Using arrays and tables are good but just when it is needed. Remove function rewards() and change this: local z = number(1,table.getn(daily_quest.rewards()[1])) say(daily_quest.rewards()[1][z]..' Yang!') pc.change_money(daily_quest.rewards()[1][z]) To something like this: local yangReward = 0 if pc.get_level() >= 90 then yangReward = 1000 elseif pc.get_level() >= 50 then yangReward = 500 else yangReward = 100 end say("You got "..yangReward.." yang!") pc.change_money(yangReward) Link to comment Share on other sites More sharing options...
Aigo 56 Posted October 5, 2021 Author Share Posted October 5, 2021 11 hours ago, TMP4 said: You're not sure because this quest is very fcked up regarding that rewards array. Using arrays and tables are good but just when it is needed. Remove function rewards() and change this: local z = number(1,table.getn(daily_quest.rewards()[1])) say(daily_quest.rewards()[1][z]..' Yang!') pc.change_money(daily_quest.rewards()[1][z]) To something like this: local yangReward = 0 if pc.get_level() >= 90 then yangReward = 1000 elseif pc.get_level() >= 50 then yangReward = 500 else yangReward = 100 end say("You got "..yangReward.." yang!") pc.change_money(yangReward) Thank you! I think i understood. Link to comment Share on other sites More sharing options...
Recommended Posts