stock SetPlayerToFacePlayera(playerid, facingtoid)
{
new Float:x, Float:y, Float:z, Float:ix, Float:iy, Float:iz, Float:angle;
GetPlayerPos(facingtoid, x, y, z);
GetPlayerPos(playerid, ix, iy, iz);
angle = 180.0-atan2(ix-x,iy-y);
new string[196];
format(string,sizeof(string),"!PAWN- Playerid: X: %f, Y: %f, Z: %f | facingID: X: %f, Y: %f, Z: %f Unghiul %f",ix, iy, iz,x, y, z,angle);
WriteLog(string);
}
PLUGIN_FUNCTION n_SetPlayerFaceToPlayer( AMX* amx, cell* params )
{
float x, y, z, ix, iy, iz, angle;
callFunction(&PAWN::GetPlayerPos, params[2], &x, &y, &z);
callFunction(&PAWN::GetPlayerPos, params[1], &ix, &iy, &iz);
angle = 180.0-atan2(ix-x,iy-y);
Log("!PLUGIN- Playerid: X: %f, Y: %f, Z: %f | facingID: X: %f, Y: %f, Z: %f Unghiul %f",ix, iy, iz,x, y, z,angle);
}
[Wed Dec 1 03:33:44 2010] DEBUG: "!PAWN- Playerid: X: 1544.198242, Y: -1631.901489, Z: 13.382812 | facingID: X: 1539.359008, Y: -1627.401000, Z: 13.103496 Unghiul 47.077163". [Wed Dec 1 03:33:44 2010] DEBUG: "!PLUGIN- Playerid: X: 1544.198242, Y: -1631.901489, Z: 13.382812 | facingID: X: 1539.359009, Y: -1627.401001, Z: 13.103497 Unghiul 177.680054".
[Wed Dec 1 14:29:24 2010] DEBUG: "!PAWN- Playerid: X: 1544.198242, Y: -1631.901489, Z: 13.382812 | facingID: X: 1539.011840, Y: -1628.687988, Z: 13.102458 Unghiul 58.217597". [Wed Dec 1 14:29:24 2010] DEBUG: "!PLUGIN- Playerid: X: 1544.198242, Y: -1631.901489, Z: 13.382812 | facingID: X: 1539.011841, Y: -1628.687988, Z: 13.102459 Unghiul 180.554703". [Wed Dec 1 14:31:44 2010] DEBUG: "!PAWN- Playerid: X: 1544.198242, Y: -1631.901489, Z: 13.382812 | facingID: X: 1538.126464, Y: -1630.241821, Z: 13.104832 Unghiul 74.712142". [Wed Dec 1 14:31:44 2010] DEBUG: "!PLUGIN- Playerid: X: 1544.198242, Y: -1631.901489, Z: 13.382812 | facingID: X: 1538.126465, Y: -1630.241821, Z: 13.104833 Unghiul 180.266830". [Wed Dec 1 14:32:00 2010] DEBUG: "!PAWN- Playerid: X: 1544.198242, Y: -1631.901489, Z: 13.382812 | facingID: X: 1548.454101, Y: -1627.056396, Z: 13.105273 Unghiul 318.704406". [Wed Dec 1 14:32:00 2010] DEBUG: "!PLUGIN- Playerid: X: 1544.198242, Y: -1631.901489, Z: 13.382812 | facingID: X: 1548.454102, Y: -1627.056396, Z: 13.105273 Unghiul 182.291534".
angle = 180.0f - ( atan2( iy-y, ix-x ) * ( 3.14159265f / 180.0f ));
PLUGIN_FUNCTION n_SetPlayerFaceToPlayer( AMX* amx, cell* params )
{
float x, y, z, ix, iy, iz, angle;
callFunction(&PAWN::GetPlayerPos, params[2], &x, &y, &z);
callFunction(&PAWN::GetPlayerPos, params[1], &ix, &iy, &iz);
//angle = 180.0-atan2(iy-y,ix-x);
angle = 180.0f - ( atan2( iy-y, ix-x ) * ( 3.14159265f / 180.0f ));
Log("DEBUG: \"!PLUGIN- Playerid: X: %f, Y: %f, Z: %f | facingID: X: %f, Y: %f, Z: %f Unghiul %f\".",ix, iy, iz,x, y, z,angle);
}
[Wed Dec 1 14:39:53 2010] DEBUG: "!PAWN- Playerid: X: 1544.198242, Y: -1631.901489, Z: 13.382812 | facingID: X: 1540.246215, Y: -1627.771362, Z: 13.098144 Unghiul 43.737625". [Wed Dec 1 14:39:53 2010] DEBUG: "!PLUGIN- Playerid: X: 1544.198242, Y: -1631.901489, Z: 13.382812 | facingID: X: 1540.246216, Y: -1627.771362, Z: 13.098145 Unghiul 180.014099". [Wed Dec 1 14:40:12 2010] DEBUG: "!PAWN- Playerid: X: 1544.198242, Y: -1631.901489, Z: 13.382812 | facingID: X: 1548.842773, Y: -1628.033325, Z: 13.102981 Unghiul 309.788970". [Wed Dec 1 14:40:12 2010] DEBUG: "!PLUGIN- Playerid: X: 1544.198242, Y: -1631.901489, Z: 13.382812 | facingID: X: 1548.842773, Y: -1628.033325, Z: 13.102982 Unghiul 180.042709".
angle = 180.0f - ( atan2( iy-y, ix-x ) * ( 180.0f / 3.14159265f ) );
[Wed Dec 1 14:49:05 2010] DEBUG: "!PAWN- Playerid: X: 1544.198242, Y: -1631.901489, Z: 13.382812 | facingID: X: 1548.151367, Y: -1627.234130, Z: 13.104700 Unghiul 319.736328". [Wed Dec 1 14:49:05 2010] DEBUG: "!PLUGIN- Playerid: X: 1544.198242, Y: -1631.901489, Z: 13.382812 | facingID: X: 1548.151367, Y: -1627.234131, Z: 13.104700 Unghiul 310.263672". [Wed Dec 1 14:49:34 2010] DEBUG: "!PAWN- Playerid: X: 1544.198242, Y: -1631.901489, Z: 13.382812 | facingID: X: 1548.151367, Y: -1627.234130, Z: 13.104700 Unghiul 319.736328". [Wed Dec 1 14:49:34 2010] DEBUG: "!PLUGIN- Playerid: X: 1544.198242, Y: -1631.901489, Z: 13.382812 | facingID: X: 1548.151367, Y: -1627.234131, Z: 13.104700 Unghiul 310.263672". [Wed Dec 1 14:49:49 2010] DEBUG: "!PAWN- Playerid: X: 1544.198242, Y: -1631.901489, Z: 13.382812 | facingID: X: 1540.595581, Y: -1628.579833, Z: 13.103104 Unghiul 47.323928". [Wed Dec 1 14:49:49 2010] DEBUG: "!PLUGIN- Playerid: X: 1544.198242, Y: -1631.901489, Z: 13.382812 | facingID: X: 1540.595581, Y: -1628.579834, Z: 13.103105 Unghiul 222.676071". [Wed Dec 1 14:51:04 2010] DEBUG: "!PAWN- Playerid: X: 1544.198242, Y: -1631.901489, Z: 13.382812 | facingID: X: 1541.014892, Y: -1634.031372, Z: 13.327032 Unghiul 123.785278". [Wed Dec 1 14:51:04 2010] DEBUG: "!PLUGIN- Playerid: X: 1544.198242, Y: -1631.901489, Z: 13.382812 | facingID: X: 1541.014893, Y: -1634.031372, Z: 13.327032 Unghiul 146.214722".
angle = 90.0f - ( atan2( y-iy, x-ix ) * ( 180.0f / 3.1415f ) );
[Wed Dec 1 15:49:58 2010] DEBUG: "!PAWN- Playerid: X: 1544.198242, Y: -1631.901489, Z: 13.382812 | facingID: X: 1540.967651, Y: -1628.268066, Z: 13.103264 Unghiul 41.641311". [Wed Dec 1 15:49:58 2010] DEBUG: "!PLUGIN- Playerid: X: 1544.198242, Y: -1631.901489, Z: 13.382812 | facingID: X: 1540.967651, Y: -1628.268066, Z: 13.103265 Unghiul -41.645187". [Wed Dec 1 15:50:12 2010] DEBUG: "!PAWN- Playerid: X: 1544.198242, Y: -1631.901489, Z: 13.382812 | facingID: X: 1545.893432, Y: -1627.286132, Z: 13.092100 Unghiul 339.832031". [Wed Dec 1 15:50:12 2010] DEBUG: "!PLUGIN- Playerid: X: 1544.198242, Y: -1631.901489, Z: 13.382812 | facingID: X: 1545.893433, Y: -1627.286133, Z: 13.092100 Unghiul 20.165895".
However I would be VERY careful with rewriting your mode in C, especially if you have a lot of calls to native functions, because there is no direct access so there are very large overheads involved.
|