SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 17/09/2011, 06:35 AM   #1
MisterTickle
Huge Clucker
 
MisterTickle's Avatar
 
Join Date: Jul 2007
Posts: 364
Reputation: 75
Default How to get script that starts EXACTLY when an NPC's path starts

I have certain code that teleports a player to a vehicle thats driven by an NPC problem is I used OnPlayerSpawn.. checked if the name matched and it teleported me but it took like 3 seconds+ for it to actually do the recorded path... Is there a specific callback I can use it get it exactly right cause it needs to be in sync with some times I have setup or certain things will happen either early/late
__________________
MisterTickle is offline   Reply With Quote
Old 17/09/2011, 07:44 AM   #2
=WoR=Varth
High-roller
 
=WoR=Varth's Avatar
 
Join Date: Apr 2011
Location: Indonesia
Posts: 2,000
Reputation: 133
Default Re: How to get script that starts EXACTLY when an NPC's path starts

OnPlayerConnect?
__________________
(RETIRED)
=WoR=Varth is offline   Reply With Quote
Old 17/09/2011, 08:30 PM   #3
MisterTickle
Huge Clucker
 
MisterTickle's Avatar
 
Join Date: Jul 2007
Posts: 364
Reputation: 75
Default Re: How to get script that starts EXACTLY when an NPC's path starts

Obviously not. OnPlayerSpawn is called after OnPlayerConnect.. and thats not good enough.
__________________
MisterTickle is offline   Reply With Quote
Old 17/09/2011, 08:33 PM   #4
=WoR=Varth
High-roller
 
=WoR=Varth's Avatar
 
Join Date: Apr 2011
Location: Indonesia
Posts: 2,000
Reputation: 133
Default Re: How to get script that starts EXACTLY when an NPC's path starts

Quote:
Originally Posted by MisterTickle View Post
Obviously not. OnPlayerSpawn is called after OnPlayerConnect.. and thats not good enough.
But is that what you want?

Quote:
but it took like 3 seconds+ for it to actually do the recorded path
__________________
(RETIRED)
=WoR=Varth is offline   Reply With Quote
Old 17/09/2011, 08:51 PM   #5
DRIFT_HUNTER
High-roller
 
Join Date: Oct 2009
Posts: 2,088
Reputation: 188
Default Re: How to get script that starts EXACTLY when an NPC's path starts

Make a custom callback that will start it and do what you need?
__________________
Looking for someone to start drifting server, drop me a pm if you are interested.


Any PM's that include question about any kind of help will be ignored.
Use appropriate boards for that
DRIFT_HUNTER is offline   Reply With Quote
Old 17/09/2011, 11:35 PM   #6
MisterTickle
Huge Clucker
 
MisterTickle's Avatar
 
Join Date: Jul 2007
Posts: 364
Reputation: 75
Default Re: How to get script that starts EXACTLY when an NPC's path starts

Quote:
Originally Posted by DRIFT_HUNTER View Post
Make a custom callback that will start it and do what you need?
Lol.. I don't even know what to say. Maybe I'm not explaining it right. I need somehow to get a

OnNPCStartPath(npcid)

so that I can sync things up EXACTLY when the path starts not when an NPC connects or spawns (as it takes time) I could do a timer but.. thats not really reliable and exact.
__________________
MisterTickle is offline   Reply With Quote
Old 17/09/2011, 11:38 PM   #7
=WoR=Varth
High-roller
 
=WoR=Varth's Avatar
 
Join Date: Apr 2011
Location: Indonesia
Posts: 2,000
Reputation: 133
Default Re: How to get script that starts EXACTLY when an NPC's path starts

StartRecordingPlayback?
__________________
(RETIRED)
=WoR=Varth is offline   Reply With Quote
Old 17/09/2011, 11:40 PM   #8
RelaxCafe
Big Clucker
 
RelaxCafe's Avatar
 
Join Date: Jun 2011
Posts: 88
Reputation: 8
Default Re: How to get script that starts EXACTLY when an NPC's path starts

I know what you mean mate. Now.. I do not know if there is a function to get the npc's state. Well, what you can do is restart the npc everytime.. Like : OnPlayerSpawn(..){SpawnPlayer(npcid);PutPlayerInVe hicle(playerid,2,2);}
Try that.. Now get the vehicle id the npc is driving. And place it on the first number 2. Plus the the id of the driver(npc).
I hope this worked for you mate..
__________________




First Time Public; Current Stage: Beta testing.

RelaxCafe is offline   Reply With Quote
Old 18/09/2011, 01:38 AM   #9
MisterTickle
Huge Clucker
 
MisterTickle's Avatar
 
Join Date: Jul 2007
Posts: 364
Reputation: 75
Default Re: How to get script that starts EXACTLY when an NPC's path starts

Quote:
Originally Posted by =WoR=Varth View Post
StartRecordingPlayback?
Yeah but doesn't have have to called in the scriptfile in npcmodes I cant call it directly from the gamemode? It doesn't come with a specific ID so I can't use it in the main gamemode (or I'm missing something here)


Quote:
Originally Posted by RelaxCafe View Post
I know what you mean mate. Now.. I do not know if there is a function to get the npc's state. Well, what you can do is restart the npc everytime.. Like : OnPlayerSpawn(..){SpawnPlayer(npcid);PutPlayerInVe hicle(playerid,2,2);}
Try that.. Now get the vehicle id the npc is driving. And place it on the first number 2. Plus the the id of the driver(npc).
I hope this worked for you mate..

I'm not sure what you mean man.. I have it put the NPC/Player in the vehicle when the NPC spawns.. but it takes some time to start the recording and im trying to find a way without using a timer as it won't be 100%
__________________
MisterTickle is offline   Reply With Quote
Old 18/09/2011, 02:51 AM   #10
andrew4699
Little Clucker
 
Join Date: Jul 2010
Posts: 36
Reputation: 1
Default Re: How to get script that starts EXACTLY when an NPC's path starts

Use a PVar and set it in your filterscript right after the NPC recording starts and have a timer in your gamemode where it checks if the PVar is a certain value and if it is, it calls a custom callback called OnNPCStartPath and have that loop through all the players with strcmp and see if the name matches with a NPC name you put in.
andrew4699 is offline   Reply With Quote
Reply

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
When 0.3 starts, i had problems with my script. [FBI]Gstar Help Archive 2 18/11/2009 08:58 PM
single player starts from sa-mp killaA Client Support 2 15/11/2009 02:27 PM
SA:MP suddenly starts SP Bertje Client Support 7 21/09/2009 07:29 PM


All times are GMT. The time now is 04:22 PM.


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