SA-MP Forums Archive
Actor walking. (Pet system) - 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 walking. (Pet system) (/showthread.php?tid=655831)



Actor walking. (Pet system) - darkwing - 30.06.2018

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.



Re: Actor walking. (Pet system) - Dayrion - 30.06.2018

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


Re: Actor walking. (Pet system) - darkwing - 30.06.2018

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



Re: Actor walking. (Pet system) - Verc - 30.06.2018

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


Re: Actor walking. (Pet system) - darkwing - 30.06.2018

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



Re: Actor walking. (Pet system) - Dayrion - 30.06.2018

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?


Re: Actor walking. (Pet system) - darkwing - 30.06.2018

Yes, i increase it.



Re: Actor walking. (Pet system) - darkwing - 02.07.2018

What can I do?