SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 06/01/2020, 04:33 PM   #1
Z3nx31L
Little Clucker
 
Join Date: Aug 2019
Posts: 34
Reputation: 0
Default Pathfinder for FNCPC?

How to i make pathfinder for FCNPC?
__________________

Z3nx31L Is Here
Z3nx31L is offline   Reply With Quote
Old 07/01/2020, 10:34 PM   #2
bookknp
Huge Clucker
 
bookknp's Avatar
 
Join Date: Dec 2013
Posts: 243
Reputation: 24
Default Re: Pathfinder for FNCPC?

Quote:
Originally Posted by Z3nx31L View Post
How to i make pathfinder for FCNPC?
hi, you use Pathfinder.inc

example:
PHP Code:
#include <a_samp>
#include <PathFinder>
#include <rnpc>
new zombie_moved[5];
new 
zombie_timer;
public 
OnPathCalculated(routeid,success,nodes[],nodes_size)
{
    if(
success)
    {
        new 
Float:x,Float:y,Float:z,Float:x1,Float:y1,Float:z1;
        
RNPC_CreateBuild(routeid,PLAYER_RECORDING_TYPE_ONFOOT);
        
//Bot!
        
for(new inodes_size-1i++)
        {
            
PathFinder_GetNodePos(nodes[i],x,y,z);
            
PathFinder_GetNodePos(nodes[i+1],x1,y1,z1);
            
RNPC_AddMovement(x,y,z+1,x1,y1,z1+1,RNPC_SPEED_RUN); //crappy :D
        
}
        
RNPC_FinishBuild();
        
RNPC_StartBuildPlayback(routeid);
    }
    else
    {
        new 
text[126];
        
format(text,sizeof(text),"Zombie: %d failed!",routeid);
        
SendClientMessageToAll(-1,text);
        
zombie_moved[routeid] = true;
    }
    return 
1;
}
public 
OnFilterScriptInit()
{
    
PathFinder_Init(1.0);
    
ConnectRNPC("Zombie1"); //id 0
    
ConnectRNPC("Zombie2");
    
ConnectRNPC("Zombie3");
    
ConnectRNPC("Zombie4");
    
ConnectRNPC("Zombie5");
    return 
1;
}
public 
OnPlayerCommandText(playerid,cmdtext[])
{
    if(!
strcmp("/zombie_spawn",cmdtext,true))
    {
        new 
Float:x,Float:y,Float:z;
        
GetPlayerPos(playerid,x,y,z);
        
SetPlayerPos(0,x+5,y,z);
        
SetPlayerSkin(0,200);
        
SetPlayerPos(1,x-5,y,z);
        
SetPlayerSkin(1,200);
        
SetPlayerPos(2,x+5,y+5,z);
        
SetPlayerSkin(2,200);
        
SetPlayerPos(3,x+5,y-5,z);
        
SetPlayerSkin(3,200);
        
SetPlayerPos(4,x-5,y-5,z);
        
SetPlayerSkin(4,200);
        return 
1;
    }
    if(!
strcmp("/zombie_start",cmdtext,true))
    {
        for(new 
i=0;i<5;i++)
        {
            
zombie_moved[i] = true;
        }
        
zombie_timer SetTimerEx("ZombieRun",1000,1,"d",playerid);
        return 
1;
    }
    if(!
strcmp("/zombie_stop",cmdtext,true))
    {
        
KillTimer(zombie_timer);
        return 
1;
    }
    return 
0;
}
public 
OnRNPCPlaybackFinished(npcid)
{
    
zombie_moved[npcid] = true;
    return 
1;
}
forward ZombieRun(playerid);
public 
ZombieRun(playerid)
{
    new 
Float:x,Float:y,Float:z,Float:x1,Float:y1,Float:z1;
    
GetPlayerPos(playerid,x1,y1,z1);
    for(new 
i=0;i<5;i++)
    {
        if(
zombie_moved[i])
        {
            
GetPlayerPos(i,x,y,z);
            
PathFinder_FindWay(i,x,y,x1+random(6)-3,y1+random(6)-3);
            
zombie_moved[i] = false;
        }
    }
    return 
1;

bookknp is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Plugin] PathFinder by Pamdex pamdex Plugin Development 150 28/07/2020 12:14 PM
A* Pathfinder (3D map) in samp ForT Everything and Nothing 24 14/06/2019 07:54 PM
[Plugin] PathFinder jeanluc162 Plugin Development 19 05/09/2015 07:39 PM


All times are GMT. The time now is 03:23 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.