Walter-Correa/GPS-Plugin-Plus
Modern and feature-rich pathfinding plugin for SA-MP and Open.MP.
Instalar com o sampctl
sampctl package install Walter-Correa/GPS-Plugin-Plus
Execute na pasta do seu projeto. O sampctl baixa o pacote e as dependências dele.
Adiciona os arquivos de include dele, com as bibliotecas de que depende, ao compilador Pawn no seu navegador, prontos para incluir num script.
Depende de 1 pacote
- sampctl/samp-stdlibnão está neste diretório
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 / Capability | Legacy GPS Plugin (Amyr Ahmady) | GPS Plugin Plus |
|---|---|---|
| Platform Architecture | SA-MP plugin wrapper only | ✅ Native open.mp Component (GPS-Component-Plus) + SA-MP Plugin (GPS-Plugin-Plus) |
| Asynchronous Engine | Tick-blocking synchronous execution or basic thread | ✅ Multi-threaded C++ worker pool + PawnPlus task promises (task_await(FindPathAsync) / await) |
| Transport Modalities | Vehicles only | ✅ Unified multi-modal routing (PathType): Vehicles, Pedestrians, and Boats |
| Route Preferences | Distance 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 & Roadblocks | Static unmodifiable node graph | ✅ Real-time edge traffic multipliers (SetConnectionTrafficMultiplier) and dynamic roadblocks |
| Route Geometry & Smoothing | Piecewise 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 Queries | Linear distance checks | ✅ Anti-Euclidean nearest service by real road distance (FindNearestPointByRoad) |
| Roadside Snapping & Alignment | Snaps 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 & Serialization | Manual 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:
| Guide | Description |
|---|---|
| 📖 Getting Started | Step-by-step setup, installation for SA-MP & open.mp, GPS.dat configuration, and drop-in migration. |
| 🗺️ Pathfinding & Routing | Synchronous vs. threaded execution, PawnPlus async tasks, multi-modal routing, roadblocks, and traffic congestion. |
| 🧭 Navigation & Geometry | Real-time GPS tracking, turn-by-turn guidance, roundabout detection, Catmull-Rom splines, and route decimation. |
| 🤖 AI & Traffic Simulation | Pure Pursuit bot steering, police intercept vectors, fugitive evasion, speed radars, and real road-distance queries. |
| 📍 Map Nodes & Spatial Analytics | Map node graph lifecycle, multi-lane roads, curb-side alignment, neighborhood zones, and path serialization. |
| 📚 Complete API Reference | Exhaustive 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.dllLinux:
plugins GPS.soopen.mp (
config.json):- Option A: Native open.mp Component (Recommended):
Place
GPS.dll(orGPS.so) into your server'scomponents/directory. Open.mp automatically detects and loads all components incomponents/; no entry inconfig.jsonis required. - Option B: Legacy Plugin Mode:
Place
GPS.dll(orGPS.so) intoplugins/and add it toconfig.json:{ "pawn": { "legacy_plugins": ["GPS"] } }
- Option A: Native open.mp Component (Recommended):
Place
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:
- Map Node Management:
CreateMapNode,DestroyMapNode,IsValidMapNode,GetMapNodePos,GetRandomMapNode... - Road Connections & Lanes:
CreateConnection,GetConnectionLaneInfo,GetConnectionLanePos,IsConnectionOneWay... - Spatial Queries & Snapping:
GetClosestMapNodeToPoint,GetClosestPointOnRoad,GetRoadPositionInfo,IsPointInValidRoad/IsPointInValidRoadEx... - Pathfinding & Routing:
FindPath,FindPathThreadedEx,FindMultiStopPath,FindPathForVehicleCat... - Dynamic Traffic & Roadblocks:
SetMapNodeBlocked,SetConnectionBlocked,SetConnectionTrafficMultiplier... - Turn-by-Turn Navigation & Tracking:
GetPathProgress,GetPathRemainingInfo,GetPathNextManeuver... - Route Geometry & Splines:
GetSimplifiedPathNodes,GetSmoothPathPoints,GetPathOffsetPosition... - Autonomous AI, Interception & Evasion:
GetPurePursuitSteering,FindInterceptPath,FindEvasivePath... - Radars, Isochrones & Nearest Service:
FindNearestPointByRoad,RegisterRoadRadar,GetReachableMapNodes... - Tunnels, Danger & Elevation:
RegisterTunnelArea,FindSafePath,FindEcoPath,GetPathElevationStats... - Road Characteristics & Speed Limits:
GetConnectionRoadClass,SetConnectionSpeedLimit,IsConnectionPaved... - Height Clearances & Vehicle Categories:
SetConnectionMaxHeight,FindPathWithHeightLimit... - Path Serialization & Persistence:
SetPathAutoDestroy,SavePathToFile,ExportPathToString... - San Andreas Geographic Zones:
GetPointZoneName,GetMapNodeZoneName,GetPathZonesSummary... - PawnPlus Asynchronous Tasks:
FindPathAsync,FindPathAsyncEx... - Constants, Enums & Error Codes:
GPS_ERROR,PathType,RoutePreference,TurnDirection...
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
--recursiveor rungit submodule update --init --recursiveto fetchopen.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)andIsPointInValidRoadEx(..., &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, clampedtin[0, 1]) and withinmax_z_diffof the linearly interpolated roadbed elevationqz. - Uses dynamic spatial search radius bounds (
max_connection_length * 0.5 + max_road_width * 0.5 + radius + 1.0) tracked inContainer::Connections::Addso 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. IsPointInValidRoadreturns immediately on the first matching connection (early exit, zero AMX heap allocation), whileIsPointInValidRoadExevaluates all matching candidates and returns theConnectionwith minimum normalized lateral deviation.
- Checks whether a world coordinate lies inside any eligible road connection's capsule (
2.1.0 — 14/11/2026
- Accurate GTA SA One-Way Orientation & Lane Geometry Overhaul:
- Regenerated
GPS.datfrom retail GTA San AndreasNODES*.DATusing real5.4 mlane width, navi-derived median gap (width / 16.0), edge-orientedleft_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
Connectionlane offset geometry (GetConnectionLanePoswith0= 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
FindClosestRoadPointspatial grid lookup (30 m -> 80 mmulti-node candidate radius) and fixedIsPointAgainstTraffic(one-way orientation, divided median exclusion, off-road threshold) andGetRoadPositionInfo(ROAD_POS_CURBvsROAD_POS_EDGEswap & legal flow heading). - Added new natives
IsConnectionWrongWay,GetClosestMapNodeToPointAngle, andGetPathLaneTarget(mitered right-lane target + lookahead + signedlateral_error), and updatedGetPurePursuitSteeringto 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.0xpenalty when traversing one-way edges in reverse (IsConnectionWrongWay); inGetReachableMapNodes, distance and time budgets include this penalty on wrong-way edges. GetConnectionLanePosuses real5.4 mlane widths with index0as the leftmost travel lane in flow direction and centered carriageways on one-way roads.GetClosestPointOnRoadreturns the legal flow angle along the road and resolves curb offset on the legal side.IsPointAgainstTrafficreturnsfalsewhen off-road or over a divided median.GetConnectionRoadClassand default road speed limits derive from the updated lane-width and median geometry, so classifications may differ from 2.0.0.GetPurePursuitSteeringtracks the rightmost travel lane centerline instead of the raw center node line.- All vehicle connections start as paved (
true) by default becauseGPS.dathas no surface flag (useSetConnectionPaved(conn, false)to mark unpaved roads). bool:natives return0(false) instead of-5(GPS_ERROR_INTERNAL) if an internal C++ exception occurs, and exception logs include the failing native name.
- All route and reachability searches now apply a
- Regenerated
gpsgps-plugingta-sanavigationnodesopen-mpopenmppathfindingpawnroute-creatorroute-plannersa-mpsa-mp-pluginsampwaze
Esta página é montada com o que o GitHub publica sobre o repositório. O samp.directory não hospeda o código. Avisar de um problema com esta página