Jump to content
  • 0
celeron0134

npc that checks cells if there's already a player on that cell

Question

this NPC checks if the user is on the right cell so the user can talk or not talk to the NPC.. 

if you are outside the cell.. and a player is already in the cell you cant talk to the NPC or a dialogue will pop up that someone is still in front of me

wait for him/her to leave the cell

quiz_02,246,374,4	script	cell checker	112,{

	.@n = getareausers("quiz_02", 246, 372, 246, 372);

	if (.@n < 1) {
	mes "["+ strnpcinfo(0) +"]";
	mes "Please stand in front of me to talk";
	close;
}

	if (.@n == 1)
	mes "["+ strnpcinfo(0) +"]";
	mes "Congrats you are now in front of me";
	close;
	}else{
		npctalk "Too many people in front of me, only one person will be teleported in next 10 minute.";
	end;

}

i need something like this

	if ((.@n == 1) && (strcharinfo(0) != .@n))
	mes "someone is on front of me";
	mes "and i am waiting for him/her to talk to me";
	mes "wait till the player leave the cell";
	end;

 

Share this post


Link to post
Share on other sites

6 answers to this question

Recommended Posts

  • 0
23 hours ago, celeron0134 said:

this NPC checks if the user is on the right cell so the user can talk or not talk to the NPC.. 

if you are outside the cell.. and a player is already in the cell you cant talk to the NPC or a dialogue will pop up that someone is still in front of me

wait for him/her to leave the cell

quiz_02,246,374,4 script cell checker 112,{ .@n = getareausers("quiz_02", 246, 372, 246, 372); if (.@n < 1) { mes "["+ strnpcinfo(0) +"]"; mes "Please stand in front of me to talk"; close; } if (.@n == 1) mes "["+ strnpcinfo(0) +"]"; mes "Congrats you are now in front of me"; close; }else{ npctalk "Too many people in front of me, only one person will be teleported in next 10 minute."; end; }


quiz_02,246,374,4	script	cell checker	112,{

	.@n = getareausers("quiz_02", 246, 372, 246, 372);

	if (.@n < 1) {
	mes "["+ strnpcinfo(0) +"]";
	mes "Please stand in front of me to talk";
	close;
}

	if (.@n == 1)
	mes "["+ strnpcinfo(0) +"]";
	mes "Congrats you are now in front of me";
	close;
	}else{
		npctalk "Too many people in front of me, only one person will be teleported in next 10 minute.";
	end;

}

i need something like this

if ((.@n == 1) && (strcharinfo(0) != .@n)) mes "someone is on front of me"; mes "and i am waiting for him/her to talk to me"; mes "wait till the player leave the cell"; end;


	if ((.@n == 1) && (strcharinfo(0) != .@n))
	mes "someone is on front of me";
	mes "and i am waiting for him/her to talk to me";
	mes "wait till the player leave the cell";
	end;

 

https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L3737

Share this post


Link to post
Share on other sites
  • 0
On 2/1/2021 at 5:18 PM, celeron0134 said:

this NPC checks if the user is on the right cell so the user can talk or not talk to the NPC.. 

if you are outside the cell.. and a player is already in the cell you cant talk to the NPC or a dialogue will pop up that someone is still in front of me

wait for him/her to leave the cell

quiz_02,246,374,4 script cell checker 112,{ .@n = getareausers("quiz_02", 246, 372, 246, 372); if (.@n < 1) { mes "["+ strnpcinfo(0) +"]"; mes "Please stand in front of me to talk"; close; } if (.@n == 1) mes "["+ strnpcinfo(0) +"]"; mes "Congrats you are now in front of me"; close; }else{ npctalk "Too many people in front of me, only one person will be teleported in next 10 minute."; end; }


quiz_02,246,374,4	script	cell checker	112,{

	.@n = getareausers("quiz_02", 246, 372, 246, 372);

	if (.@n < 1) {
	mes "["+ strnpcinfo(0) +"]";
	mes "Please stand in front of me to talk";
	close;
}

	if (.@n == 1)
	mes "["+ strnpcinfo(0) +"]";
	mes "Congrats you are now in front of me";
	close;
	}else{
		npctalk "Too many people in front of me, only one person will be teleported in next 10 minute.";
	end;

}

