Jump to content

Daily Quest rewards (lua script)


Go to solution Solved by TMP4,

Recommended Posts

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 

 

spacer.png

Link to comment
Share on other sites

  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

  • Contributor
  • Solution
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

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.

spacer.png

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.