Pitanje vezano za RouteConnector

Započeo darkness1988, Septembar 13, 2018, 12:36:28 POSLE PODNE

prethodna tema - sledeća tema

0 članova i 4 gostiju pregledaju ovu temu.

Problem(error/warning): Route Connector mi je jednostavno zahtjevan za korištenje i htio bi da me neko posavjetuje kako i što dalje, većinu sam napravio sam. Zapeo sam na NearestPlayerNode. Ispričavam se što sam na dio skripte stavio cijelu filterskriptu jer je vrlo bitno što je definirano. Točnije, tako će biti lakše drugima uvidjeti problem
Dio skripte: [pawn]#
include <a_samp>
#include <zcmd>
#include <RouteConnector>

#define GPS 10
#define GPSLS 11
#define GPSLV 12
#define GPSSF 13

new GPS_Activated[MAX_PLAYERS] = 0;

enum RouteInformation
{
   Destination,
   CreatedObjects[1024],
   bool:calculating,
   Lenght
};
new PlayerRoute[MAX_PLAYERS][RouteInformation];


public OnFilterScriptInit()
{
   return 1;
}

public OnFilterScriptExit()
{
   return 1;
}


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

public OnPlayerDisconnect(playerid, reason)
{
     if(GPS_Activated[playerid] == 1 && PlayerRoute[playerid][Destination] != -1)
     {
        GPS_Activated[playerid] = 0;
      DisableGPS(playerid);
      PlayerRoute[playerid][Lenght] = 0;
      PlayerRoute[playerid][Destination] = -1;
      gps_RemovePlayer(playerid);
    }
    return 1;
}
forward DisableGPS(playerid);
public DisableGPS(playerid)//iskljucivanje GPS
{
   for(new i = 0; i < PlayerRoute[playerid][Lenght]; ++i)
   {
      DestroyPlayerObject(playerid,PlayerRoute[playerid][CreatedObjects]); //brisanje objekata
   }
   PlayerRoute[playerid][Lenght] = 0;
   PlayerRoute[playerid][Destination] = -1;
   gps_RemovePlayer(playerid);
   return 1;
}
public GPS_WhenRouteIsCalculated(routeid,node_id_array[],amount_of_nodes,Float:distance,Float:Polygon[],Polygon_Size,Float:NodePosX[],Float:NodePosY[],Float:NodePosZ[])//Kada se ruta kreira
{
   PlayerRoute[routeid][calculating] = false;// puts the route creation on false
   if(amount_of_nodes > 1)
   { // if the number of points in the path is greater than 1
       for(new i = 0; i < amount_of_nodes; ++i)
      {
         PlayerRoute[routeid][CreatedObjects] = CreatePlayerObject(routeid,1318,NodePosX,NodePosY,NodePosZ+1.0,0.0,0.0,0.0,150.0); // create objects by the way ...
       }
       PlayerRoute[routeid][Lenght] = amount_of_nodes; // sets the number of points on the road
      PlayerRoute[routeid][Destination] = node_id_array[amount_of_nodes-1]; // sets the destination
       gps_AddPlayer(routeid); // adds players to that route
       SendClientMessage(routeid,-1,"Route created, happy way!");
   }
   else {
      SendClientMessage(routeid,-1,"Satellite can not find you at this location, go to the nearest road.");
   }

   return 1;
}

public OnPlayerClosestNodeIDChange(playerid,old_NodeID,new_NodeID)
{ // when the player arrives at the destination
   if(new_NodeID != -1)
   {
      if(PlayerRoute[playerid][Destination] == new_NodeID) {
         SendClientMessage(playerid,-1,"You're at the destination.");
         DisableGPS(playerid);
      }
   }
   return 1;
}