i need something like this

if ((.@n == 1) && (strcharinfo(0) != .@n)) mes "someone is on front of me"; mes "and i am waiting for him/her to talk to me"; mes "wait till the player leave the cell"; end;


	if ((.@n == 1) && (strcharinfo(0) != .@n))
	mes "someone is on front of me";
	mes "and i am waiting for him/her to talk to me";
	mes "wait till the player leave the cell";
	end;

 

you didnt mention your problem, or what exactly you want..
difficult to assume what you are looking for ...

Share this post


Link to post
Share on other sites
  • 0
On 2/2/2021 at 10:14 PM, Master@Ragna said:

you didnt mention your problem, or what exactly you want..
difficult to assume what you are looking for ...

Problem of the script

.@n = getareausers("quiz_02", 246, 372, 246, 372);

1) if player A is on .@n and player B is not on .@n ~ Player B can talk to the NPC

 

what to do:

1) if Player A is on .@n (talking or not talking to the NPC) Player B will not be able to talk to the NPC

    for example .. on a soda machine.. only 1 person at a time can use the soda machine

 

	if ((.@n == 1) && (strcharinfo(0) is not on .@n))
	mes "someone is on front of me";
	mes "and i am waiting for him/her to talk to me";
	mes "wait till the player leave the cell";
	end;


  

 

Share this post


Link to post
Share on other sites
  • 0
35 minutes ago, celeron0134 said:

Problem of the script

.@n = getareausers("quiz_02", 246, 372, 246, 372);

1) if player A is on .@n and player B is not on .@n ~ Player B can talk to the NPC

 

what to do:

1) if Player A is on .@n (talking or not talking to the NPC) Player B will not be able to talk to the NPC

    for example .. on a soda machine.. only 1 person at a time can use the soda machine

 

if ((.@n == 1) && (strcharinfo(0) is not on .@n)) mes "someone is on front of me"; mes "and i am waiting for him/her to talk to me"; mes "wait till the player leave the cell"; end;


	if ((.@n == 1) && (strcharinfo(0) is not on .@n))
	mes "someone is on front of me";
	mes "and i am waiting for him/her to talk to me";
	mes "wait till the player leave the cell";
	end;


  

 

You can use this command:

Spoiler

*getunits(<type>, <variable>, <limit>{, "<map>"{, <x1>, <y1>, <x2>, <y2>}})

This function searches a whole map or area for units and adds their GID to
the provided <variable> array. It filters units by <type> and stops searching
after <limit> units have been found. Set <limit> to false (0) if you wish to
disable the limit altogether. If <map> is omitted, this command will search
on the whole server (slow). Returns the number of units added to the array.

Type is the type of unit to search for:

	BL_PC    - Character object
	BL_MOB   - Monster object
	BL_PET   - Pet object
	BL_HOM   - Homunculus object
	BL_MER   - Mercenary object
	BL_ITEM  - Item object (item drops)
	BL_SKILL - Skill object (skill fx & sfx)
	BL_NPC   - NPC object
	BL_CHAT  - Chat object
	BL_ELEM  - Elemental object
	BL_CHAR  - Shorthand for (BL_PC|BL_MOB|BL_HOM|BL_MER|BL_ELEM)
	BL_ALL   - Any kind of object

** Do NOT use UNITTYPE_ constants here, they have different values.

** If battle_config.dynamic_mobs is enabled and no player has entered the map
   yet, the mobs will not have spawned in the map yet, so getunits() will be
   unable to find them when searching for BL_MOB.

Example:

	.@count = getunits((BL_PC | BL_NPC), .@units, false, "prontera");

The above example would search the map "prontera" for all PC and NPC units and
add them to the .@units array, while setting .@count to the amount of units
added to the array (useful in for() loops).

 

 

Share this post


Link to post
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.   Restore formatting

  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.

Loading...

×
×
  • Create New...

Important Information

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