How to detect if someone is near a spawned object in game?
#1

So basically I type a command to make the below happen...
Код:
new Float:x,Float:y,Float:z;
GetPlayerPos(playerid,x,y,z);
CreateObject(677,x,y,z-1,0,0,0);
That's fine, but what I need to do is figure out a way to see if someone is near that object that was created by the command, some help here?
Reply
#2

maybe change this one into IsObjectInRangeOfPlayer...just put a IsPlayerInRangeOfPoint in there somewhere

Код:
stock IsObjectInRangeOfPoint(objectid, Float:range, Float:x, Float:y, Float:z)
{
new
Float:px,
Float:py,
Float:pz;
GetObjectPos(objectid, px, py, pz);
px -= x;
py -= y;
pz -= z;
return ((px * px) + (py * py) + (pz * pz)) < (range * range);
}
Reply
#3

use IsPlayerInRangeOfPoint, it's already defined
Reply
#4

Use IsPlayerInRangeOfPoint, with the object pos, or use boelie's stock.
Reply
#5

My question is how I would use isplayerinrangeofpoint with a object that was created by that...
Reply
#6

you'd store the x, y and z as global variables and then use them to check its location
Reply
#7

So how would I store them lol?
Reply
#8

bump...
Reply
#9

Quote:
Originally Posted by boelie
Посмотреть сообщение
maybe change this one into IsObjectInRangeOfPlayer...just put a IsPlayerInRangeOfPoint in there somewhere

Код:
stock IsObjectInRangeOfPoint(objectid, Float:range, Float:x, Float:y, Float:z)
{
new
Float:px,
Float:py,
Float:pz;
GetObjectPos(objectid, px, py, pz);
px -= x;
py -= y;
pz -= z;
return ((px * px) + (py * py) + (pz * pz)) < (range * range);
}
Can you explain more into that?
Reply
#10

pawn Код:
new Float:X,Float:Y,Float:Z,Float:oX,Float:oY,Float:oZ;
GetPlayerPos(playerid,X,Y,Z);
for(new o = 0; 0 < MAX_OBJECTS; o++)
{
      GetObjectPos(o,oX,oY,oZ);
}
if(IsPlayerInRangeOfPoint(playerid,4,oX,oY,oZ)) //4 = range
{
      //What ya need?
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)