CMD:gps(playerid, params[])
{
//        if(!IsPlayerInAnyVehicle(playerid)) return GameTextForPlayer(playerid, "~w~You're not in a vehicle", 3000, 3);
       
        if(PlayerRoute[playerid][calculating])
      { // This will check if the route is created
         SendClientMessage(playerid,-1,"First, delete your chosen route. / gpsoff");
         return 1;
      }
      if(PlayerRoute[playerid][Destination] != -1) // this will be a security check that does not create a player 2 routes first to turn off the old one
      {
         DisableGPS(playerid);
      }
        ShowPlayerDialog(playerid, GPS, DIALOG_STYLE_LIST, "GPS", "Los Santos\nLas Venturas\nSan Fierro", "Select", "Close");
        return 1;
}
CMD:gpsoff(playerid,params[])
{
        if(GPS_Activated[playerid] == 1 && PlayerRoute[playerid][Destination] != -1)
        {
            DisablePlayerCheckpoint(playerid);
            GameTextForPlayer(playerid, "GPS OFF", 3000, 3);
            GPS_Activated[playerid] = 0;
            DisableGPS(playerid);
            PlayerRoute[playerid][Lenght] = 0;
         PlayerRoute[playerid][Destination] = -1;
         gps_RemovePlayer(playerid);
        }
        else GameTextForPlayer(playerid, "~w~GPS is not activated", 3000, 3);
        return 1;
}
public OnPlayerEnterCheckpoint(playerid)
{
    if(GPS_Activated[playerid] == 1 && PlayerRoute[playerid][Destination] != -1)
    {
      GameTextForPlayer(playerid, "You have reached your destination", 3000, 3);
      DisablePlayerCheckpoint(playerid);
      GPS_Activated[playerid] = 0;
      DisableGPS(playerid);
      PlayerRoute[playerid][Lenght] = 0;
      PlayerRoute[playerid][Destination] = -1;
      gps_RemovePlayer(playerid);
    }
   return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(response)
    {
            switch(dialogid == GPS)
           {
               case 1:
               {
                  switch(listitem)
                 {
                 case 0:
                 {
                 ShowPlayerDialog(playerid, GPSLS, DIALOG_STYLE_LIST, "Los Santos", "Los Santos police department\n", "Select", "Close");
                 }
                 case 1:
                 {
                 ShowPlayerDialog(playerid, GPSLV, DIALOG_STYLE_LIST, "Las Venturas", "Las Venturas police department\n", "Select", "Close");
                 }
                 case 2:
                 {
                 ShowPlayerDialog(playerid, GPSSF, DIALOG_STYLE_LIST, "San Fierro", "San Fierro police department\n", "Select", "Close");
                 }
             }
              }
          }
    }
    if(dialogid == GPSLS)
    {
        if(response)
        {
            switch(listitem)
            {
                case 0:
                {
               //==== Testing with LSPD
                    new PlayerClosest = NearestPlayerNode(playerid); // this will take the closest point where the player is located
                new TempDestination = NearestNodeFromPoint(1533.1295, -1657.7357, 13.3828); // this is taken to the nearest point on the specified coordinates X, Y, Z

               if(PlayerClosest == TempDestination)
               { // if the player is already on the target
                      SendClientMessage(playerid,-1,"You are already in that location.");
                   return 1;
               }
               if(PlayerClosest == -1)
               {
                  SendClientMessage(playerid,-1,"Satellite can not find a destination, please try again.");
                  return 1;
               }
               if(TempDestination == -1)
               {// if the player is far from the nearest point on the way
                  SendClientMessage(playerid,-1,"Satellite can not find a destination, please try again.");
                  return 1;
               }
               if(CalculatePath(PlayerClosest,TempDestination,playerid, .GrabNodePositions = true))
               { // if the route is created
                  PlayerRoute[playerid][calculating] = true;
                   SendClientMessage(playerid,-1,"Create a route, please wait");
                   GameTextForPlayer(playerid, "~w~Check Your minimap!", 3000, 1);
                       GPS_Activated[playerid] = 1;
                       SetPlayerCheckpoint(playerid, 1533.1295,-1657.7357,13.3828, 8);
               }
               else SendClientMessage(playerid,-1,"Unknown error, please try again.");
                }
            }
          }
        }
        if(dialogid == GPSLV)
        {
        if(!response) return 0;
        {
            switch(listitem)
            {
                case 0:
                {
                 SetPlayerCheckpoint(playerid, 2230.2854,2470.0540,10.8203, 8);
                 GameTextForPlayer(playerid, "~w~Check Your minimap", 3000, 2);
                 GPS_Activated[playerid] = 1;
                }
            }
        }
    }
    if(dialogid == GPSSF)
    {
        if(!response) return 0;
        {
            switch(listitem)
            {
                case 0:
                {
                 SetPlayerCheckpoint(playerid, -1563.9243,659.6130,7.0391, 8);
                 GameTextForPlayer(playerid, "~w~Check Your Minimap", 3000, 3);
                 GPS_Activated[playerid] = 1;
                }
            }
          }
    }
    return 1;
}
[/pawn]
Debug iz server_log(ukoliko je u pitanju crashanje servera - crashdetect log): [ code ]Compilano bez errora[ /code ]
Slika/video ingame problema(obavezno ako je ingame problem): /
Poslednja Izmena: Septembar 19, 2018, 16:06:12 POSLE PODNE od Bašovski


