![]() |
NPC range check/Place NPC
question 1
Let's say I have a NPC on a looping TimeOut(). What is the code to check to see if a player is near by? I think it would go SOMETHING like this. PHP Code:
Question 2 I am a little confused on the placeNpc function. How do I place a NPC that joins a certain class? |
Use the distance formula:
http://0.tqn.com/d/math/1/0/A/1/distance.gif Therefore, to get distance PHP Code:
PHP Code:
PHP Code:
You'll probably want to adjust the player's x/y and the object's x/y to reach the center of the object. |
What about the second question???
|
PHP Code:
putnpc2(x, y, script); |
People often use putNPC2() like this:
PHP Code:
|
Quote:
PHP Code:
|
Quote:
|
is there a code for finding the nearest player?
|
Quote:
findnearestplayers(x, y); There isn't a range though, so it doesn't matter how far away the player is, as long as they're closest to the NPC then they'll be picked up. You can get around it by doing: PHP Code:
PHP Code:
|
| All times are GMT +2. The time now is 10:01 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.