GPS plugin -> callback is not called
#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


Messages In This Thread

Forum Jump:


Users browsing this thread: 3 Guest(s)