return ( ( ((px-X)*(px-X))+((py-Y)*(py-Y))+((pz-Z)*(pz-Z)) ) >= radius*radius );
private bool IsPlayerInRangeOfPoint(Player pl, float radius, float X, float Y, float Z)
{
float px, py, pz;
px = pl.Pos.X;
py = pl.Pos.Y;
pz = pl.Pos.Z;
float dist = (((px - X) * (px - X)) + ((py - Y) * (py - Y)) + ((pz - Z) * (pz - Z)));
float radi = radius * radius;
if (dist >= radi)
{
return true;
}
else
{
return false;
}
}
private bool IsPlayerInRangeOfPoint(Player pl, float radius, Vector3 other)
{
if (pl.Pos.Distance(other) < radius) return true;
return false;
}
public float Distance(Vector3 other)
{
// __________________________________
//d = √ (x2-x1)^2 + (y2-y1)^2 + (z2-z1)^2
//
//Our end result
float result = 0.0F;
//Take x2-x1, then square it
double part1 = Math.Pow((other.X - this.X), 2);
//Take y2-y1, then sqaure it
double part2 = Math.Pow((other.Y - this.Y), 2);
//Take z2-z1, then square it
double part3 = Math.Pow((other.Z - this.Z), 2);
//Add both of the parts together
double underRadical = part1 + part2 + part3;
//Get the square root of the parts
result = (float)Math.Sqrt(underRadical);
//Return our result
return result;
}
|
Code looks right to me.
There is a Vector3 method for getting distance that will make life easier though. Код:
private bool IsPlayerInRangeOfPoint(Player pl, float radius, Vector3 other)
{
if (pl.Pos.Distance(other) < radius) return true;
return false;
}
Код:
public float Distance(Vector3 other)
{
// __________________________________
//d = √ (x2-x1)^2 + (y2-y1)^2 + (z2-z1)^2
//
//Our end result
float result = 0.0F;
//Take x2-x1, then square it
double part1 = Math.Pow((other.X - this.X), 2);
//Take y2-y1, then sqaure it
double part2 = Math.Pow((other.Y - this.Y), 2);
//Take z2-z1, then square it
double part3 = Math.Pow((other.Z - this.Z), 2);
//Add both of the parts together
double underRadical = part1 + part2 + part3;
//Get the square root of the parts
result = (float)Math.Sqrt(underRadical);
//Return our result
return result;
}
|
public void SpawnPlayerCar(int playerid)
{
int model = 429; //banshee
Samp.Util.FloatRef x = 0.0F, y = 0.0F, z = 0.0F, angle = 0.0F; // must use FloatRef class to return floats from native function, same goes for StringRef & IntRef
Samp.Client.NativeFunctionRequestor.RequestFunction("GetPlayerPos", playerid, x, y, z);
NativeFunctionRequestor.RequestFunction("GetPlayerFacingAngle", playerid, angle);
int vehicleid = NativeFunctionRequestor.RequestFunction("CreateVehicle", model, x.Value, y.Value, z.Value, angle.Value, 0, 0, 300);// note that we use x.Value now
NativeFunctionRequestor.RequestFunction("PutPlayerInVehicle", playerid,vehicleid,0);
NativeFunctionRequestor.RequestFunction("SendClientMessage", playerid, 0,"{00FF00}Vehicle Spawned.");
}
|
Oh yeah, good idea, i'll add that.
I never realy thought much on it, but it should be relatively simple (famous last words) to add both calling .net functions from pawn & calling pawn functions from .net. I've had too many beers to comtemplate it properly at the moment, but i'll see about adding it tomorrow-ish. |