GPS system
#1

Okay, i have a little simple gps system with so far no bugs. Can anyone help me to do it correctly without errors?
Next thing i want to add is this:

http://i.imgur.com/7ZK4e7T.png

Here are the codes of /GPS:
PHP код:
#define FILTERSCRIPT
#include <a_samp>
#include <zcmd>
#define GPS 10
#define GPSLS 11
#define GPSLV 12
#define GPSSF 13
#pragma tabsize 0
CMD:gps(playeridparams[])
{
        if(
IsPlayerInAnyVehicle(playerid))
        {
        
ShowPlayerDialog(playeridGPSDIALOG_STYLE_LIST"GPS""Los Santos\nLas Venturas\nSan Fierro""Select""Close");
        return 
1;
        }
        
//GameTextForPlayer(playerid, "~w~You're not in a vehicle", 3000, 3);
        
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) return 0;
        {
            switch(
listitem)
            {
                case 
0:
                {
                 
SetPlayerCheckpoint(playerid1533.1295,-1657.7357,13.38288);
                 
GameTextForPlayer(playerid"~w~Check Your minimap!"30001);
                }
            }
          }
        }
        if(
dialogid == GPSLV)
        {
        if(!
response) return 0;
        {
            switch(
listitem)
            {
                case 
0:
                {
                 
SetPlayerCheckpoint(playerid2230.2854,2470.0540,10.82038);
                 
GameTextForPlayer(playerid"~w~Check Your minimap"30002);
                }
            }
        }
    }
    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);
                }
            }
          }
        }
    return 
1;
}
public 
OnPlayerExitVehicle(playeridvehicleid)
{
        
//DisablePlayerCheckpoint(playerid);
        
return 1;
}
public 
OnPlayerEnterCheckpoint(playerid)
{
        
GameTextForPlayer(playerid"You have reached your destination"30003);
        
DisablePlayerCheckpoint(playerid);
        return 
1;

On top of script goes something like this:
PHP код:
#include < RouteConnector >
enum RouteInformation
{
    
Destination,
    
CreatedObjects[1024],
    
bool:calculating,
    
Lenght
};
new 
PlayerRoute[MAX_PLAYERS][RouteInformation]; 
OnPlayerConnect
PHP код:
PlayerRoute[playerid][Destination] = -1
OnPlayerDisconnect
PHP код:
if(PlayerRoute[playerid][Destination] != -1) {
        
DisableGPS(playerid);
    } 
In command i need to put this, but don't know where exactly:
PHP код:
new PlayerClosest NearestPlayerNode(playerid); 
    new 
TempDestination NearestNodeFromPoint(X,Y,Z); 
    
    if(
PlayerClosest == TempDestination
            
            return 
1;
    }
    if(
PlayerClosest == -1
        
        return 
1;
    }
    if(
TempDestination == -1
        return 
1;
    }
    if(
CalculatePath(PlayerClosest,TempDestination,playerid, .GrabNodePositions true)) 
        
PlayerRoute[playerid][calculating] = true;
    
        }
    else {if 
error shows...
        
SendClientMessage(playerid,"error please try again.");
    }
    return 
1;

On Bottom:
PHP код:
public OnPlayerClosestNodeIDChange(playerid,old_NodeID,new_NodeID
    if(
new_NodeID != -1)
        if(
PlayerRoute[playerid][Destination] == new_NodeID) {
            
DisableGPS(playerid);
        }
    }
    return 
1;

Also on Bottom:
PHP код:
public GPS_WhenRouteIsCalculated(routeid,node_id_array[],amount_of_nodes,Float:distance,Float:Polygon[],Polygon_Size,Float:NodePosX[],Float:NodePosY[],Float:NodePosZ[])
{
    
PlayerRoute[routeid][calculating] = false
    if(
amount_of_nodes 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); 
        }
        
PlayerRoute[routeid][Lenght] = amount_of_nodes
        
PlayerRoute[routeid][Destination] = node_id_array[amount_of_nodes-1]; 
        
gps_AddPlayer(routeid); 
        }
    
smthing goes here
    
}
    return 
1;

We're still on Bottom, remember?
PHP код:
forward DisableGPS(playerid); 
public 
DisableGPS(playerid)//iskljucivanje GPS
{
    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;

Reply
#2

Does anyone have tips/tutorials how to use gamer_z plugin for routeconnector? I've tried to search the forums but so far all links down.
Give rep for help!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)