new Float:a, targetid;
GetPlayerFacingAngle(targetid, a);
SetPlayerFacingAngle(playerid, -a);
SetPlayerToFacePlayer(playerid, targetid)
{
new
Float:pX,
Float:pY,
Float:pZ,
Float:X,
Float:Y,
Float:Z,
Float:ang;
if(!IsPlayerConnected(playerid) || !IsPlayerConnected(targetid)) return 0;
GetPlayerPos(targetid, X, Y, Z);
GetPlayerPos(playerid, pX, pY, pZ);
if( Y > pY ) ang = (-acos((X - pX) / floatsqroot((X - pX)*(X - pX) + (Y - pY)*(Y - pY))) - 90.0);
else if( Y < pY && X < pX ) ang = (acos((X - pX) / floatsqroot((X - pX)*(X - pX) + (Y - pY)*(Y - pY))) - 450.0);
else if( Y < pY ) ang = (acos((X - pX) / floatsqroot((X - pX)*(X - pX) + (Y - pY)*(Y - pY))) - 90.0);
if(X > pX) ang = (floatabs(floatabs(ang) + 180.0));
else ang = (floatabs(ang) - 180.0);
SetPlayerFacingAngle(playerid, ang);
return 0;
}//include a_angles
Well, how do you get "targetid"'s value? And how doesn't it work perfectly?
|
SetPlayerToFacePlayer(playerid, targetid) {
new
Float: pX,
Float: pY,
Float: tX,
Float: tY
;
return
GetPlayerPos(targetid, tX, tY, Float: targetid) &&
GetPlayerPos(playerid, pX, pY, Float: targetid) &&
SetPlayerFacingAngle(playerid, -atan2(tX - pX, tY - pY))
;
}
(1533) : warning 219: local variable "pX" shadows a variable at a preceding level (1533) : warning 219: local variable "pY" shadows a variable at a preceding level (1533) : warning 219: local variable "pZ" shadows a variable at a preceding level (1537) : error 035: argument type mismatch (argument 2) (1539) : warning 213: tag mismatch (1539) : warning 213: tag mismatch (1539) : warning 213: tag mismatch (1539) : warning 213: tag mismatch (1539) : warning 213: tag mismatch (1539) : warning 213: tag mismatch (1540) : warning 213: tag mismatch (1540) : warning 213: tag mismatch (1540) : warning 213: tag mismatch (1540) : warning 213: tag mismatch (1540) : warning 213: tag mismatch (1540) : warning 213: tag mismatch (1540) : warning 213: tag mismatch (1541) : warning 213: tag mismatch (1541) : warning 213: tag mismatch (1541) : warning 213: tag mismatch (1541) : warning 213: tag mismatch (1541) : warning 213: tag mismatch (1541) : warning 213: tag mismatch (1543) : warning 213: tag mismatch (1533) : warning 203: symbol is never used: "pZ" (1533) : warning 203: symbol is never used: "pY" (1533) : warning 203: symbol is never used: "pX" Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase 1 Error.
(1552) : warning 219: local variable "pX" shadows a variable at a preceding level (1553) : warning 219: local variable "pY" shadows a variable at a preceding level (1558 -- 1559) : error 035: argument type mismatch (argument 2) (1553) : warning 203: symbol is never used: "pY" (1552) : warning 203: symbol is never used: "pX" Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase 1 Error.
SetPlayerToFacePlayer(playerid, targetid) {
new
Float: aX,
Float: aY,
Float: tX,
Float: tY
;
return
GetPlayerPos(targetid, tX, tY, Float: targetid) &&
GetPlayerPos(playerid, aX, aY, Float: targetid) &&
SetPlayerFacingAngle(playerid, -atan2(tX - aX, tY - aY))
;
}