SA-MP Forums Archive
Actor's facing angle problems - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Actor's facing angle problems (/showthread.php?tid=572429)



Actor's facing angle problems - Gammix - 28.04.2015

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;
}



Re: Actor's facing angle problems - (SF)Noobanatior - 28.04.2015

can you post PED_SetFacingPlayer(0, playerid) not setfacingpoint please


Re: Actor's facing angle problems - Gammix - 28.04.2015

It uses PED_SetFacingPoint, but here it is:
pawn Код:
stock PED_SetFacingPlayer(pedid, playerid)
{
    if(! PED_IsConnected(pedid)) return false;
    if(! IsPlayerConnected(playerid)) return false;

    new Float:pX, Float:pY, Float:pZ;
    GetPlayerPos(playerid, pX, pY, pZ);

    return PED_SetFacingPoint(pedid, pX, pY);
}
* I also gave the debug mode for test if you want.

The problem is, when i type /face it makes the PED face me and when i type /goto and then /stop, it makes the ped stop. But after that when i type /face, it does nothing to the PED.

Also i recently found that when ped stream out, then i am able to make it face me once.


EDIT: http://forum.sa-mp.com/showthread.ph...33#post3443333


Re: Actor's facing angle problems - (SF)Noobanatior - 28.04.2015

cant see it what does PED_Stop(0); do?


Re: Actor's facing angle problems - Gammix - 28.04.2015

It just clears the animation of the actor. Read the source (peds.inc) for more explainations.

BTW i have reported the bug here: http://forum.sa-mp.com/showthread.ph...33#post3443333