SA-MP Forums Archive
[Include] Simple AI Police Officer NPC using RNPC - 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: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+---- Forum: Includes (https://sampforum.blast.hk/forumdisplay.php?fid=83)
+---- Thread: [Include] Simple AI Police Officer NPC using RNPC (/showthread.php?tid=358655)

Pages: 1 2


Re: Simple AI Police Officer NPC using RNPC - TheArcher - 15.07.2012

@qq757679895

Put the example that Mauzen done

pawn Code:
new rp = CreateRNPCPolice("Officerino", 280);
AddRPOLWaypoint(rp, 2029.42, 1354.34, 10.5);
AddRPOLWaypoint(rp, 2033.55, 1286.21, 10.5);
AddRPOLWaypoint(rp, 2079.03, 1286.00, 10.5);
AddRPOLWaypoint(rp, 2079.02, 1362.08, 10.5);
StartRPOLRoute(rp);



Re: Simple AI Police Officer NPC using RNPC - qq757679895 - 15.07.2012

Why the police can not move.


Respuesta: Simple AI Police Officer NPC using RNPC - Marricio - 15.07.2012

Woah, awesome.


Re: Simple AI Police Officer NPC using RNPC - Igi_Guduric - 15.07.2012

Nice Include.


Re: Respuesta: Simple AI Police Officer NPC using RNPC - ds811888 - 15.07.2012

Quote:
Originally Posted by [FeK]DraKiNs
View Post
Good working Mauzen !!
I am creating a system of zombies, advise the use of RNPC !!

Kill NPC
pawn Code:
// top of gm
new tirosLevados[MAX_PLAYERS];

// onplayer update
static targetplayer,  Keys,ud,lr;
GetPlayerKeys(playerid,Keys,ud,lr);
targetplayer = GetPlayerTargetPlayer(playerid);

if(targetplayer != INVALID_PLAYER_ID && Keys == KEY_FIRE || Keys == 132)
{
    if(IsPlayerNPC(targetplayer)) {
        tirosLevados[targetplayer]++;
        SetPVarInt(playerid, "timesTick", GetTickCount());
        if(tirosLevados[targetplayer] > 20) { // 20 shoots +-
            SpawnPlayer(targetplayer);
            OnPlayerDeath(targetplayer, playerid, GetPlayerWeapon(playerid));
            tirosLevados[targetplayer] = 0;
          }
    }
}


Follow
pawn Code:
CHK_RowMoviment(n, moviment) {

    if(moviment > rowNPCMove[n]) {
        return false;
    }
   
    static
        rowSTR[3][32];

    format(rowSTR[0], 32, "rowNPC%dX", moviment);
    format(rowSTR[1], 32, "rowNPC%dY", moviment);
    format(rowSTR[2], 32, "rowNPC%dZ", moviment);

    return IsPlayerInRangeOfPoint(n, 1.5, GetPVarFloat(n, rowSTR[0]),GetPVarFloat(n, rowSTR[1]),GetPVarFloat(n, rowSTR[2]));
}

EXE_RowMoviment(n) {

    if(!rowNPCMove[n] || execROWMoviment[n] > (rowNPCMove[n] - 1))  {
        return false;
    }

    if(execROWMoviment[n]) {
        if(!CHK_RowMoviment(n, execROWMoviment[n]-1)) {
            return false;
        }
    }

   
    static
        rowSTR[4][32];


    if(execROWMoviment[n] > 1) {
        for(new i = execROWMoviment[n]-1; i > -1; i--) {
            format(rowSTR[0], 32, "rowNPC%dX", i);
            format(rowSTR[1], 32, "rowNPC%dY", i);
            format(rowSTR[2], 32, "rowNPC%dZ", i);
            format(rowSTR[3], 32, "rowNPC%dS", i);

            DeletePVar(n,rowSTR[0]);
            DeletePVar(n,rowSTR[1]);
            DeletePVar(n,rowSTR[2]);
            DeletePVar(n,rowSTR[3]);
        }
    }
   
    format(rowSTR[0], 32, "rowNPC%dX", execROWMoviment[n]);
    format(rowSTR[1], 32, "rowNPC%dY", execROWMoviment[n]);
    format(rowSTR[2], 32, "rowNPC%dZ", execROWMoviment[n]);
    format(rowSTR[3], 32, "rowNPC%dS", execROWMoviment[n]);
   
    MoveRNPC(n, GetPVarFloat(n, rowSTR[0]),GetPVarFloat(n, rowSTR[1]),GetPVarFloat(n, rowSTR[2]),GetPVarFloat(n, rowSTR[3]));

    return execROWMoviment[n]++;
}

ADD_RowMoviment(n, Float:x, Float:y, Float:z, Float:s) {

    static str[32];

    format(str, 32, "rowNPC%dX", rowNPCMove[n]);
    SetPVarFloat(n, str, x);
   
    format(str, 32, "rowNPC%dY", rowNPCMove[n]);
    SetPVarFloat(n, str, y);
   
    format(str, 32, "rowNPC%dZ", rowNPCMove[n]);
    SetPVarFloat(n, str, z);
   
    format(str, 32, "rowNPC%dS", rowNPCMove[n]);
    SetPVarFloat(n, str, s);

    return rowNPCMove[n]++;
}
Now use:
pawn Code:
ADD_RowMoviment(npcid, x-0.1, y-0.1, z,0.006);
// MoveRNPC(npcid, x-0.1, y-0.1, z,0.006);
EXE_RowMoviment(npcid);
pawn Code:
new execROWMoviment[MAX_PLAYERS];
new rowNPCMove[MAX_PLAYERS];
This follows exactly where the player walks. It can also be optimized ..

- So the NPC does not fly on the wall, or walk inside them or fly into holes
I'm looking forward to your zombies npc


Re: Simple AI Police Officer NPC using RNPC - Mauzen - 15.07.2012

Quote:
Originally Posted by qq757679895
View Post
Why the police can not move.
Its a problem with the RNPC plugin, that im currently fixing. Start the route some seconds after creating the npc with a timer, and it will work.


Re: Simple AI Police Officer NPC using RNPC - qq757679895 - 16.07.2012

I used the death of NPC script, I killed him, how resurrect it.

I knelt down, he can not hit.


Re: Simple AI Police Officer NPC using RNPC - TheArcher - 16.07.2012

The plugin doesn't include any death system. You should do it by yourself in some ways.


Re: Simple AI Police Officer NPC using RNPC - Mauzen - 16.07.2012

Yep, I didnt consider any deaths in it. Youll probably need to restart the playback when the npc respawned, e.g. by calling OnNPCFinishPlayback manually.

Also heres an example code i just PMed someone, to fix the problems with NPCs not moving after spawn:
pawn Code:
new pol;
public OnGameModeInit() {
    SetTimer("ConnectAllNPCs", 5000, 0);
}

public ConnectAllNPCs() {
    // Connect the NPC after the gamemode is loaded
    pol = ConnectRNPC("Police");
    // Add all waypoints or other NPCs...
    SetTimer("StartAllRoutes", 500, 0);
}

public StartAllRoutes() {
    StartRPOLRoute(pol);
    // etc
}



Re: Simple AI Police Officer NPC using RNPC - Mauzen - 20.08.2012

You need to fill this array
pawn Code:
new rpol[MAX_RNPC_POLICE][RPol_enum] = {{-1, -1, 0.0, 0.0, 0.0, 0, 0, -1}, {-1, -1, 0.0, 0.0, 0.0, 0, 0, -1},
        {-1, -1, 0.0, 0.0, 0.0, 0, 0, -1}, {-1, -1, 0.0, 0.0, 0.0, 0, 0, -1}, {-1, -1, 0.0, 0.0, 0.0, 0, 0, -1},
        {-1, -1, 0.0, 0.0, 0.0, 0, 0, -1}, {-1, -1, 0.0, 0.0, 0.0, 0, 0, -1}, {-1, -1, 0.0, 0.0, 0.0, 0, 0, -1} };
and add/remove more {-1, -1, 0.0, 0.0, 0.0, 0, 0, -1} until it got the correct size. I was too lazy to hook a init function that fills the array automaitcally


Re: Simple AI Police Officer NPC using RNPC - ajwar - 09.01.2013

Officer pickups just first RPOLWaypoint and not continues on others. He just stand's in same position after picking the first RPOLWaypoint. Tried many ways, but npc do the same