Posts: 1,047
Threads: 23
Joined: Jun 2009
did you use gps_AddPlayer(playerid); for the player you want to use the public for?
and remember to use gps_RemovePlayer(playerid); when not needed anymore.
There is a extended tutorial on the GPS plugin available here:
https://sampforum.blast.hk/showthread.php?tid=411357
Posts: 80
Threads: 15
Joined: Jul 2011
Reputation:
0
How to add "walker nodes" ? For citizens
Posts: 1,047
Threads: 23
Joined: Jun 2009
Quote:
Originally Posted by Patchwerk
How to add "walker nodes" ? For citizens
|
AddNode(Ex).
Posts: 1,047
Threads: 23
Joined: Jun 2009
I suggest you leave out the 1,1 after the xyz paramaters and use RebuildGraph (plugin and include version 184) after you are done adding nodes.
Posts: 1,047
Threads: 23
Joined: Jun 2009
pawn Code:
//example for RebuildGraph
#include <a_samp>
#include <RouteConnector>
#define MY_NODES (5)
new Float:ArrayWithPositions[MY_NODES][3] =
{
{0.0,0.0,0.0},
{1.0,1.0,1.0},
{2.0,2.0,2.0},
{3.0,3.0,3.0},
{4.0,4.0,4.0}
};
new SavedNodeIDS[MY_NODES];
new Errors[2] = {0,0};
public OnFilterScriptInit()
{
//create nodes
for(new index = 0; index < MY_NODES; ++index)
{
SavedNodeIDS[index] = AddNode(ArrayWithPositions[index][0],ArrayWithPositions[index][1],ArrayWithPositions[index][2]);
if(SavedNodeIDS[index] == (-1))
{
++Errors[0];
}
}
//connect nodes
for(new index = 1; index < MY_NODES; ++index)
{
if(SavedNodeIDS[index-1] != (-1) && SavedNodeIDS[index] != (-1))
{
if(ConnectNodes(SavedNodeIDS[index-1],SavedNodeIDS[index]) < 0)
{
++Errors[1];
}
}
}
//rebuild graph
if(RebuildGraph())//server freezes until graph is rebuild, should take a few miliseconds
{
if(Errors[0] || Errors[1])
{
printf("Graph rebuilded succesfully but failed adding %d nodes and failed to create %d connections.",Errors[0],Errors[1]);
}
else
{
printf("Graph rebuilded succesfully without errors.");
}
}
else
{
if(Errors[0] || Errors[1])
{
printf("Graph rebuild FAILED, %d nodes could not be added and creating %d connections failed.",Errors[0],Errors[1]);
}
else
{
printf("Graph rebuild FAILED but all nodes were added succesfully.");
}
}
return 1;
}
Posts: 80
Threads: 15
Joined: Jul 2011
Reputation:
0
Thanks its useful function
Posts: 1,047
Threads: 23
Joined: Jun 2009
Also note that RebuildGraph() takes care of race conditions (threading problems) while AddNode with AddToPathfinder = 1 set does not.
Posts: 1,047
Threads: 23
Joined: Jun 2009
Quote:
Originally Posted by Patchwerk
I have this
Code:
new File:f = fopen("Nodes.txt",io_read);
print("2");
new str[256];
new indexx;
while(fread(f,str)){
new Float:x,Float:y,Float:z;
sscanf(str, "p<|>fff", x, y, z); //sscanf plugin :)
// printf("%f %f %f",x, y, z);
SavedNodeIDS[indexx] = AddNode(x, y, z);
if(SavedNodeIDS[indexx] == (-1))
{
print("ERROR");
++Errors[0];
}
indexx++;
}
fclose(f);
print("4");
//connect nodes
for(new index = 1; index < MY_NODES; ++index)
{
if(SavedNodeIDS[index-1] != (-1) && SavedNodeIDS[index] != (-1))
{
if(ConnectNodes(SavedNodeIDS[index-1],SavedNodeIDS[index]) < 0)
{
print("ERROR 2");
++Errors[1];
}
}
}
print("creating graph !!!!!!!!!!!");
//rebuild graph
if(RebuildGraph())//server freezes until graph is rebuild, should take a few miliseconds
{
if(Errors[0] || Errors[1])
{
printf("Graph rebuilded succesfully but failed adding %d nodes and failed to create %d connections.",Errors[0],Errors[1]);
}
else
{
printf("Graph rebuilded succesfully without errors.");
}
}
else
{
if(Errors[0] || Errors[1])
{
printf("Graph rebuild FAILED, %d nodes could not be added and creating %d connections failed.",Errors[0],Errors[1]);
}
else
{
printf("Graph rebuild FAILED but all nodes were added succesfully.");
}
}
but its print "Graph rebuild FAILED but all nodes were added succesfully."
In Nodes.txt i have
Code:
-892.458129|1273.021728|35.418518
-896.376647|1263.579833|34.825996
-893.042053|1248.275878|34.745880
-887.429809|1233.633300|35.088066
-883.389709|1216.690673|33.656955
-884.337829|1196.213745|31.959152
-890.417846|1175.161621|30.537527
-886.196411|1151.811767|28.928644
-879.719177|1127.689697|27.161552
|
that is weird : o does CalculatePath calculate with the new nodes?
Posts: 80
Threads: 15
Joined: Jul 2011
Reputation:
0
Yes, i can use CalculatePath with new nodes