samp.directory
← Scripts and libraries

Walter-Correa/GPS-Plugin-Plus

Modern and feature-rich pathfinding plugin for SA-MP and Open.MP.

Plugin★ 1updated 19 days agoOtherC++sampctl
Open on GitHub

Install with sampctl

sampctl package install Walter-Correa/GPS-Plugin-Plus

Run this in your project folder. sampctl downloads the package and what it depends on.

Try it in the Pawn compiler →

Adds its include files, with the libraries it depends on, to the Pawn compiler in your browser, ready to include in a script.

Depends on 1 package

README.md

GPS Plugin Plus

GPS Plugin Plus is a high-performance, multi-threaded pathfinding, real-time navigation, autonomous NPC vehicle steering, and spatial analysis suite engineered specifically for San Andreas Multiplayer (SA-MP) and open.mp.

It empowers Pawn developers to build intelligent, state-of-the-art navigation systems: Threaded A* Route Calculations, Real-Time Turn-by-Turn Maneuvers, Catmull-Rom Spline Curve Smoothing, Douglas-Peucker Route Decimation, Autonomous Pure Pursuit Bot Steering, High-Speed Police Intercept Vectors, Dynamic Traffic Jams & Roadblocks, Waze-Style Speed Radars, and Nearest Service Queries by Real Road Distance—with full asynchronous worker thread support (zero server tick lag on threaded queries) and drop-in compatibility.

[!NOTE] This project is conceptually inspired by the original samp-gps-plugin by @kristoisberg and its fork by @AmyrAhmady. It has been completely re-architected and modernized from the ground up, introducing dual-stack architecture (native open.mp Component + SA-MP Plugin), a native multi-threaded C++ worker pool, PawnPlus task async coroutines, multi-modal routing (vehicles, pedestrians, boats), and 114+ high-performance spatial natives.


Comparison: Legacy GPS Plugin vs. GPS Plugin Plus

Feature / CapabilityLegacy GPS Plugin (Amyr Ahmady)GPS Plugin Plus
Platform ArchitectureSA-MP plugin wrapper only✅ Native open.mp Component (GPS-Component-Plus) + SA-MP Plugin (GPS-Plugin-Plus)
Asynchronous EngineTick-blocking synchronous execution or basic thread✅ Multi-threaded C++ worker pool + PawnPlus task promises (task_await(FindPathAsync) / await)
Transport ModalitiesVehicles only✅ Unified multi-modal routing (PathType): Vehicles, Pedestrians, and Boats
Route PreferencesDistance only✅ 8 heuristics: Shortest, Highway, Avoid Highway, Safest, Eco, Evasive, Toll-Free, Paved Only
Turn-by-Turn Navigation❌ None✅ Built-in tracker (GetPathProgress, GetPathNextManeuver) with 7 turn directions & distance
Autonomous Bot Steering❌ None✅ Built-in Pure Pursuit controller calculating lookahead steering ratios ($-1.0$ to $+1.0$) and cornering speed
Dynamic Traffic & RoadblocksStatic unmodifiable node graph✅ Real-time edge traffic multipliers (SetConnectionTrafficMultiplier) and dynamic roadblocks
Route Geometry & SmoothingPiecewise jagged polygon lines✅ Catmull-Rom cubic spline densification (GetSmoothPathPoints) for smooth NPC driving
Route Decimation❌ None✅ Douglas-Peucker route decimation (GetSimplifiedPathNodes) reducing node bandwidth by up to 90%
Roundabout Analysis❌ None✅ Automatic rotary detection, radius calculation, and exit counting ("Take the 2nd exit")
Law Enforcement AI❌ None✅ Dynamic police intercept vectors (FindInterceptPath) cutting off suspects ahead of time
Tactical Evasion AI❌ None✅ Fugitive anti-dead-end routing (FindEvasivePath, IsMapNodeDeadEnd) avoiding traps
Spatial Proximity QueriesLinear distance checks✅ Anti-Euclidean nearest service by real road distance (FindNearestPointByRoad)
Roadside Snapping & AlignmentSnaps to road center✅ Curb-side alignment (GetRoadPositionInfo) for parked vehicles and mechanic missions
Speed Radars & Hazard Alerts❌ None✅ Waze-style road radar detector (RegisterRoadRadar, GetNextPathRadar)
Vehicle Physical Limits❌ None✅ Bridge clearance limits (SetConnectionMaxHeight) & vehicle categories (VehicleCategory)
Memory & SerializationManual deletion only✅ Automatic TTL garbage collection (SetPathAutoDestroy) and plain-text path file/string import/export

Documentation Hub

Comprehensive, modular guides and technical references are available in the docs/ directory:

