Jump to content
  • 0

Daily quest command


Tassadar

Question


  • Group:  Members
  • Topic Count:  52
  • Topics Per Day:  0.02
  • Content Count:  107
  • Reputation:   5
  • Joined:  07/21/16
  • Last Seen:  

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.
Link to comment
Share on other sites

8 answers to this question

Recommended Posts

  • 0

  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10015
  • Reputation:   2357
  • Joined:  10/28/11
  • Last Seen:  

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
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  30
  • Topics Per Day:  0.01
  • Content Count:  122
  • Reputation:   17
  • Joined:  12/10/12
  • Last Seen:  

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.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  52
  • Topics Per Day:  0.02
  • Content Count:  107
  • Reputation:   5
  • Joined:  07/21/16
  • Last Seen:  

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.
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  25
  • Topics Per Day:  0.01
  • Content Count:  283
  • Reputation:   77
  • Joined:  06/13/13
  • Last Seen:  

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
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  52
  • Topics Per Day:  0.02
  • Content Count:  107
  • Reputation:   5
  • Joined:  07/21/16
  • Last Seen:  

 

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.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  25
  • Topics Per Day:  0.01
  • Content Count:  283
  • Reputation:   77
  • Joined:  06/13/13
  • Last Seen:  

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;
}

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  52
  • Topics Per Day:  0.02
  • Content Count:  107
  • Reputation:   5
  • Joined:  07/21/16
  • Last Seen:  

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.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  25
  • Topics Per Day:  0.01
  • Content Count:  283
  • Reputation:   77
  • Joined:  06/13/13
  • Last Seen:  

please describe the npc behaviour step by step, i don't really understand what you want anymore....

Link to comment
Share on other sites

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.

×
×
  • Create New...