GPS plugin -> callback is not called
#1

Hi, i have problem. My code
Code:
public OnPlayerClosestNodeIDChange(playerid,old_NodeID,new_NodeID){
new strr[128];
format(strr,128,"Old %d New %d",old_NodeID,new_NodeID);
SendClientMessageToAll(-1,strr);
return true;
}
this public is not called... how to repair this ?

Thanks
Reply
#2

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

Thanks, it works ! Thanks for fast reply.
Reply
#4

How to add "walker nodes" ? For citizens
Reply
#5

Quote:
Originally Posted by Patchwerk
View Post
How to add "walker nodes" ? For citizens
AddNode(Ex).
Reply
#6

I have this
Code:
print("1");
new car = GetPlayerVehicleID(playerid);
node++;
new Float:x,Float:y,Float:z;
print("2");
GetVehiclePos(car,x,y,z);
print("3");
AddNode(x,y,z,1, 1);
new str[256];
format(str,256,"node %d",node);
print("4");
CreateDynamic3DTextLabel(str, 0xFF0000FF, x, y, z+5,50);
print("5");
In 1 second timer and its crashing my server. In serverlog i have last print "3"
Reply
#7

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

How to use it ? Can you make example usage ?
Reply
#9

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;
}
Reply
#10

Thanks its useful function
Reply
#11

Also note that RebuildGraph() takes care of race conditions (threading problems) while AddNode with AddToPathfinder = 1 set does not.
Reply
#12

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

Quote:
Originally Posted by Patchwerk
View Post
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?
Reply
#14

Yes, i can use CalculatePath with new nodes
Reply
#15

sorry, im not tested it
Reply
#16

No, it not working. It crashing my server
code

Code:
if(!strcmp("/3",cmdtext)){

			new nodeID = NearestPlayerNode(playerid);
			new nodeID2 = NearestNodeFromPoint(0,0,5);

		print("CalculatePath");
		CalculatePath(nodeID,nodeID2,playerid, .GrabNodePositions = true);
return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)