GuideDescription
📖 Getting StartedStep-by-step setup, installation for SA-MP & open.mp, GPS.dat configuration, and drop-in migration.
🗺️ Pathfinding & RoutingSynchronous vs. threaded execution, PawnPlus async tasks, multi-modal routing, roadblocks, and traffic congestion.
🧭 Navigation & GeometryReal-time GPS tracking, turn-by-turn guidance, roundabout detection, Catmull-Rom splines, and route decimation.
🤖 AI & Traffic SimulationPure Pursuit bot steering, police intercept vectors, fugitive evasion, speed radars, and real road-distance queries.
📍 Map Nodes & Spatial AnalyticsMap node graph lifecycle, multi-lane roads, curb-side alignment, neighborhood zones, and path serialization.
📚 Complete API ReferenceExhaustive technical dictionary covering all 114 native functions, callbacks, enums, and error codes.

Quick Start & Installation

1. File Placement

Place the binaries, database, and include header into your server development environment:

[Server Root]/
  ├── plugins/
  │     └── GPS.dll             (or GPS.so on Linux)
  ├── components/               (Optional: open.mp native component)
  │     └── GPS.dll             (or GPS.so on Linux)
  ├── pawno/include/            (or qawno/include/)
  │     └── GPS.inc
  └── scriptfiles/
        └── GPS.dat             <-- MANDATORY: Node database

2. Server Configuration

Install either the SA-MP plugin in plugins/ or the open.mp component in components/ (do not install both simultaneously).

  • SA-MP (server.cfg): Windows:

    plugins GPS.dll
    

    Linux:

    plugins GPS.so
    
  • open.mp (config.json):

    • Option A: Native open.mp Component (Recommended): Place GPS.dll (or GPS.so) into your server's components/ directory. Open.mp automatically detects and loads all components in components/; no entry in config.json is required.
    • Option B: Legacy Plugin Mode: Place GPS.dll (or GPS.so) into plugins/ and add it to config.json:
      {
        "pawn": {
          "legacy_plugins": ["GPS"]
        }
      }
      

3. Include in Your Script

#include <open.mp> // Or <a_samp>
#include <GPS>

4. Basic Example

Compute a high-speed highway route and track navigation in real time:

new Path:g_PlayerRoute[MAX_PLAYERS] = { INVALID_GPS_PATH_ID, ... };

CMD:navigate(playerid, params[])
{
    new Float:px, Float:py, Float:pz;
    GetPlayerPos(playerid, px, py, pz);

    new MapNode:start_node, MapNode:dest_node;
    GetClosestMapNodeToPoint(px, py, pz, start_node);
    GetClosestMapNodeToPoint(2232.0, 2452.0, 10.8, dest_node); // Las Venturas Strip

    // Compute route asynchronously on native worker thread
    FindPathThreadedEx(
        start_node, dest_node,
        PATH_TYPE_VEHICLE, ROUTE_PREF_HIGHWAYS,
        "OnPlayerRouteReady", "i", playerid
    );
    return 1;
}

forward OnPlayerRouteReady(Path:path, playerid);
public OnPlayerRouteReady(Path:path, playerid)
{
    if (!IsValidPath(path)) return SendClientMessage(playerid, 0xE74C3CAA, "[GPS] No route found.");

    g_PlayerRoute[playerid] = path;

    new Float:dist, Float:eta;
    GetPathLength(path, dist);
    GetPathEstimatedTravelTime(path, 80.0, eta);

    new msg[128];
    format(msg, sizeof(msg), "[GPS] Route calculated! Distance: %.1f km | ETA: %.1f minutes", dist / 1000.0, eta / 60.0);
    SendClientMessage(playerid, 0x2ECC71AA, msg);

    // Auto-destroy path from memory after 5 minutes (absolute TTL)
    SetPathAutoDestroy(path, 300000);
    return 1;
}

[!TIP] Need to migrate an existing gamemode from Amyr Ahmady's GPS Plugin? Read the Migration Guide in docs/getting-started.md for instant 1:1 drop-in compatibility.


Complete API Reference

All 114 native functions, callbacks, style enumerations, and constants are exhaustively documented with signature parameters, return values, and code snippets in docs/api-reference.md:


Building from Source

Prerequisites

  • CMake 3.15+
  • Visual Studio 2022 (Windows) with Desktop C++ workload
  • GCC / G++ 9+ with 32-bit multilib (gcc-multilib g++-multilib) (Linux)
  • Git submodules: clone with --recursive or run git submodule update --init --recursive to fetch open.mp-sdk (required for building the open.mp component).

Compiling on Windows (1-Click Script)

Run the provided automated build script:

build_msvc.bat

