NPC Stop & Resume
#1

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.
Reply
#2

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);
Reply
#3

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.
Reply
#4

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.
Reply
#5

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

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 ?
Reply
#7

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
}
}
}
}
}
}
Reply
#8

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.
Reply
#9

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)