NPC Refuses To Hide In Closet, Loves Driving!
#1

I found myself playing with the NPC features for the first time today. The tutorial by kc was most highly of assistance, I was able to get a bot driving across the server. It was rather strange at first, but amazingly cool & inspirational. A haze of new ideas flooding to my mind. But, I wish to expand on what the tutorial instructed. I found it worked great to get my bot driving around the server, but I'd like to hide him away in a closet until he's requested by means of a command.

So I check whether the player is a NPC during OnPlayerSpawn. It realizes it is & adds the rather eye pleasing 3D text, thus confirming it's recognized the check. During that same check though, it chooses to ignore SetPlayerPos. It just appears at so far, the same place everytime. Not the custom random spawns I'd set for him (to hide in the closet).

Why is this?

I tried changing the NPC playback record to 2 (on foot) instead. It still ignored it, plus surely playback doesn't need to start for the bot to be able to function basic things such as SetPlayerPos? My bot is refusing to hide into the closet. Just stands in the wrong place, unless I put him in his vehicle so he can go for a drive.

Could someone please show me where I'm going wrong? I find myself rather confused. Many kind regards.

Edit:
Quote:
Originally Posted by SA-MP Wiki
They use their own compiled scripts for this task, which have to stay inside the npcmodes directory. That is, if you want to have 20 different NPCs doing different things, you will most likely have to have 20 pawn compiled scripts inside the npcmodes directory. This doesn't mean that you can't use the normal player functions applied to your NPCs (like SetPlayerPos, for example) from inside a gamemode or filterscript.
Reply
#2

Anyone?
Reply
#3

Are you using any login scripts? have you tried taking it out? I'm new to the whole NPC thing so i'm not too sure. I know my login screen stops gl_npc's from doing the required things.
Reply
#4

I believe that you should you use SetMyPos(X,Y,Z); instead of SetPlayerPos
here:
https://sampwiki.blast.hk/wiki/Category:NPC
Reply
#5

Once it starts playing the recording, it will continue uninterrupted unless you use the function to stop it.
Reply
#6

Quote:
Originally Posted by DobbysGamertag
Посмотреть сообщение
Are you using any login scripts? have you tried taking it out? I'm new to the whole NPC thing so i'm not too sure. I know my login screen stops gl_npc's from doing the required things.
No login script.

Quote:
Originally Posted by Joshman543
Посмотреть сообщение
I believe that you should you use SetMyPos(X,Y,Z); instead of SetPlayerPos
here:
https://sampwiki.blast.hk/wiki/Category:NPC
SetMyPos is only for NPC scripts & SetPlayerPos should work in the gamemode (according to the Wiki). Hence my confusion.

Quote:
Originally Posted by SuperViper
Посмотреть сообщение
Once it starts playing the recording, it will continue uninterrupted unless you use the function to stop it.
I'm trying to SetPlayerPos before the recording starts. The bot joins, but doesn't do anything until put in a vehicle (as I expected). At this point - I'm trying to SetPlayerPos. The recording is loaded etc but not working. As soon as he's put in his vehicle, he does as intended. But that space inbetween, is where I'm having the difficulty.


Thank you all for your suggestions!
Reply
#7

Have you tried SetSpawnInfo?
Reply
#8

Not in this script, it isn't used at all. Point is, according to the Wiki it should work. Hence my confusion for a solution.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)