(Automatically configures CMake for Win32, compiles Release binaries, stages packages, and builds dist/GPS-Plugin-Plus-Windows.zip).

Compiling on Linux

mkdir -p build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-m32" -DCMAKE_CXX_FLAGS="-m32"
make -j$(nproc)

Version history

Show the version history

2.2.0 — 16/11/2026

  • Added IsPointInValidRoad(Float:x, Float:y, Float:z, Float:radius = 0.0, PathType:type = PATH_TYPE_VEHICLE, Float:max_z_diff = 4.0) and IsPointInValidRoadEx(..., &Connection:connectionid = INVALID_CONNECTION_ID):
    • Checks whether a world coordinate lies inside any eligible road connection's capsule (2D distance <= road_width * 0.5 + radius, clamped t in [0, 1]) and within max_z_diff of the linearly interpolated roadbed elevation qz.
    • Uses dynamic spatial search radius bounds (max_connection_length * 0.5 + max_road_width * 0.5 + radius + 1.0) tracked in Container::Connections::Add so long road segments (e.g., 60+ m from either endpoint node) are never missed.
    • Evaluates vertical clearance (max_z_diff) per candidate to distinguish overpasses/viaducts from lower roads and handles parallel streets of varying widths.
    • IsPointInValidRoad returns immediately on the first matching connection (early exit, zero AMX heap allocation), while IsPointInValidRoadEx evaluates all matching candidates and returns the Connection with minimum normalized lateral deviation.

2.1.0 — 14/11/2026

  • Accurate GTA SA One-Way Orientation & Lane Geometry Overhaul:
    • Regenerated GPS.dat from retail GTA San Andreas NODES*.DAT using real 5.4 m lane width, navi-derived median gap (width / 16.0), edge-oriented left_lanes/right_lanes, and (source, target) edge deduplication (enforced on load too).
    • Built-in 25.0x wrong-way pathfinding penalty across all routing/reachability/nearest-road searches for one-way streets in reverse (IsConnectionWrongWay), preventing wrong-way shortcuts while preserving fallback escape routes.
    • Updated Connection lane offset geometry (GetConnectionLanePos with 0 = leftmost, n-1 = rightmost in travel direction; divided median support; one-way carriageway centering), road class heuristics, narrow-road checks, and default paved status for vehicle roads.
    • Improved FindClosestRoadPoint spatial grid lookup (30 m -> 80 m multi-node candidate radius) and fixed IsPointAgainstTraffic (one-way orientation, divided median exclusion, off-road threshold) and GetRoadPositionInfo (ROAD_POS_CURB vs ROAD_POS_EDGE swap & legal flow heading).
    • Added new natives IsConnectionWrongWay, GetClosestMapNodeToPointAngle, and GetPathLaneTarget (mitered right-lane target + lookahead + signed lateral_error), and updated GetPurePursuitSteering to track the vehicle lane line.
    • Added Phase 2 & 3 autopilot, ETA, and routing primitives: connected-component filtering, stop-point truncation (FindPathToPoint, IsPathStopReached), predictive Menger curvature and terminal braking (GetPathSpeedAdvice), longitudinal road elevation/slope profiling (GetPathRoadProfile), and physics-aware remaining ETA estimation (GetPathTimeEstimate).
    • Behavior changes (same API):
      • All route and reachability searches now apply a 25.0x penalty when traversing one-way edges in reverse (IsConnectionWrongWay); in GetReachableMapNodes, distance and time budgets include this penalty on wrong-way edges.
      • GetConnectionLanePos uses real 5.4 m lane widths with index 0 as the leftmost travel lane in flow direction and centered carriageways on one-way roads.
      • GetClosestPointOnRoad returns the legal flow angle along the road and resolves curb offset on the legal side.
      • IsPointAgainstTraffic returns false when off-road or over a divided median.
      • GetConnectionRoadClass and default road speed limits derive from the updated lane-width and median geometry, so classifications may differ from 2.0.0.
      • GetPurePursuitSteering tracks the rightmost travel lane centerline instead of the raw center node line.
      • All vehicle connections start as paved (true) by default because GPS.dat has no surface flag (use SetConnectionPaved(conn, false) to mark unpaved roads).
      • bool: natives return 0 (false) instead of -5 (GPS_ERROR_INTERNAL) if an internal C++ exception occurs, and exception logs include the failing native name.

Read the rest on GitHub

gpsgps-plugingta-sanavigationnodesopen-mpopenmppathfindingpawnroute-creatorroute-plannersa-mpsa-mp-pluginsampwaze

This page is built from what GitHub publishes about the repository. samp.directory does not host the code. Report a problem with this listing

Walter-Correa/GPS-Plugin-Plus: SA-MP Plugin | samp.directory