Actor's facing angle problems
#1

Requires SAMP 0.3.7 RC6-2+.

I have been searching for this bug but didn't found any solution.

What happens is, when i join and try my debug commands or make the actor face me, i am successful in doing so but when i apply animation of running on them, and stop after a while they have traveled; and thenn type the same command to make them face me, they don't.

Here is my debug mode:
pawn Код:
#include <a_samp>
#include <zcmd>
#include <peds>

main(){}

public OnPlayerRequestClass(playerid, classid) return GameTextForPlayer(playerid, "~r~PEDS.inc Debug~n~~w~~h~Press SPAWN please", 5000, 3);

public OnPlayerSpawn(playerid)
{
    SetPlayerPos(playerid, 1830.1359,-1092.1849,23.8656);
    if(PED_IsConnected(0)) PED_Disconnect(0);
   
    PED_Connect(78, 1830.1359,-1092.1849,23.8656);
   
    SendClientMessage(playerid, -1, "Debug-Commands list:");
    SendClientMessage(playerid, -1, "/face - set ped to face you");
    SendClientMessage(playerid, -1, "/facing - check if ped is faceing you");
    SendClientMessage(playerid, -1, "/range - check if ped is within your range(10.0 units)");
    SendClientMessage(playerid, -1, "/goto - Make the ped come to your position");
    SendClientMessage(playerid, -1, "/stop - Make the ped to come in rest");
    return 1;
}

CMD:face(playerid) return PED_SetFacingPlayer(0, playerid);
CMD:facing(playerid)
{
    if(PED_IsFacingPlayer(0, playerid)) SendClientMessage(playerid, -1, "/facing: YES");
    else SendClientMessage(playerid, -1, "/facing: NO");
    return 1;
}

CMD:range(playerid)
{
    new Float:pos[3];
    GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
    if(PED_IsInRangeOfPoint(0, 10.0, pos[0], pos[1], pos[2])) SendClientMessage(playerid, -1, "/range: YES");
    else SendClientMessage(playerid, -1, "/range: NO");
    return 1;
}

CMD:goto(playerid)
{
    new Float:pos[3];
    GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
    printf("PED goin to point: %f, %f, %f", pos[0], pos[1], pos[2]);
    return PED_GotoPoint(0, pos[0], pos[1], pos[2]);
}
CMD:stop(playerid) return PED_Stop(0);
NOTE: You need zcmd.inc and peds.inc

* Please give me any solution so that i can continue adding more to the include.


Here is my PED_SetFacingPoint:
pawn Код:
stock PED_SetFacingPoint(pedid, Float:x, Float:y)
{
    if(! PED_IsConnected(pedid)) return false;

    new Float:pX, Float:pY, Float:pZ;
    PED_GetPos(pedid, pX, pY, pZ);
   
    new Float:angle;

    if( y > pY ) angle = (-acos((x - pX) / floatsqroot((x - pX)*(x - pX) + (y - pY)*(y - pY))) - 90.0);
    else if( y < pY && x < pX ) angle = (acos((x - pX) / floatsqroot((x - pX)*(x - pX) + (y - pY)*(y - pY))) - 450.0);
    else if( y < pY ) angle = (acos((x - pX) / floatsqroot((x - pX)*(x - pX) + (y - pY)*(y - pY))) - 90.0);

    if(x > pX) angle = (floatabs(floatabs(angle) + 180.0));
    else angle = (floatabs(angle) - 180.0);

    PED_SetFacingAngle(pedid, angle);//this is just simply SetActorFacingAngle
    return true;
}
Reply


Messages In This Thread
Actor's facing angle problems - by Gammix - 28.04.2015, 07:56
Re: Actor's facing angle problems - by (SF)Noobanatior - 28.04.2015, 08:07
Re: Actor's facing angle problems - by Gammix - 28.04.2015, 08:18
Re: Actor's facing angle problems - by (SF)Noobanatior - 28.04.2015, 08:33
Re: Actor's facing angle problems - by Gammix - 28.04.2015, 08:34

Forum Jump:


Users browsing this thread: 1 Guest(s)