SA-MP Forums Archive
NPC Stop & Resume - 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: NPC Stop & Resume (/showthread.php?tid=381048)



NPC Stop & Resume - Black Wolf - 28.09.2012

Hello

I am using this code

pawn Код:
public OnPlayerText(playerid, text[])
{
    new Float:X, Float:Y, Float:Z;
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(IsPlayerNPC(i))
            {
                GetPlayerPos(i, X, Y, Z);
                    {
                if(IsPlayerInRangeOfPoint(playerid,2.0, X, Y, Z ))
    {
        if (strfind(text, "browse") != -1)
        {
                Here Goes the dialog
}
}
}
}
}
I want that if player comes in range of npc he gets stoppped and when he goes out of npc range he resume walking.

I see the functions for it but i am confused where to put and how to use it also i got 2 npc in my gamemode so i dont want other one to get stopped too.

NPC name is Killer. Which i want to get stopped when player is in range of him and resume if player is not in range of him.


Re: NPC Stop & Resume - XtremeR - 28.09.2012

pawn Код:
public OnPlayerText(playerid, text[])
{
    new Float:X, Float:Y, Float:Z;
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(IsPlayerNPC(i))
            {
                GetPlayerPos(i, X, Y, Z);
                    {
                if(IsPlayerInRangeOfPoint(playerid,2.0, X, Y, Z ))
    {
        if (strfind(text, "browse") != -1)
        {
TogglePlayerControllable(playerid,0);//this will freeze the player
                Here Goes the dialog
}
}
}
}
}
when u want to unfreeze the player use this:
pawn Код:
TogglePlayerControllable(playerid,1);



Re: NPC Stop & Resume - Snaz - 28.09.2012

An npc? Last time I saw an npc was in MTA. Some guy wanted to creep out people by making slenderman in the county/woods.


Re: NPC Stop & Resume - Black Wolf - 28.09.2012

Quote:
Originally Posted by XtremeR
Посмотреть сообщение
pawn Код:
public OnPlayerText(playerid, text[])
{
    new Float:X, Float:Y, Float:Z;
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(IsPlayerNPC(i))
            {
                GetPlayerPos(i, X, Y, Z);
                    {
                if(IsPlayerInRangeOfPoint(playerid,2.0, X, Y, Z ))
    {
        if (strfind(text, "browse") != -1)
        {
TogglePlayerControllable(playerid,0);//this will freeze the player
                Here Goes the dialog
}
}
}
}
}
when u want to unfreeze the player use this:
pawn Код:
TogglePlayerControllable(playerid,1);
I want to freeze the npc there is a function for it.


Re: NPC Stop & Resume - XtremeR - 28.09.2012

pawn Код:
if(IsPlayerConnected(i))
        {
            if(IsPlayerNPC(i))
            {
              TogglePlayerControllable(i,0);
}
}
this will freeze the NPC


Re: NPC Stop & Resume - Black Wolf - 28.09.2012

Quote:
Originally Posted by XtremeR
Посмотреть сообщение
pawn Код:
if(IsPlayerConnected(i))
        {
            if(IsPlayerNPC(i))
            {
              TogglePlayerControllable(i,0);
}
}
this will freeze the NPC
Can you please do it using the functions ?


Re: NPC Stop & Resume - XtremeR - 28.09.2012

pawn Код:
public OnPlayerText(playerid, text[])
{
    new Float:X, Float:Y, Float:Z;
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(IsPlayerNPC(i))
            {
                GetPlayerPos(i, X, Y, Z);
                    {
                if(IsPlayerInRangeOfPoint(playerid,2.0, X, Y, Z ))
    {
        if (strfind(text, "browse") != -1)
        {
if(IsPlayerNPC(i))
            {
              TogglePlayerControllable(i,0);
                Here Goes the dialog
}
}
}
}
}
}



Re: NPC Stop & Resume - Black Wolf - 28.09.2012

I am talking about these functions
https://sampwiki.blast.hk/wiki/NPC:PauseRecordingPlayback
https://sampwiki.blast.hk/wiki/NPC:ResumeRecordingPlayback

Please these functions and make only Killer NPC to stop and resume i dont want my other npc to get affected.


Re: NPC Stop & Resume - XtremeR - 28.09.2012

to stop use:
PauseRecordingPlayback();

to continue use:
ResumeRecordingPlayback();


pausing a singple NPC

pawn Код:
if(IsPlayerNpc(playerid))
    {
        new pName[MAX_PLAYER_NAME];
        GetPlayerName(playerid, pName, sizeof(pName));
        if(strcmp(pName, "Killer") == 0)
        {
         ResumeRecordingPlayback();
            return 0;
        }
    }
i hope that helps