Jump to content
  • 0

Daily quest command


Question

Posted (edited)

Good evening to all. Happy New Year. We are back.

How to leave this daily quest, renewing every day 06:00 AM?

Thanks.

* npc by Emistry!

prontera,155,181,5	script	Sample	4_F_KAFRA1,{
	if (!quest_random) {
		quest_random = rand(1, 2);
		mes "You have been assigned with a new quest.";
		next;
	}
	switch(quest_random) {
		case 1:
			setarray .@reward, 4001, 1;
			setarray .@item, 512;
			setarray .@amount, 100;
			break;
		case 2:
			setarray .@reward, 4002, 1;
			setarray .@item, 501, 502, 503;
			setarray .@amount, 3, 1, 2;
			break;
		default:
			mes "invalid quest.";
			close;
	}
	mes "Quest Requirement(s):";
	.@size = getarraysize(.@item);
	for (.@i = 0; .@i < .@size; .@i++) {
		mes " > "+.@amount[.@i]+"x "+getitemname(.@item[.@i]);
		if (countitem(.@item[.@i]) < .@amount[.@i])
			.@fail++;
	}
	if (!.@fail) {
		next;
		if (select("Submit Quest", "Cancel") == 1) {
			for (.@i = 0; .@i < .@size; .@i++)
				delitem .@item[.@i], .@amount[.@i];
			getitem .@reward[0], .@reward[1];
			quest_random = 0;
		}
	}
	close;
}

 

Edited by Tassadar
give credits to the author.

8 answers to this question

Recommended Posts

  • 0
Posted (edited)

you can try this.

prontera,155,181,5	script	Sample	4_F_KAFRA1,{
	if (quest_random_cd > gettimetick(2)) {
		mes "You will be assigned with a new quest by tomorrow 6AM.";
		mes "Cooldown: "+(quest_random_cd - gettimetick(2))+" seconds";
		close;
	}
	if (!quest_random) {
		quest_random = rand(1, 2);
		mes "You have been assigned with a new quest.";
		next;
	}
	switch(quest_random) {
		case 1:
			setarray .@reward, 4001, 1;
			setarray .@item, 512;
			setarray .@amount, 100;
			break;
		case 2:
			setarray .@reward, 4002, 1;
			setarray .@item, 501, 502, 503;
			setarray .@amount, 3, 1, 2;
			break;
		default:
			mes "invalid quest.";
			close;
	}
	
	mes "Quest Requirement(s):";
	.@size = getarraysize(.@item);
	for (.@i = 0; .@i < .@size; .@i++) {
		mes " > "+.@amount[.@i]+"x "+getitemname(.@item[.@i]);
		if (countitem(.@item[.@i]) < .@amount[.@i])
			.@fail++;
	}
	if (!.@fail) {
		next;
		if (select("Submit Quest", "Cancel") == 1) {
			for (.@i = 0; .@i < .@size; .@i++)
				delitem .@item[.@i], .@amount[.@i];
			getitem .@reward[0], .@reward[1];
			quest_random = 0;
			quest_random_cd = gettimetick(2) + (86400 - gettimetick(1)) + (6 * 3600); // till 6AM next day.
		}
	}
	close;
}

or this

prontera,155,181,5	script	Sample	4_F_KAFRA1,{
	if (quest_random_cd == gettime(8)) {
		mes "You will be assigned with a new quest by tomorrow 6AM.";
		close;
	}
	if (!quest_random) {
		if (gettime(3) < 6) {
			mes "You will be assigned with a new quest by 6AM today.";
			close;
		}
		quest_random_cd = 0;
		quest_random = rand(1, 2);
		mes "You have been assigned with a new quest.";
		next;
	}
	switch(quest_random) {
		case 1:
			setarray .@reward, 4001, 1;
			setarray .@item, 512;
			setarray .@amount, 100;
			break;
		case 2:
			setarray .@reward, 4002, 1;
			setarray .@item, 501, 502, 503;
			setarray .@amount, 3, 1, 2;
			break;
		default:
			mes "invalid quest.";
			close;
	}
	
	mes "Quest Requirement(s):";
	.@size = getarraysize(.@item);
	for (.@i = 0; .@i < .@size; .@i++) {
		mes " > "+.@amount[.@i]+"x "+getitemname(.@item[.@i]);
		if (countitem(.@item[.@i]) < .@amount[.@i])
			.@fail++;
	}
	if (!.@fail) {
		next;
		if (select("Submit Quest", "Cancel") == 1) {
			for (.@i = 0; .@i < .@size; .@i++)
				delitem .@item[.@i], .@amount[.@i];
			getitem .@reward[0], .@reward[1];
			quest_random = 0;
			quest_random_cd = gettime(8);
		}
	}
	close;
}

 

