SA-MP Forums Archive
How to get script that starts EXACTLY when an NPC's path starts - 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: How to get script that starts EXACTLY when an NPC's path starts (/showthread.php?tid=283881)



How to get script that starts EXACTLY when an NPC's path starts - MisterTickle - 17.09.2011

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


Re: How to get script that starts EXACTLY when an NPC's path starts - =WoR=Varth - 17.09.2011

OnPlayerConnect?


Re: How to get script that starts EXACTLY when an NPC's path starts - MisterTickle - 17.09.2011

Obviously not. OnPlayerSpawn is called after OnPlayerConnect.. and thats not good enough.


Re: How to get script that starts EXACTLY when an NPC's path starts - =WoR=Varth - 17.09.2011

Quote:
Originally Posted by MisterTickle
Посмотреть сообщение
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




Re: How to get script that starts EXACTLY when an NPC's path starts - DRIFT_HUNTER - 17.09.2011

Make a custom callback that will start it and do what you need?


Re: How to get script that starts EXACTLY when an NPC's path starts - MisterTickle - 17.09.2011

Quote:
Originally Posted by DRIFT_HUNTER
Посмотреть сообщение
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.


Re: How to get script that starts EXACTLY when an NPC's path starts - =WoR=Varth - 17.09.2011

StartRecordingPlayback?


Re: How to get script that starts EXACTLY when an NPC's path starts - RelaxCafe - 17.09.2011

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


Re: How to get script that starts EXACTLY when an NPC's path starts - MisterTickle - 18.09.2011

Quote:
Originally Posted by =WoR=Varth
Посмотреть сообщение
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
Посмотреть сообщение
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%


Re: How to get script that starts EXACTLY when an NPC's path starts - andrew4699 - 18.09.2011

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.