How to stop all NPCs with a command?
#1

Hello there,
I'm kinda frustrated of this situation here,several hours ago,I decided to use
a command to stop all NPCs ,and to start them all with another command,so that
their movements can be completely synchornized.I don't know if it was possible,and i made
something like this:
The code is a little bit dirty,sorry about that.The main idea is to create an .inc which defines the variables.Then include this inc into the gamemode for creating the start/stop command and into the npcmode script for recieving such commands.
Код:
 syncer.inc
#include <a_samp>
#include <a_npc>

#define color 0xFFFF22AA
new fsync_stop = 0;
new fsync_start = 0;
new sync_stop = 0;
new sync_start = 0;
Код:
 Gamemode
#include <a_samp>
#include <syncer>

forward checkifsync();

public OnGameModeInit()
{
SetTimer("checkifsync",1000,1);
}
public checkifsync(){
	if (fsync_stop == 1) {
        sync_start = 0;
	sync_stop = 1;
	fsync_stop = 0;
	fsync_start = 0;
      SendClientMessageToAll(color,"All NPCS are frozen and to be synchronized.Enter /fstart to restart the NPC movements.");
	}

	if (fsync_start == 1) {
	sync_start = 1;
	sync_stop = 0;
	fsync_stop = 0;
	fsync_start = 0;
      SendClientMessageToAll(color,"All NPCS are now restored.Enter /fstop again to freeze all NPCs.");
	}
}
       public OnPlayerCommandText()
     {
             if(strcmp(cmd, "/fstart", true) == 0) {
	fsync_start = 1;
	return 1;
	}
	if(strcmp(cmd, "/fstop", true) == 0) {
	fsync_stop = 1;
	return 1;
	}
}
Код:
 NPCmode Script
   public OnPlayerStreamIn(){
   if(sync_start == 1){
   StartRecordingPlayback(RECORDING_TYPE, RECORDING);
   }
   if(sync_stop == 1){
   StopRecordingPlayback();
   }
}
The main question is I don't know where to put the StartRecordingPlayback or StopRecordingPlayback.I am pretty sure it shouldn't belong to OnPlayerStreamIn.

The result is all NPCs keep moving and did not stop after entering /fstop.

Anyone can help ? plz ? thx !
T
Reply
#2

just make a command saying stop then for new max players(loop) and isplayernpc toggleplayercontorlable(i,0);
Reply
#3

PauseRecordingPlayback();

ResumeRecodingPlayback();
Reply
#4

Quote:
Originally Posted by Kar
Посмотреть сообщение
just make a command saying stop then for new max players(loop) and isplayernpc toggleplayercontorlable(i,0);
Код:
TogglePlayerControllable(playerid,toggle);
doesn't work on NPCs' for your information Kar.
Reply
#5

oh.. didnt know that thx gonna go read wiki more
Reply
#6

Bumped.
One thing i would like to add is the NPCs has a recording and they are moving referring to that recording.
Quote:

@Conroy:
PauseRecordingPlayback();

ResumeRecodingPlayback();

Well,I tried that with my codes and it didn't work.
In fact,i would like to make them restart their recording playback instead of pause the recording playback..

I put the whole timer into the NPC script and the timer just won't work.Apperantely i put those codes in the wrong
callback..Which callback i have to use
Reply
#7

Quote:
Originally Posted by Talisman010
Посмотреть сообщение
Bumped.
One thing i would like to add is the NPCs has a recording and they are moving referring to that recording.

Well,I tried that with my codes and it didn't work.
In fact,i would like to make them restart their recording playback instead of pause the recording playback..

I put the whole timer into the NPC script and the timer just won't work.Apperantely i put those codes in the wrong
callback..Which callback i have to use
This sounds a bit impossible to me...then again, it sounds a little possible...
ResumeRecordingPlayback and StopRecordingPlayback are only to be used in the npcmode; They're useless in other modes other than the npcmode using the specified recording. An idea i had was to save the fact that they're playing back to a file from the npcmodes of the npcs you want to control, then use your gamemode/filterscript to change this file value so that when the npcmode scans the file for "stopping" credentials, it will stop. This however takes work and I would make one for you right now, but it's well past my bedtime xDD
Reply
#8

Quote:
Originally Posted by mastasquizy
Посмотреть сообщение
This sounds a bit impossible to me...then again, it sounds a little possible...
ResumeRecordingPlayback and StopRecordingPlayback are only to be used in the npcmode; They're useless in other modes other than the npcmode using the specified recording. An idea i had was to save the fact that they're playing back to a file from the npcmodes of the npcs you want to control, then use your gamemode/filterscript to change this file value so that when the npcmode scans the file for "stopping" credentials, it will stop. This however takes work and I would make one for you right now, but it's well past my bedtime xDD
I don't really get it...u mean to change the recording file or something

In fact i would like to edit the recording if I can,since i am creating a NPC parade (seen in my last question asking how to change position of the NPCs),with that I only need to copy and edit the recording file.

Anyway,thanks.

T
Reply
#9

Quote:
Originally Posted by Talisman010
Посмотреть сообщение
I don't really get it...u mean to change the recording file or something

In fact i would like to edit the recording if I can,since i am creating a NPC parade (seen in my last question asking how to change position of the NPCs),with that I only need to copy and edit the recording file.

Anyway,thanks.

T
Sorry, sometimes I forget I'm working with new scripters (no offense)
You cannot edit existing npc recordings, you can only make new recordings and use those instead. A parade? You would need to record every individual npc's path(read the tut to find out how to record)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)