Edited by Emistry
  • Love 1
  • 0
Posted
prontera,155,181,5	script	Sample	4_F_KAFRA1,{
  
  OnClock0600:
  quest_random = 0;
  end;
  
	if (!quest_random) {
		quest_random = rand(1, 2);
		mes "You have been assigned with a new quest.";
		next;
	}
	switch(quest_random) {
		case 1:
			setarray .@reward, 4001, 1;
			setarray .@item, 512;
			setarray .@amount, 100;
			break;
		case 2:
			setarray .@reward, 4002, 1;
			setarray .@item, 501, 502, 503;
			setarray .@amount, 3, 1, 2;
			break;
		default:
			mes "invalid quest.";
			close;
	}
	mes "Quest Requirement(s):";
	.@size = getarraysize(.@item);
	for (.@i = 0; .@i < .@size; .@i++) {
		mes " > "+.@amount[.@i]+"x "+getitemname(.@item[.@i]);
		if (countitem(.@item[.@i]) < .@amount[.@i])
			.@fail++;
	}
	if (!.@fail) {
		next;
		if (select("Submit Quest", "Cancel") == 1) {
			for (.@i = 0; .@i < .@size; .@i++)
				delitem .@item[.@i], .@amount[.@i];
			getitem .@reward[0], .@reward[1];
			
		}
	}
	close;
  
  OnInit:
  quest_random = 0;
  end;
}

Probably this should work.

  • 0
Posted (edited)
11 hours ago, fictionx said:

Probably this should work.

Thanks for the help, but unfortunately it didn't work. The npc appears but is not clickable. Does not open any dialog boxes.

I'm posting the error that gave in the putty.

I didn't understand what removes the player's variable preventing him from doing the quest 2 times in the same day.

error.png

Edited by Tassadar
thank for the help.
  • 0
Posted (edited)
prontera,155,181,5	script	Sample	4_F_KAFRA1,{
	if (!quest_random) {
		// quest not taken or completed, check the date and time.
		if (quest_random_next <= gettime(DT_DAYOFYEAR) && gettime(DT_HOUR) < 6) {
			mes "you have completed today quest, come again tomorrow, thank you!";
			close;
		}
		quest_random = rand(1, 2);
		mes "You have been assigned with a new quest.";
		next;
	}
	switch(quest_random) {
		case 1:
			setarray .@reward, 4001, 1;
			setarray .@item, 512;
			setarray .@amount, 100;
			break;
		case 2:
			setarray .@reward, 4002, 1;
			setarray .@item, 501, 502, 503;
			setarray .@amount, 3, 1, 2;
			break;
		default:
			mes "invalid quest.";
			close;
	}
	mes "Quest Requirement(s):";
	.@size = getarraysize(.@item);
	for (.@i = 0; .@i < .@size; .@i++) {
		mes " > "+.@amount[.@i]+"x "+getitemname(.@item[.@i]);
		if (countitem(.@item[.@i]) < .@amount[.@i])
			.@fail++;
	}
	if (!.@fail) {
		next;
		if (select("Submit Quest", "Cancel") == 1) {
			for (.@i = 0; .@i < .@size; .@i++)
				delitem .@item[.@i], .@amount[.@i];
			getitem .@reward[0], .@reward[1];
			quest_random = 0;
			// Set next day limitation to take the quest.
			quest_random_next = gettime(DT_DAYOFYEAR);
		}
	}
	close;
}

you can try this

