Jump to content
  • 0

Check if player exits OnTouch Zone


Syouji

Question


  • Group:  Members
  • Topic Count:  70
  • Topics Per Day:  0.02
  • Content Count:  1245
  • Reputation:   392
  • Joined:  11/19/11
  • Last Seen:  

So what I'm trying to do is to have the script check if a player is still within the OnTouch zone. Here is an example NPC:

brasilis,249,60,0 script School of Fish#fs1 723,2,2,{
end;
OnTouch:
set .fishno,1;
callfunc "fishfunc",.fishno;
end;
}

In the function "fishfunc" I want it to perform a check to see if that player is still within the 2x2 cell radius around 249,60. If the user is still in that area they can continue with fishing, if not, they cannot fish. There is already a menu that pops up immediately stating if they wish to fish when they enter that OnTouch zone as long as they meet the required conditions. I just dont want people to walk across an OnTouch zone bypassing the area around the fishing zone and continue to fish. Just doesn't make sense.

getmapxy(.npcMap$, .npcX, .npcY, 1, strnpcinfo(0)) might somehow be used in this. I need some help here ;x

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 1

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

erm..i think you can try make use of the distance...

brasilis,249,60,0 script School of Fish#fs1 723,2,2,{
end;
OnTouch:
do{
set .@fishno,1;
callfunc "fishfunc",.@fishno;
getmapxy( .@NPCMAP,.@NPCX,.@NPCY,1 );
getmapxy( .@PCMAP,.@PCX,.@PCY,0 );
}while( distance( .@NPCX,.@NPXY,.@PCX,.@PCY ) <= 2 );
end;
}

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  70
  • Topics Per Day:  0.02
  • Content Count:  1245
  • Reputation:   392
  • Joined:  11/19/11
  • Last Seen:  

Thanks Emistry. Ill try it out =)

Edit: SOLVED

For those who are interested in how I did it, using Emistry's idea:

// Player and npc coordinates at the time of the shot
getmapxy $@mapname$,$@mapxNPC,$@mapyNPC,1;
getmapxy $@mapname$,$@mapxPC,$@mapyPC,0;
// verification of the player's distance
if (distance($@mapxNPC,$@mapyNPC,$@mapxPC,$@mapyPC)>2) {
mes "You cannot fish at this distance.";
close;
}

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...