Actor walking. (Pet system)
#1

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.

Код:
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);
}
I found these codes in a Turkish pawn forum.
My variables are:

Код:
"PlayerInfo[playerid][pPet]"
"PlayerInfo[playerid][pPetStatus]"
"PlayerInfo[playerid][pPetText]"
"PlayerInfo[playerid][pPetName]"
If I can make this pet system, I will share it.
Reply
#2

Actors aren't made to walk. They are static.
The only things you do right here is moving actor's position which looks like a movement but isn't that good as a NPC can possibility do.
Take a look at this plugin: https://sampforum.blast.hk/showthread.php?tid=428066
Reply
#3

I tried FCNPC but some commands didn't work. (FCNPC_Create, FCNPC_Spawn etc.)
Reply
#4

Post the logs,actor isn't created to walk.
Reply
#5

Код:
Error: NPC 'TestNPC' not created. Name 'TestNPC' is invalid or the maxnpc limit in server.cfg has been reached.
Reply
#6

Quote:
Originally Posted by darkwing
Посмотреть сообщение
Код:
Error: NPC 'TestNPC' not created. Name 'TestNPC' is invalid or the maxnpc limit in server.cfg has been reached.
Did you increase, at least more than one, maxnpc limit in your server.cfg?
Reply
#7

Yes, i increase it.
Reply
#8

What can I do?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)