Edited by Litro Endemic
  • 0
Posted

 

On 1/25/2020 at 3:54 AM, Litro Endemic said:

you can try this

it didn't work .. he delivers all quests on the same day. He is not turning on a 24-hour timer.

  • 0
Posted

you want 24 hours delay or every day reset at 6 AM ?

prontera,155,181,5	script	Sample	4_F_KAFRA1,{
	if (!quest_random) {
		// today quest has been, completed.
		if (quest_random_next <= gettime(DT_DAYOFYEAR)) {
			mes "you have completed today quest, come again tomorrow, thank you!";
			close;
		}
		// its new day after the last quest submission, but yet 06 am today.
		if (quest_random_next > gettime(DT_DAYOFYEAR) && gettime(DT_HOUR) < 6) {
			mes "new quest will be available at 06 AM today";
			close;
		}
		quest_random = rand(1, 2);
		mes "You have been assigned with a new quest.";
		next;
	}
	switch(quest_random) {
		case 1:
			setarray .@reward, 4001, 1;
			setarray .@item, 512;
			setarray .@amount, 100;
			break;
		case 2:
			setarray .@reward, 4002, 1;
			setarray .@item, 501, 502, 503;
			setarray .@amount, 3, 1, 2;
			break;
		default:
			mes "invalid quest.";
			close;
	}
	mes "Quest Requirement(s):";
	.@size = getarraysize(.@item);
	for (.@i = 0; .@i < .@size; .@i++) {
		mes " > "+.@amount[.@i]+"x "+getitemname(.@item[.@i]);
		if (countitem(.@item[.@i]) < .@amount[.@i])
			.@fail++;
	}
	if (!.@fail) {
		next;
		if (select("Submit Quest", "Cancel") == 1) {
			for (.@i = 0; .@i < .@size; .@i++)
				delitem .@item[.@i], .@amount[.@i];
			getitem .@reward[0], .@reward[1];
			quest_random = 0;
			// Set next day limitation to take the quest.
			quest_random_next = gettime(DT_DAYOFYEAR);
		}
	}
	close;
}

 

  • 0
Posted
just once a day. resetting at 06:00 am.
On 2/3/2020 at 12:59 PM, Litro Endemic said:

you want 24 hours delay or every day reset at 6 AM ?


prontera,155,181,5	script	Sample	4_F_KAFRA1,{
	if (!quest_random) {
		// today quest has been, completed.
		if (quest_random_next <= gettime(DT_DAYOFYEAR)) {
			mes "you have completed today quest, come again tomorrow, thank you!";
			close;
		}
		// its new day after the last quest submission, but yet 06 am today.
		if (quest_random_next > gettime(DT_DAYOFYEAR) && gettime(DT_HOUR) < 6) {
			mes "new quest will be available at 06 AM today";
			close;
		}
		quest_random = rand(1, 2);
		mes "You have been assigned with a new quest.";
		next;
	}
	switch(quest_random) {
		case 1:
			setarray .@reward, 4001, 1;
			setarray .@item, 512;
			setarray .@amount, 100;
			break;
		case 2:
			setarray .@reward, 4002, 1;
			setarray .@item, 501, 502, 503;
			setarray .@amount, 3, 1, 2;
			break;
		default:
			mes "invalid quest.";
			close;
	}
	mes "Quest Requirement(s):";
	.@size = getarraysize(.@item);
	for (.@i = 0; .@i < .@size; .@i++) {
		mes " > "+.@amount[.@i]+"x "+getitemname(.@item[.@i]);
		if (countitem(.@item[.@i]) < .@amount[.@i])
			.@fail++;
	}
	if (!.@fail) {
		next;
		if (select("Submit Quest", "Cancel") == 1) {
			for (.@i = 0; .@i < .@size; .@i++)
				delitem .@item[.@i], .@amount[.@i];
			getitem .@reward[0], .@reward[1];
			quest_random = 0;
			// Set next day limitation to take the quest.
			quest_random_next = gettime(DT_DAYOFYEAR);
		}
	}
	close;
}

 

what if the npc resets midnight? programming is easier. because that's fine with me.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...