CONFIRMED: Gamer_z Path Finding Bug
#1

Hey Guys well i had a crashing issue in gamer_z advanced path finding plugin and i decided to make a gps in grand larceny gamemode and i included all includes in it and tested the gamemode with 2 players and i noticed it got crashed when we go in off-route other arrow showed and it crashed
pawn Код:
#include <a_samp>
#include <RouteConnector>
#include <streamer>

enum RouteInformation
{
    Destination,
    CreatedObjects[1024],
    bool:calculating,
    Lenght,
    GPS_Polygon,
    bool:IsInGPS_Polygon
};

new PlayerRoute[MAX_PLAYERS][RouteInformation];

#pragma dynamic 16777215

public OnPlayerClickMap(playerid, Float:fX, Float:fY, Float:fZ)
{
    if(PlayerRoute[playerid][calculating])
    {
        SendClientMessage(playerid,0xFFFF00FF,"Please wait before selecting your next destination!");
        return 1;
    }
    if(PlayerRoute[playerid][Destination] != -1)
    {
        DisableGPS(playerid);
    }
    new PlayerClosest = NearestPlayerNode(playerid);
    new TempDestination = NearestNodeFromPoint(fX,fY,fZ);
    if(PlayerClosest == -1)
    {
        SendClientMessage(playerid,0xFFFF00FF,"Your current location is unknown, GPS cannot be activated");
        return 1;
    }
    if(TempDestination == -1)
    {
        SendClientMessage(playerid,0xFFFF00FF,"Your selected destination is not known to the GPS, please try again");
        return 1;
    }
    if(CalculatePath(PlayerClosest, TempDestination, playerid, .CreatePolygon = true, .GrabNodePositions = true))
    {
        PlayerRoute[playerid][calculating] = true;
        SendClientMessage(playerid,0xFFFF00FF,"Connecting to sattelite.. please wait.");
    }
    else
    {
        SendClientMessage(playerid,0xFFFF00FF,"Unknown error occured, please try again.");
    }
    return 1;
}

public OnPlayerClosestNodeIDChange(playerid,old_NodeID,new_NodeID)
{
    if(new_NodeID != -1)
    {
        if(PlayerRoute[playerid][Destination] != -1)
        {
            if(PlayerRoute[playerid][Destination] == new_NodeID)
            {
                SendClientMessage(playerid,0xFFFF00FF,"You have reached your destination, have a nice day! [GPS OFF..]");
                DisableGPS(playerid);
            }
            else
            {
                if(!PlayerRoute[playerid][IsInGPS_Polygon])
                {
                    if(!PlayerRoute[playerid][calculating])
                    {
                       
                        if(CalculatePath(new_NodeID, PlayerRoute[playerid][Destination], playerid, .CreatePolygon = true, .GrabNodePositions = true))
                        {
                            DisableGPS(playerid);
                            PlayerRoute[playerid][calculating] = true;
                        }
                    }
                }
            }
        }
    }
    return 1;
}

public OnPlayerConnect(playerid)
{
    PlayerRoute[playerid][Destination] = -1;
    return 1;
}

public OnPlayerDisconnect(playerid,reason)
{
    if(PlayerRoute[playerid][Destination] != -1)
    {
        DisableGPS(playerid);
    }
    return 1;
}

stock DisableGPS(playerid)
{
    if(PlayerRoute[playerid][Destination] != -1)
    {
        for(new i = 0; i < PlayerRoute[playerid][Lenght]; ++i)
        {
            DestroyPlayerObject(playerid,PlayerRoute[playerid][CreatedObjects][i]);
        }
        PlayerRoute[playerid][Lenght] = 0;
        PlayerRoute[playerid][Destination] = -1;
        gps_RemovePlayer(playerid);
        DestroyDynamicArea(PlayerRoute[playerid][GPS_Polygon]);
        PlayerRoute[playerid][GPS_Polygon] = -1;
        PlayerRoute[playerid][IsInGPS_Polygon] = false;
    }
    return 1;
}

public GPS_WhenRouteIsCalculated(routeid,node_id_array[],amount_of_nodes,Float:distance,Float:Polygon[],Polygon_Size,Float:NodePosX[],Float:NodePosY[],Float:NodePosZ[])//Every processed Queue will be called here
{
    PlayerRoute[routeid][calculating] = false;
    if(amount_of_nodes > 1)
    {
        for(new i = 0; i < amount_of_nodes; ++i)
        {
            PlayerRoute[routeid][CreatedObjects][i] = CreateDynamicObject(1318,X,Y,Z+1.0,0.0,0.0,0.0, -1, -1, routeid, 50.0);
        }
        PlayerRoute[routeid][Lenght] = amount_of_nodes;
        PlayerRoute[routeid][Destination] = node_id_array[amount_of_nodes-1];
        PlayerRoute[routeid][GPS_Polygon] = CreateDynamicPolygon(Polygon,.maxpoints = Polygon_Size,.playerid = routeid);
        PlayerRoute[routeid][IsInGPS_Polygon] = IsPlayerInDynamicArea(routeid,PlayerRoute[routeid][GPS_Polygon]) == 1;
        gps_AddPlayer(routeid);
        SendClientMessage(routeid,0xFFFF00FF,"Recieved route information, happy drivin'!");
    }
    else
    {
        SendClientMessage(routeid,0xFFFF00FF,"Satellite not responsive, try another destination.");
    }
    return 1;
}

public OnPlayerEnterDynamicArea(playerid, areaid)
{
    if(areaid == PlayerRoute[playerid][GPS_Polygon])//check if the areas match
    {
        PlayerRoute[playerid][IsInGPS_Polygon] = true;
    }
    return 1;
}

public OnPlayerLeaveDynamicArea(playerid, areaid)
{
    if(areaid == PlayerRoute[playerid][GPS_Polygon] && PlayerRoute[playerid][IsInGPS_Polygon])
    {
        if(!PlayerRoute[playerid][calculating])
        {
            new PlayerClosest = NearestPlayerNode(playerid);
            if(PlayerClosest != -1)
            {
                if(CalculatePath(PlayerClosest, PlayerRoute[playerid][Destination], playerid, .CreatePolygon = true, .GrabNodePositions = true))
                {
                    DisableGPS(playerid);
                    PlayerRoute[playerid][calculating] = true;
                }
            }
        }
        PlayerRoute[playerid][IsInGPS_Polygon] = false;
    }
    return 1;
}
nothing else code i have inserted other than gamemode code anyone else have this problem?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)