SA-MP Forums

SA-MP Forums (https://forum.sa-mp.com/index.php)
-   Scripting Help (https://forum.sa-mp.com/forumdisplay.php?f=12)
-   -   How to get script that starts EXACTLY when an NPC's path starts (https://forum.sa-mp.com/showthread.php?t=283881)

MisterTickle 17/09/2011 06:35 AM

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

=WoR=Varth 17/09/2011 07:44 AM

Re: How to get script that starts EXACTLY when an NPC's path starts
 
OnPlayerConnect?

MisterTickle 17/09/2011 08:30 PM

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.

=WoR=Varth 17/09/2011 08:33 PM

Re: How to get script that starts EXACTLY when an NPC's path starts
 
Quote:

Originally Posted by MisterTickle (Post 1410344)
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

DRIFT_HUNTER 17/09/2011 08:51 PM

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?

MisterTickle 17/09/2011 11:35 PM

Re: How to get script that starts EXACTLY when an NPC's path starts
 
Quote:

Originally Posted by DRIFT_HUNTER (Post 1410382)
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.

=WoR=Varth 17/09/2011 11:38 PM

Re: How to get script that starts EXACTLY when an NPC's path starts
 
StartRecordingPlayback?

RelaxCafe 17/09/2011 11:40 PM

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..

MisterTickle 18/09/2011 01:38 AM

Re: How to get script that starts EXACTLY when an NPC's path starts
 
Quote:

Originally Posted by =WoR=Varth (Post 1410679)
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 (Post 1410685)
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%

andrew4699 18/09/2011 02:51 AM

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.


All times are GMT. The time now is 10:57 PM.

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