How to detect if someone is near a spawned object in game? -
marharth - 26.12.2010
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?
Re: How to detect if someone is near a spawned object in game? -
boelie - 26.12.2010
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);
}
Re: How to detect if someone is near a spawned object in game? -
cessil - 26.12.2010
use IsPlayerInRangeOfPoint, it's already defined
Re: How to detect if someone is near a spawned object in game? -
Mean - 26.12.2010
Use IsPlayerInRangeOfPoint, with the object pos, or use boelie's stock.
Re: How to detect if someone is near a spawned object in game? -
marharth - 26.12.2010
My question is how I would use isplayerinrangeofpoint with a object that was created by that...
Re: How to detect if someone is near a spawned object in game? -
cessil - 26.12.2010
you'd store the x, y and z as global variables and then use them to check its location
Re: How to detect if someone is near a spawned object in game? -
marharth - 26.12.2010
So how would I store them lol?
Re: How to detect if someone is near a spawned object in game? -
marharth - 26.12.2010
bump...
Re: How to detect if someone is near a spawned object in game? -
marharth - 28.12.2010
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?
Re: How to detect if someone is near a spawned object in game? -
willsuckformoney - 28.12.2010
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?
}