26.03.2010, 11:22
pawn Код:
stock GetPosFromView(playerid, Float:distance, &Float:x, &Float:y, &Float:z)
{
new Float:cx,Float:cy,Float:cz,Float:fx,Float:fy,Float:fz;
GetPlayerCameraPos(playerid, cx, cy, cz);
GetPlayerCameraFrontVector(playerid, fx, fy, fz);
x = fx * distance + cx;
y = fy * distance + cy;
z = fz * distance + cz;
}
This function returns coords of the point a player is looking at, depending on the distance.
Example:
pawn Код:
zcmd(bang,playerid,params[])
{
new Float:r;
if(sscanf(params,"f",r)) {}
else
{
new Float:x,Float:y,Float:z;
GetPlayerPos(playerid, x, y, z);
GetPosFromView(playerid, r, x, y, z);
CreateExplosion(x, y, z, 2, 10);
}
return 1;
}