Citat: Jerenić poslato Septembar 13, 2018, 13:41:20 POSLE PODNE
Pawn format?
[pawn]Test[/pawn]
Izvini, krivo sam nesto stavio sa zagradama, može li neki admin edit? Nema veze, ja cu stavit ovamo

[pawn]
#include <a_samp>
#include <zcmd>
#include <RouteConnector>

#define GPS 10
#define GPSLS 11
#define GPSLV 12
#define GPSSF 13

new GPS_Activated[MAX_PLAYERS] = 0;

enum RouteInformation
{
   Destination,
   CreatedObjects[1024],
   bool:calculating,
   Lenght
};
new PlayerRoute[MAX_PLAYERS][RouteInformation];


public OnFilterScriptInit()
{
   return 1;
}

public OnFilterScriptExit()
{
   return 1;
}


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

public OnPlayerDisconnect(playerid, reason)
{
     if(GPS_Activated[playerid] == 1 && PlayerRoute[playerid][Destination] != -1)
     {
        GPS_Activated[playerid] = 0;
      DisableGPS(playerid);
      PlayerRoute[playerid][Lenght] = 0;
      PlayerRoute[playerid][Destination] = -1;
      gps_RemovePlayer(playerid);
    }
    return 1;
}
forward DisableGPS(playerid);
public DisableGPS(playerid)//iskljucivanje GPS
{
   for(new i = 0; i < PlayerRoute[playerid][Lenght]; ++i)
   {
      DestroyPlayerObject(playerid,PlayerRoute[playerid][CreatedObjects]); //brisanje objekata
   }
   PlayerRoute[playerid][Lenght] = 0;
   PlayerRoute[playerid][Destination] = -1;
   gps_RemovePlayer(playerid);
   return 1;
}
public GPS_WhenRouteIsCalculated(routeid,node_id_array[],amount_of_nodes,Float:distance,Float:Polygon[],Polygon_Size,Float:NodePosX[],Float:NodePosY[],Float:NodePosZ[])//Kada se ruta kreira
{
   PlayerRoute[routeid][calculating] = false;// puts the route creation on false
   if(amount_of_nodes > 1)
   { // if the number of points in the path is greater than 1
       for(new i = 0; i < amount_of_nodes; ++i)
      {
         PlayerRoute[routeid][CreatedObjects] = CreatePlayerObject(routeid,1318,NodePosX,NodePosY,NodePosZ+1.0,0.0,0.0,0.0,150.0); // create objects by the way ...
       }
       PlayerRoute[routeid][Lenght] = amount_of_nodes; // sets the number of points on the road
      PlayerRoute[routeid][Destination] = node_id_array[amount_of_nodes-1]; // sets the destination
       gps_AddPlayer(routeid); // adds players to that route
       SendClientMessage(routeid,-1,"Route created, happy way!");
   }
   else {
      SendClientMessage(routeid,-1,"Satellite can not find you at this location, go to the nearest road.");
   }

   return 1;
}

