Jump to content
  • 0

Is it possible to add reg_value to an npc?


Meister

Question


  • Group:  Members
  • Topic Count:  280
  • Topics Per Day:  0.06
  • Content Count:  841
  • Reputation:   17
  • Joined:  04/16/12
  • Last Seen:  

For example: There are 2 npcs located at same map.. but the other npc is in an isolated same map like for example a tiny cell.. It's like a quest wherein.. 3 players are trying to do the quest at the same time but the problem is the npc only can entertain 1 player at a time. Since they're at the same map (NPC) and getuser won't help to check if there is trying to do the quest.. I want the 2 npc to communicate via a reg_value. If one player talks to an NPC he will warp it to the 2nd npc and then 2nd npc will raise the variable to 1. And if the other 2 players want to take the quest they can't since the 1st npc read the variable as one therefore there is a player still doing the quest..

 

 

Edited by Gnome
Link to comment
Share on other sites

3 answers to this question

Recommended Posts


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

something like this ?

http://pastebin.com/raw.php?i=BQVZiLvd

 

you can use those NPC variable..or temporary global variable for this kind of script...

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  280
  • Topics Per Day:  0.06
  • Content Count:  841
  • Reputation:   17
  • Joined:  04/16/12
  • Last Seen:  

Cool i'll try this. Thanks.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  75
  • Topics Per Day:  0.02
  • Content Count:  2223
  • Reputation:   593
  • Joined:  10/26/11
  • Last Seen:  

Use NPC variables attached to the "main" NPC in the quest:

- one to store the char_id of the character currently doing the quest

- another to store the quest step they're at

Then NPC 2 can use getvariableofnpc to check those variables in NPC 1.

prontera,155,180,0	script	quest_step1	910,{
	if (.char_id == 0) {
		// quest is open
		mes "Do you want to start this quest?"
		mes " ";
		if (select("Yes:No")==1) {
			if (.char_id) {
				mes "Too slow! Someone else already started the quest...";
			} else {
				set .char_id, getcharid(0);
				set .quest_endtime, gettimetick(2) + 300; // 300 seconds = 5 minutes
				set .quest_step, 1;
				initnpctimer "quest_step1";
				mes "^008000 STEP 1 Complete! ^000000";
				mes "Now, go talk to Step 2.";
			}
		}
	} else if (.char_id == getcharid(0)) {
		// in progress
		switch(.quest_step) {
		case 1:
			mes "You've already completed step 1.";
			mes "Proceed to step 2 -->";
			break;
		case 2:
			// other message to tell them they are "in progress"
			break;
		default:
			mes "Keep doing all the steps until you finish!";
			break;
		}
	} else {
		// in progress (another player is doing quest)
		mes "Another player is currently doing this quest.";
		mes "Please wait " + Time2Str(.quest_endtime);
	}
	close;
OnTimer300000:
	stopnpctimer;
	set .char_id, 0;
	set .quest_endtime, 0; // 300 seconds = 5 minutes
	set .quest_step, 0;
	end;
}
 
prontera,158,180,0	script	quest_step2	910,{
	if (getvariableofnpc(.char_id, "quest_step1") == 0) {
		// quest is open
		mes "To start the quest, first talk to Step 1.";
	} else if (getvariableofnpc(.char_id, "quest_step1") == getcharid(0)) {
		// in progress
		switch(getvariableofnpc(.quest_step, "quest_step1")) {
		case 1:
			set getvariableofnpc(.quest_step, "quest_step1"), 2;
			mes "^008000 STEP 2 Complete! ^000000";
			next;
			mes "All done  *_*";
			set getvariableofnpc(.char_id, "quest_step1"), 0;
			set getvariableofnpc(.quest_endtime, "quest_step1"), 0;
			set getvariableofnpc(.quest_step, "quest_step1"), 0;
			stopnpctimer "quest_step1"
			break;
		}
	} else {
		// in progress (another player is doing quest)
		mes "Another player is currently doing this quest.";
		mes "Please wait " + Time2Str(getvariableofnpc(.quest_endtime, "quest_step1"));
	}
	close;
}
Edited by Brian
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...