Jump to content
  • 0
Tassadar

Daily quest command

Question

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 [email protected], 4001, 1;
			setarray [email protected], 512;
			setarray [email protected], 100;
			break;
		case 2:
			setarray [email protected], 4002, 1;
			setarray [email protected], 501, 502, 503;
			setarray [email protected], 3, 1, 2;
			break;
		default:
			mes "invalid quest.";
			close;
	}
	mes "Quest Requirement(s):";
	[email protected] = getarraysize([email protected]);
	for ([email protected] = 0; [email protected] < [email protected]; [email protected]++) {
		mes " > "[email protected][[email protected]]+"x "+getitemname([email protected][[email protected]]);
		if (countitem([email protected][[email protected]]) < [email protected][[email protected]])
			[email protected]++;
	}
	if ([email protected]) {
		next;
		if (select("Submit Quest", "Cancel") == 1) {
			for ([email protected] = 0; [email protected] < [email protected]; [email protected]++)
				delitem [email protected][[email protected]], [email protected][[email protected]];
			getitem [email protected][0], [email protected][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
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
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
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 [email protected], 4001, 1;
			setarray [email protected], 512;
			setarray [email protected], 100;
			break;
		case 2:
			setarray [email protected], 4002, 1;
			setarray [email protected], 501, 502, 503;
			setarray [email protected], 3, 1, 2;
			break;
		default:
			mes "invalid quest.";
			close;
	}
	mes "Quest Requirement(s):";
	[email protected] = getarraysize([email protected]);
	for ([email protected] = 0; [email protected] < [email protected]; [email protected]++) {
		mes " > "[email protected][[email protected]]+"x "+getitemname([email protected][[email protected]]);
		if (countitem([email protected][[email protected]]) < [email protected][[email protected]])
			[email protected]++;
	}
	if ([email protected]) {
		next;
		if (select("Submit Quest", "Cancel") == 1) {
			for ([email protected] = 0; [email protected] < [email protected]; [email protected]++)
				delitem [email protected][[email protected]], [email protected][[email protected]];
			getitem [email protected][0], [email protected][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

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 [email protected], 4001, 1;
			setarray [email protected], 512;
			setarray [email protected], 100;
			break;
		case 2:
			setarray [email protected], 4002, 1;
			setarray [email protected], 501, 502, 503;
			setarray [email protected], 3, 1, 2;
			break;
		default:
			mes "invalid quest.";
			close;
	}
	mes "Quest Requirement(s):";
	[email protected] = getarraysize([email protected]);
	for ([email protected] = 0; [email protected] < [email protected]; [email protected]++) {
		mes " > "[email protected][[email protected]]+"x "+getitemname([email protected][[email protected]]);
		if (countitem([email protected][[email protected]]) < [email protected][[email protected]])
			[email protected]++;
	}
	if ([email protected]) {
		next;
		if (select("Submit Quest", "Cancel") == 1) {
			for ([email protected] = 0; [email protected] < [email protected]; [email protected]++)
				delitem [email protected][[email protected]], [email protected][[email protected]];
			getitem [email protected][0], [email protected][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
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 [email protected], 4001, 1;
			setarray [email protected], 512;
			setarray [email protected], 100;
			break;
		case 2:
			setarray [email protected], 4002, 1;
			setarray [email protected], 501, 502, 503;
			setarray [email protected], 3, 1, 2;
			break;
		default:
			mes "invalid quest.";
			close;
	}
	mes "Quest Requirement(s):";
	[email protected] = getarraysize([email protected]);
	for ([email protected] = 0; [email protected] < [email protected]; [email protected]++) {
		mes " > "[email protected][[email protected]]+"x "+getitemname([email protected][[email protected]]);
		if (countitem([email protected][[email protected]]) < [email protected][[email protected]])
			[email protected]++;
	}
	if ([email protected]) {
		next;
		if (select("Submit Quest", "Cancel") == 1) {
			for ([email protected] = 0; [email protected] < [email protected]; [email protected]++)
				delitem [email protected][[email protected]], [email protected][[email protected]];
			getitem [email protected][0], [email protected][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

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 [email protected], 4001, 1;
			setarray [email protected], 512;
			setarray [email protected], 100;
			break;
		case 2:
			setarray [email protected], 4002, 1;
			setarray [email protected], 501, 502, 503;
			setarray [email protected], 3, 1, 2;
			break;
		default:
			mes "invalid quest.";
			close;
	}
	
	mes "Quest Requirement(s):";
	[email protected] = getarraysize([email protected]);
	for ([email protected] = 0; [email protected] < [email protected]; [email protected]++) {
		mes " > "[email protected][[email protected]]+"x "+getitemname([email protected][[email protected]]);
		if (countitem([email protected][[email protected]]) < [email protected][[email protected]])
			[email protected]++;
	}
	if ([email protected]) {
		next;
		if (select("Submit Quest", "Cancel") == 1) {
			for ([email protected] = 0; [email protected] < [email protected]; [email protected]++)
				delitem [email protected][[email protected]], [email protected][[email protected]];
			getitem [email protected][0], [email protected][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 [email protected], 4001, 1;
			setarray [email protected], 512;
			setarray [email protected], 100;
			break;
		case 2:
			setarray [email protected], 4002, 1;
			setarray [email protected], 501, 502, 503;
			setarray [email protected], 3, 1, 2;
			break;
		default:
			mes "invalid quest.";
			close;
	}
	
	mes "Quest Requirement(s):";
	[email protected] = getarraysize([email protected]);
	for ([email protected] = 0; [email protected] < [email protected]; [email protected]++) {
		mes " > "[email protected][[email protected]]+"x "+getitemname([email protected][[email protected]]);
		if (countitem([email protected][[email protected]]) < [email protected][[email protected]])
			[email protected]++;
	}
	if ([email protected]) {
		next;
		if (select("Submit Quest", "Cancel") == 1) {
			for ([email protected] = 0; [email protected] < [email protected]; [email protected]++)
				delitem [email protected][[email protected]], [email protected][[email protected]];
			getitem [email protected][0], [email protected][1];
			quest_random = 0;
			quest_random_cd = gettime(8);
		}
	}
	close;
}

 

Edited by Emistry
  • Love 1
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...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.