PDA

View Full Version : Issue With Actors


Jay_Dixon
25/06/2018, 05:46 PM
Ok so I've finally got the Actors down. Atleast more than alot of the confusion I see going on with them. I got it to spawn at first, and so on. But now when I try to fix it's spawn location (unless I log in infront of it, it spawns in the middle of the alley), it doesn't even appear anymore, at all. Is there something I'm missing here?


forward IsPlayerInRangeOfActor(playerid);
public IsPlayerInRangeOfActor(playerid)//This Works
{
if(IsPlayerInRangeOfPoint(playerid, 1.5, 2397.78, -1468.79, 24.00))
{
SendClientMessage(playerid, COLOR_RED, "Success!");
return 1;
}
return 1;
}

forward SpawnActor();
public SpawnActor()//This worked originally
{
myActor = CreateActor(120, 2397.78, -1468.79, 24.00, 182.42);
//ApplyActorAnimation(myActor,"GANGS","leanIDLE",4.1,1,0,0,0,0);
return 1;
}

public OnActorStreamIn(actorid, forplayerid)//I added more here to try and fix the issue with the Actor, now it won't even appear
{
SpawnActor();//I figured I'd try to force spawn it, yeah that definitely didn't pan out well
SetActorPos(myActor, 2397.78, -1468.79, 24.00);
SetActorFacingAngle(myActor,182.42);
SetActorVirtualWorld(myActor, 0);
SetActorInvulnerable(myActor, true);
ApplyActorAnimation(myActor,"GANGS","leanIDLE",4.1,1,0,0,0,0);//Hopefully this fixes the bug with the actors
return 1;
}

JasonRiggs
25/06/2018, 06:30 PM
What are you trying to do?

Jay_Dixon
25/06/2018, 06:33 PM
I'm trying to get the Actor to actually spawn and be leaned up against the wall where he should be. If I can get that done, I'm gonna do that to the rest so the Actor's can replace the NPC's that are doing the same function (basically just standing there and look pretty). However, at first the actor would spawn. But when I drove to him, he'd be in the middle of the alley leaning up against nothing, instead of against the wall where he should be. If I logged on infront of him, he was leaned up against the wall like he should be. So I figured forcing it into that in OnActorStreamIn would fix it, turns out, it makes it so he won't even spawn anymore or whatever.

JasonRiggs
25/06/2018, 06:40 PM
I guess that all what you need to do is the following..

On top of script
new actor;

Under on gamemodeinit

actor = CreateActor(model, x, y, z, rotation);
SetActorInvulnerable(actor, 1);
ApplyActorAnimation(actor, animlib, animname, speed, loop, and the rest of the format);

And then check OnPlayerGiveDamageToActor, and set the actor's position to the original place, easy..

Jay_Dixon
25/06/2018, 06:42 PM
When I did it that way though it spawned him right in the middle of the alley once I drove to him. Unless I logged in right where he was, then he spawned in the right place.

JasonRiggs
25/06/2018, 06:56 PM
When I did it that way though it spawned him right in the middle of the alley once I drove to him. Unless I logged in right where he was, then he spawned in the right place.

Then you didn't do the OnPlayerGiveDamageActor thingy, and if it didn't work, create a timer that checks every 1 sec if the actor's pos isn't the original one then set his pos to the original

Jay_Dixon
25/06/2018, 07:00 PM
This might give a better idea of what I'm trying to do with them. They're gonna replace the NPC's if I can get atleast 2 working correctly.

https://www.youtube.com/watch?v=wNqBAn0MoQY

JasonRiggs
25/06/2018, 07:13 PM
He created an actor and applied animation to them, that's all, YOUR PROBLEM is that when you move the actor from his position by a car for example, he doesn't TP back, You can easily avoid it with this..

forward a timer function somewhere in your script forward actorcheck();
When you create the actor set a time with him SetTimer(actorcheck, 1000, true);

and the response..

public actorcheck()
{
new Float:X, Float:Y, Float:Z;
GetActorPos(actor, X, Y, Z);
if(X != your original X here || Y != your original Y here || Z != your original Z here)
{
SetActorPos(actor, your x, y, z);
ApplyActorAnimation(bla, bla, bla);
}
}


That's it.

Jay_Dixon
25/06/2018, 07:35 PM
Actually the video wasn't Actors, those were the NPC's that I made a long time ago before I left that I'm now trying to replace. I'll give the actor check thing a try though, thanks :D

If that don't work looks like I'm buying a server that can accomidate 250+ NPC's xD

Dayrion
25/06/2018, 09:01 PM
I don't fully understand what you are trying to achieve because of my english, sorry.
So that you want:
- When a player enters in an interior, it create an actor or, at least, there is an actor standing there
- It apply an animation to the actor and a message appear at the front of the actor, when you are pressing a key or what ever it intereact in any way with actor

Jay_Dixon
26/06/2018, 01:33 AM
I don't fully understand what you are trying to achieve because of my english, sorry.
So that you want:
- When a player enters in an interior, it create an actor or, at least, there is an actor standing there
- It apply an animation to the actor and a message appear at the front of the actor, when you are pressing a key or what ever it intereact in any way with actor



Yup. Iím trying to place some all around the city too. Like say you want to go to East LS to buy some weed. Thatís what the actor would be for essentially.

JasonRiggs
26/06/2018, 07:41 AM
Yup. Iím trying to place some all around the city too. Like say you want to go to East LS to buy some weed. Thatís what the actor would be for essentially.

SIMPLY CreateActor or CreateDynamicActor under ONGAMEMODEINIT and to apply the animation you can also SIMPLY ApplyActorAnimation and you can find its syntax and details here (http://wiki.sa-mp.com/wiki/ApplyActorAnimation), What's hard??

Jay_Dixon
26/06/2018, 03:33 PM
I tried with the timer's you recommended as well. Still didn't work :c

I made a video of my issue though, the beginning shows where he's supposed to be, the end shows what happens instead when i'm not near him. Ignore the video name, I haven't changed the stream title in months

https://www.twitch.tv/videos/277823138##

Dayrion
26/06/2018, 04:40 PM
Is it a custom mapping or the basic one?

Jay_Dixon
26/06/2018, 04:53 PM
Is it a custom mapping or the basic one?

Nope, that alleyway there is the one that's in the base game

Dayrion
26/06/2018, 04:57 PM
Nope, that alleyway there is the one that's in the base game

Okei, I wasn't sure. I don't play on LS.
It seems your actor spawn after the mapping. Did you try with dynamic actor?

JasonRiggs
26/06/2018, 04:57 PM
Are you sure that nothing else is created in the same position of the actor?

If you are sure, then do a timer that sets the actor's position to the original one every 2 seconds or something..

Jay_Dixon
27/06/2018, 08:37 PM
Are you sure that nothing else is created in the same position of the actor?

If you are sure, then do a timer that sets the actor's position to the original one every 2 seconds or something..

Thanks for pointing out the small thing I overlooked about how to actually get them to work correctly. Timer's work miracles, I gave you +rep :D