30.06.2018, 18:25
I'm making a pet system with actor. I want to do "/petfollow" command but I couldn't. Can anyone help me? Codes're here.
I found these codes in a Turkish pawn forum.
My variables are:
If I can make this pet system, I will share it.
Код:
CMD:actorolustur(playerid)
{
new Float:pos[4];
GetPlayerPos(playerid,pos[0],pos[1],pos[2]);
GetPlayerFacingAngle(playerid,pos[3]);
ActorPet = CreateActor(311,pos[0],pos[1],pos[2],pos[3]);
return 1;
}
Код:
CMD:gel(playerid)
{
SetTimerEx("MoveActor",1,true,"i",playerid,ActorPet);
return 1;
}
Код:
forward MoveActor(playerid,id);
public MoveActor(playerid,id)
{
if(IsValidActor(id))
{
new Float:x,Float:y,Float:z,Float:angle;
new Float:playerx,Float:playery,Float:playerz;
GetPlayerPos(playerid,playerx,playery,playerz);
GetActorPos(id,x,y,z);
ApplyActorAnimation(id,"ped","run_player",4.1,1,1,1,0,0);
ApplyActorAnimation(id,"ped","run_player",4.1,1,1,1,0,0);
SetActorLookAt(id,playerx,playery);
GetActorFacingAngle(id,angle);
x += 0.01 * floatsin(-angle, degrees);
y += 0.01 * floatcos(-angle, degrees);
new Float:yeniz;
MapAndreas_FindZ_For2DCoord(x,y,yeniz);
SetActorPos(id x, y, yeniz+1);
}
return 1;
}
Код:
stock SetActorLookAt(actorid, Float:X, Float:Y)
{
new Float:Px, Float:Py, Float: Pa;
GetActorPos(actorid, Px, Py, Pa);
Pa = floatabs(atan((Y-Py)/(X-Px)));
if (X <= Px && Y >= Py) Pa = floatsub(180, Pa);
else if (X < Px && Y < Py) Pa = floatadd(Pa, 180);
else if (X >= Px && Y <= Py) Pa = floatsub(360.0, Pa);
Pa = floatsub(Pa, 90.0);
if (Pa >= 360.0) Pa = floatsub(Pa, 360.0);
SetActorFacingAngle(actorid, Pa);
}
My variables are:
Код:
"PlayerInfo[playerid][pPet]" "PlayerInfo[playerid][pPetStatus]" "PlayerInfo[playerid][pPetText]" "PlayerInfo[playerid][pPetName]"