public OnPlayerClosestNodeIDChange(playerid,old_NodeID,new_NodeID)
{ // when the player arrives at the destination
   if(new_NodeID != -1)
   {
      if(PlayerRoute[playerid][Destination] == new_NodeID) {
         SendClientMessage(playerid,-1,"You're at the destination.");
         DisableGPS(playerid);
      }
   }
   return 1;
}


CMD:gps(playerid, params[])
{
//        if(!IsPlayerInAnyVehicle(playerid)) return GameTextForPlayer(playerid, "~w~You're not in a vehicle", 3000, 3);
       
        if(PlayerRoute[playerid][calculating])
      { // This will check if the route is created
         SendClientMessage(playerid,-1,"First, delete your chosen route. / gpsoff");
         return 1;
      }
      if(PlayerRoute[playerid][Destination] != -1) // this will be a security check that does not create a player 2 routes first to turn off the old one
      {
         DisableGPS(playerid);
      }
        ShowPlayerDialog(playerid, GPS, DIALOG_STYLE_LIST, "GPS", "Los Santos\nLas Venturas\nSan Fierro", "Select", "Close");
        return 1;
}
CMD:gpsoff(playerid,params[])
{
        if(GPS_Activated[playerid] == 1 && PlayerRoute[playerid][Destination] != -1)
        {
            DisablePlayerCheckpoint(playerid);
            GameTextForPlayer(playerid, "GPS OFF", 3000, 3);
            GPS_Activated[playerid] = 0;
            DisableGPS(playerid);
            PlayerRoute[playerid][Lenght] = 0;
         PlayerRoute[playerid][Destination] = -1;
         gps_RemovePlayer(playerid);
        }
        else GameTextForPlayer(playerid, "~w~GPS is not activated", 3000, 3);
        return 1;
}
public OnPlayerEnterCheckpoint(playerid)
{
    if(GPS_Activated[playerid] == 1 && PlayerRoute[playerid][Destination] != -1)
    {
      GameTextForPlayer(playerid, "You have reached your destination", 3000, 3);
      DisablePlayerCheckpoint(playerid);
      GPS_Activated[playerid] = 0;
      DisableGPS(playerid);
      PlayerRoute[playerid][Lenght] = 0;
      PlayerRoute[playerid][Destination] = -1;
      gps_RemovePlayer(playerid);
    }
   return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(response)
    {
            switch(dialogid == GPS)
           {
               case 1:
               {
                  switch(listitem)
                 {
                 case 0:
                 {
                 ShowPlayerDialog(playerid, GPSLS, DIALOG_STYLE_LIST, "Los Santos", "Los Santos police department\n", "Select", "Close");
                 }
                 case 1:
                 {
                 ShowPlayerDialog(playerid, GPSLV, DIALOG_STYLE_LIST, "Las Venturas", "Las Venturas police department\n", "Select", "Close");
                 }
                 case 2:
                 {
                 ShowPlayerDialog(playerid, GPSSF, DIALOG_STYLE_LIST, "San Fierro", "San Fierro police department\n", "Select", "Close");
                 }
             }
              }
          }
    }
    if(dialogid == GPSLS)
    {
        if(response)
        {
            switch(listitem)
            {
                case 0:
                {
               //==== Testing with LSPD
                    new PlayerClosest = NearestPlayerNode(playerid); // this will take the closest point where the player is located
                new TempDestination = NearestNodeFromPoint(1533.1295, -1657.7357, 13.3828); // this is taken to the nearest point on the specified coordinates X, Y, Z

               if(PlayerClosest == TempDestination)
               { // if the player is already on the target
                      SendClientMessage(playerid,-1,"You are already in that location.");
                   return 1;
               }
               if(PlayerClosest == -1)
               {
                  SendClientMessage(playerid,-1,"Satellite can not find a destination, please try again.");
                  return 1;
               }
               if(TempDestination == -1)
               {// if the player is far from the nearest point on the way
                  SendClientMessage(playerid,-1,"Satellite can not find a destination, please try again.");
                  return 1;
               }
               if(CalculatePath(PlayerClosest,TempDestination,playerid, .GrabNodePositions = true))
               { // if the route is created
                  PlayerRoute[playerid][calculating] = true;
                   SendClientMessage(playerid,-1,"Create a route, please wait");
                   GameTextForPlayer(playerid, "~w~Check Your minimap!", 3000, 1);
                       GPS_Activated[playerid] = 1;
                       SetPlayerCheckpoint(playerid, 1533.1295,-1657.7357,13.3828, 8);
               }
               else SendClientMessage(playerid,-1,"Unknown error, please try again.");
                }
            }
          }
        }
        if(dialogid == GPSLV)
        {
        if(!response) return 0;
        {
            switch(listitem)
            {
                case 0:
                {
                 SetPlayerCheckpoint(playerid, 2230.2854,2470.0540,10.8203, 8);
                 GameTextForPlayer(playerid, "~w~Check Your minimap", 3000, 2);
                 GPS_Activated[playerid] = 1;
                }
            }
        }
    }
    if(dialogid == GPSSF)
    {
        if(!response) return 0;
        {
            switch(listitem)
            {
                case 0:
                {
                 SetPlayerCheckpoint(playerid, -1563.9243,659.6130,7.0391, 8);
                 GameTextForPlayer(playerid, "~w~Check Your Minimap", 3000, 3);
                 GPS_Activated[playerid] = 1;
                }
            }
          }
    }
    return 1;
}[/pawn]



