SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 09/11/2009, 05:32 PM   #11
niCe
Gangsta
 
niCe's Avatar
 
Join Date: Mar 2008
Posts: 520
Reputation: 94
Default Re: Getting a NPC to follow me

You have to use a repeating timer, where you move NPC by setting the position.
__________________
s2.gta-multiplayer.cz:7777 Freeroam + Singleplayer Features
s3.gta-multiplayer.cz:7777 NEW Server! Freeroam + Singleplayer Features 2
- Many features from singleplayer
- Pool and basketball minigames
- Video game QUB3D from GTA 4
- Custom made roulettes, slot machines, video poker and horse-betting
- Stock market BAWSAQ from GTA 5
- Gang wars over 60 territories
- More than 30 unique sub-missions to earn money (including vigilante, paramedic, firefighter, pimping, valet parking and pizza-boy sub-missions)
- Burglary missions
- Singleplayers races and other challenges
- Gyms, strip clubs, clothes shops, hidden packages, oysters, spray tags, horseshoes and much more
niCe is offline  
Old 09/11/2009, 05:34 PM   #12
shady91
High-roller
 
shady91's Avatar
 
Join Date: Nov 2008
Location: Uk
Posts: 1,783
Reputation: 5
Default Re: Getting a NPC to follow me

Quote:
Originally Posted by niCe
You have to use a timer, where you move NPC by setting the position.
that what i did i just made it read the players position then make the bot walk animation then making the bot teleport a little bit behind the player it doesn't look to good tho.
__________________


Want to be apart of Need For Speed Carbon Multi Player, you can join us at


Want something in PHP/HTML/PAWN coded pm me.
shady91 is offline  
Old 09/11/2009, 05:40 PM   #13
niCe
Gangsta
 
niCe's Avatar
 
Join Date: Mar 2008
Posts: 520
Reputation: 94
Default Re: Getting a NPC to follow me

I meant, the repeating timer, where you get X, Y in front of NPC and set the position to these coordinates. I would also recommend switching the parameter causing player freeze when anitmation is finished to 0 - so the parameters would be 4.1,1,1,1,0,0. No need to reapply the animation then, just ClearAnimations when you want to make NPC stop.
__________________
s2.gta-multiplayer.cz:7777 Freeroam + Singleplayer Features
s3.gta-multiplayer.cz:7777 NEW Server! Freeroam + Singleplayer Features 2
- Many features from singleplayer
- Pool and basketball minigames
- Video game QUB3D from GTA 4
- Custom made roulettes, slot machines, video poker and horse-betting
- Stock market BAWSAQ from GTA 5
- Gang wars over 60 territories
- More than 30 unique sub-missions to earn money (including vigilante, paramedic, firefighter, pimping, valet parking and pizza-boy sub-missions)
- Burglary missions
- Singleplayers races and other challenges
- Gyms, strip clubs, clothes shops, hidden packages, oysters, spray tags, horseshoes and much more
niCe is offline  
Old 09/11/2009, 05:47 PM   #14
shady91
High-roller
 
shady91's Avatar
 
Join Date: Nov 2008
Location: Uk
Posts: 1,783
Reputation: 5
Default Re: Getting a NPC to follow me

Quote:
Originally Posted by niCe
I meant, the repeating timer, where you get X, Y in front of NPC and set the position to these coordinates. I would also recommend switching the parameter causing player freeze when anitmation is finished to 0 - so the parameters would be 4.1,1,1,1,0,0. No need to reapply the animation then, just ClearAnimations when you want to make NPC stop.
it still would look as bad.
__________________


Want to be apart of Need For Speed Carbon Multi Player, you can join us at


Want something in PHP/HTML/PAWN coded pm me.
shady91 is offline  
Old 09/11/2009, 06:00 PM   #15
niCe
Gangsta
 
niCe's Avatar
 
Join Date: Mar 2008
Posts: 520
Reputation: 94
Default Re: Getting a NPC to follow me

I disagree, I use it exactly as I wrote, and it looks completely smooth.
__________________
s2.gta-multiplayer.cz:7777 Freeroam + Singleplayer Features
s3.gta-multiplayer.cz:7777 NEW Server! Freeroam + Singleplayer Features 2
- Many features from singleplayer
- Pool and basketball minigames
- Video game QUB3D from GTA 4
- Custom made roulettes, slot machines, video poker and horse-betting
- Stock market BAWSAQ from GTA 5
- Gang wars over 60 territories
- More than 30 unique sub-missions to earn money (including vigilante, paramedic, firefighter, pimping, valet parking and pizza-boy sub-missions)
- Burglary missions
- Singleplayers races and other challenges
- Gyms, strip clubs, clothes shops, hidden packages, oysters, spray tags, horseshoes and much more
niCe is offline  
Old 09/11/2009, 06:00 PM   #16
Joe Staff
High-roller
 
