01.04.2013, 17:07
Sometimes calculation fails (e.g. when end point is in water). I tested this plugin on my public server with 5 zombies and it worked fine.
To test use this (previous code isn't good for testing):
You should set point on map (near you) and use command :P.
To test use this (previous code isn't good for testing):
Code:
#include <a_samp>
#include <PathFinder>
#include <rnpc>
new Float:Point[MAX_PLAYERS][3];
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 i; i < nodes_size-1; i++)
{
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);
}
return 1;
}
public OnFilterScriptInit()
{
PathFinder_Init(1.0); //test
ConnectRNPC("Bot"); //id 0
return 1;
}
public OnPlayerCommandText(playerid,cmdtext[])
{
if(!strcmp("/bot_test",cmdtext,true))
{
new Float:x,Float:y,Float:z;
GetPlayerPos(playerid,x,y,z);
PathFinder_FindWay(0,x,y,Point[playerid][0],Point[playerid][1]);
return 1;
}
return 0;
}
public OnPlayerClickMap(playerid, Float:fX, Float:fY, Float:fZ)
{
Point[playerid][0] = fX;
Point[playerid][1] = fY;
Point[playerid][2] = fZ;
return 1;
}