Citat: Timur Script poslato Septembar 15, 2018, 12:03:21 POSLE PODNE
Problm koji je?

Citat: Slade poslato Septembar 14, 2018, 23:56:50 POSLE PODNE
Å ta je problem?
Zapeo sam na NearestPlayerNode, ne znam Å¡ta i kako dalje. Pratio sam ovaj tutorijal: http://balkan-samp.com/forum/index.php?PHPSESSID=04fbc825jpdo722p4dk6i7kcj7&topic=100478.0

Znam da je route connector dosta zbugovan i to sve, ali bi htio strelice po cesti za gps. Pa bih zamolio ako netko moze malo me savjetovati kako dalje, gdje sta i kako.


Zanima me, koji do NearestPlayerNodea ti smeta, uglavnom to ti, koliko znam, služi da provjeriš udaljenost trenutnog (najbližeg nodea) recimo te lokacije, zatim notea tog igrača (playerid), ali budući da nisam 100% siguran da je to tačno, nisam kompetentan da ti dam siguran odgovor, ali mislim da je to to. Imaš Driver-FS koji koristi taj plugin i inc, Taxiji, obicni vozaci i policija po gradu, kucaj Taxi NPC i naci ces na stranom samp forumu, i pogledaj malo za sta se to koristi.

Citat: Slade poslato Septembar 17, 2018, 14:47:06 POSLE PODNE
Zanima me, koji do NearestPlayerNodea ti smeta, uglavnom to ti, koliko znam, služi da provjeriš udaljenost trenutnog (najbližeg nodea) recimo te lokacije, zatim notea tog igrača (playerid), ali budući da nisam 100% siguran da je to tačno, nisam kompetentan da ti dam siguran odgovor, ali mislim da je to to. Imaš Driver-FS koji koristi taj plugin i inc, Taxiji, obicni vozaci i policija po gradu, kucaj Taxi NPC i naci ces na stranom samp forumu, i pogledaj malo za sta se to koristi.
Izgleda su ugasili SAMP forume, no nema veze. Snasao sam se i pronasao sam zasto ne radi. Sada mogu sve povezat i gps i truck delivery i sve misije na koje se ide po pickup i cijela ruta gdje se vozi bude prikazana strelicama po cesti. Samo ih jos malo rotiram i posao obavljen. Hvala Puno i moze lock na ovo ;)