Joe Staff's Avatar
 
Join Date: Aug 2007
Posts: 2,789
Reputation: 330
Default Re: Getting a NPC to follow me

I could get an NPC to follow the closest player, but I would need a plugin.

Some time ago I did some research on how the NPC recordings were made, and using a simple program I learned the exact format that was used to create walking NPCs, so I could actually create a customized recording with pawn alone. I stopped the research due to me not caring anymore, but to create what you want, you'd have to create a function that creates a new recording that starts from the NPCs current position, and ends at the position of where you want it to be (so it would actually be a very small recording if you got the timer correct, requires more math) and then have the npcmode run the new recording. Using a file manager (there's one in the plugins board someplace) you would then move the created recording into the recordings folder and then your NPC would go from its current position, to the new one. You wouldn't have to use a timer, you could just use OnRecordingEnd(or whatever) and then run the function that creates new recordings and run that recording. So a constant loop of creating and executing recordings. It's more simple than it looks.
__________________
I hate your face.
Joe Staff is offline  
Old 09/11/2009, 08:23 PM   #17
miokie
High-roller
 
miokie's Avatar
 
Join Date: Jan 2007
Location: Bedfordshire, England
Posts: 1,417
Reputation: 12
Default Re: Getting a NPC to follow me

Created It By Using GetXYInfrontOfPlayer and a timer using SetPlayerFacePlayer, Then Using an animation etc...

I've got it working But just need to make it look more cleaner.
__________________
miokie is offline  
Old 20/11/2009, 09:53 PM   #18
[HLF]Southclaw
High-roller
 
[HLF]Southclaw's Avatar
 
Join Date: Apr 2009
Location: England
Posts: 4,204
Reputation: 759
Default Re: Getting a NPC to follow me

I tried this and the ideal distance to use for GetXY etc... is about 3.0 [2.8 - 3.2] thats about the best i can get it with a running, walking anims are about 1-2 its not the best but its about as close as its gona get

i use a timer with SetPlayerFacePlayer and the run or walk anim, i got the right distance in game by making a command that changes the distance so i got it right

it looks like really laggy player if it is too low or high but if its right it just jumps a bit and one thing i got to fix is when i go down a slope the npc is still running in mid air lol so il just set it to go at the players hieght

hope this helps with npc anims etc
[HLF]Southclaw is offline  
Old 01/05/2010, 09:13 AM   #19
[LF]Mr.Lucci
Big Clucker
 
Join Date: Nov 2006
Posts: 86
Reputation: 0
Default Re: Getting a NPC to follow me

I'm trying to do this exact same thing right now, could someone post the missing code for timers and GetXYInfrontOfPlayer so that I could actually use this? Please and thanks in advance!!!

Code:
public GetCandyToFollow(playerid)
{
new npcid = GetPlayerID("Candy");
new Float:ax,Float:ay,Float:az,Float:dif;
new Float:x,Float:y,Float:z;
GetPlayerPos(playerid,x,y,z);
GetPlayerPos(npcid,ax,ay,az);

if( az <= (z+3.0) && az >= (z-3.0)){
ApplyAnimation(npcid,"PED","WALK_PLAYER",4.1,1,1,0,0,0);
	}

dif = az;
SetPlayerPos(npcid,x,y,dif);
SetPlayerFacingPlayer(npcid, playerid);
Update- Been working on it more the NPC follows me, and I agree it looks a little choppy but I could care less. My problem is the NPC is RIGHT on my ass, and disapears entirely when it gets close enough to me. What I want it to do is follow me and stop animation when im not moving. I also notice the height never changes so the NPC is walking underground when I go up or down hills... Any help?
__________________
[LF]Mr.Lucci is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[HELP]Making a NPC follow a Player! Epic Shower Help Archive 1 04/04/2010 03:33 PM
Making NPC follow me? Hot Help Archive 4 02/03/2010 10:40 PM
I need the camera to follow a certan player Nickg Help Archive 1 21/02/2010 05:20 PM
How do i make a bot Attack/Follow? Epic Shower Help Archive 4 08/02/2010 11:32 PM
Forced to follow. Chrham_2 Help Archive 2 25/07/2009 11:37 PM


All times are GMT. The time now is 12:29 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.