how to create gps system like this ?
#1

hello i like to create gps like crzybob server its very cool i tried to make one but i couldnt

i practice alot examples but i didnt success
https://github.com/grasmanek94/GPB/t...RouteConnector


https://pasteboard.co/HDwfIzK.png
Reply
#2

this would be easiest way, but i havent used this plugin for long time so idk any specific details
PHP код:
    new route1=AddNode(0.0,0.0,0.0),route2=AddNode(0.0,0.0,0.0);
    
CalculatePath(route1,route2,.GrabNodePositions true);
public 
GPS_WhenRouteIsCalculated(routeidnode_id_array[], amount_of_nodesFloat:distanceFloat:Polygon[], Polygon_SizeFloat:NodePosX[], Float:NodePosY[], Float:NodePosZ[]){
    for(new 
iamount_of_nodesi++){
        
CreateDynamicObject(3082,NodePosX[i],NodePosY[i],NodePosZ[i]+1.0,0.0,0.0,0.0);
    }
    return 
1;

Reply
#3

RouteConnector is very complicated for me and i can't figure out how and where to put what and why.
I tried the same thing but couldn't make it work. I got stuck with NearestPlayerNode. So if anyone can help me and this guy will be rewarded!

My gps code:
PHP код:
#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(playeridreason)
{
     if(
GPS_Activated[playerid] == && 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)
{
    for(new 
0PlayerRoute[playerid][Lenght]; ++i)
    {
        
DestroyPlayerObject(playerid,PlayerRoute[playerid][CreatedObjects][i]);
    }
    
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 0amount_of_nodes; ++i)
        {
            
PlayerRoute[routeid][CreatedObjects][i] = CreatePlayerObject(routeid,1318,NodePosX[i],NodePosY[i],NodePosZ[i]+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(playeridparams[])
{
//        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(playeridGPSDIALOG_STYLE_LIST"GPS""Los Santos\nLas Venturas\nSan Fierro""Select""Close");
        return 
1;
}
CMD:gpsoff(playerid,params[])
{
        if(
GPS_Activated[playerid] == && PlayerRoute[playerid][Destination] != -1)
        {
            
DisablePlayerCheckpoint(playerid);
            
GameTextForPlayer(playerid"GPS OFF"30003);
            
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"30003);
        return 
1;
}
public 
OnPlayerEnterCheckpoint(playerid)
{
    if(
GPS_Activated[playerid] == && PlayerRoute[playerid][Destination] != -1)
    {
        
GameTextForPlayer(playerid"You have reached your destination"30003);
        
DisablePlayerCheckpoint(playerid);
        
GPS_Activated[playerid] = 0;
        
DisableGPS(playerid);
        
PlayerRoute[playerid][Lenght] = 0;
        
PlayerRoute[playerid][Destination] = -1;
        
gps_RemovePlayer(playerid);
    }
    return 
1;
}
public 
OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    if(
response)
    {
            switch(
dialogid == GPS)
           {
               case 
1:
               {
                  switch(
listitem)
                 {
                   case 
0:
                   {
                   
ShowPlayerDialog(playeridGPSLSDIALOG_STYLE_LIST"Los Santos""Los Santos police department\n""Select""Close");
                   }
                   case 
1:
                   {
                   
ShowPlayerDialog(playeridGPSLVDIALOG_STYLE_LIST"Las Venturas""Las Venturas police department\n""Select""Close");
                   }
                   case 
2:
                   {
                   
ShowPlayerDialog(playeridGPSSFDIALOG_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.735713.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!"30003);
                        
GPS_Activated[playerid] = 1;
                        
SetPlayerCheckpoint(playerid1533.1295,-1657.7357,13.38288);
                    }
                    else 
SendClientMessage(playerid,-1,"Unknown error, please try again.");
                }
            }
          }
        }
        if(
dialogid == GPSLV)
        {
        if(!
response) return 0;
        {
            switch(
listitem)
            {
                case 
0:
                {
                 
SetPlayerCheckpoint(playerid2230.2854,2470.0540,10.82038);
                 
GameTextForPlayer(playerid"~w~Check Your minimap"30003);
                 
GPS_Activated[playerid] = 1;
                }
            }
        }
    }
    if(
dialogid == GPSSF)
    {
        if(!
response) return 0;
        {
            switch(
listitem)
            {
                case 
0:
                {
                 
SetPlayerCheckpoint(playerid, -1563.9243,659.6130,7.03918);
                 
GameTextForPlayer(playerid"~w~Check Your Minimap"30003);
                 
GPS_Activated[playerid] = 1;
                }
            }
          }
    }
    return 
1;

Reply
#4

Here is a script which uses RouteConnector.
https://sampforum.blast.hk/showthread.php?tid=437708
You may get idea by seeing this.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)