derrick0930/Custom-Vehicle-Samp
Custom vehicle models for SA-MP 0.3.7: server plugin, client ASI and Pawn include.
Ajoute ses fichiers include, avec les bibliothèques dont il dépend, au compilateur Pawn de ton navigateur, prêts à être inclus dans un script.
README.md
Custom Vehicle Skin
Server-delivered custom vehicle models for all SA-MP versions.
Table of contents
- Preview
- Overview
- How it works
- Repository structure
- Requirements
- Building
- Installation
- Usage
- API reference
- Limits and assumptions
- Troubleshooting
- Reporting issues
- Acknowledgements
Preview
Overview
| Component | Output | Purpose |
|---|---|---|
Server plugin (server/) | cvs.dll / cvs.so | Registers and validates models (.dff, .txd, .ifp, model.ini folders), serves them over HTTP, coordinates OnPlayerConnect gating, and tracks download completion |
Client plugin (client/) | vehskin.asi | Waits for OnPlayerConnect, renders a modern ImGui-style download table overlay, caches models, applies custom models/wheels/mudguards/lights, and swaps custom .ifp animations |
Gamemode include (example/) | cvs.inc | Pawn API used to gate OnPlayerConnect before login, create/track custom vehicles, and fire OnPlayerCVSDownloadFinish |
Key features:
- Custom vehicle appearance with the handling and physics of a standard base vehicle (model IDs 400 to 611).
- Built-in HTTP file server that shares the same port number as the game server, so no extra port is needed.
- Download-once caching on the client, keyed by server address and port, with fast metadata verification (
.meta) so returning players skip the download screen and go straight to login. - Modern client-side download table overlay (Direct3D9 + GDI+): clean dark rounded card with
TYPE,FILE,PROGRESS(0%–100%), speed (KB/s), and overall progress bar — no intrusiveDIALOG_STYLE_TABLIST_HEADERSdialog. - Built-in Custom Models panel (
F3hotkey directly invehskin.asifor all SA-MP versions): unlocks a free mouse cursor, supports mouse wheel /Up/Downscrolling, top-rightXclose button, and displays every registered custom model ID, file name, base ID, total size, andREADY/MISSINGstatus. OnPlayerConnectsynchronization: the download overlay appears only afterOnPlayerConnectfires (not during the SA-MP loading screen), and server login/account systems can wait forOnPlayerCVSDownloadFinish.- Per-vehicle application, so custom and standard vehicles can coexist freely.
- Custom animations: an optional
.ifpfile per model (GTA: SAANP3format) replaces the rider animations of custom motorbikes. - Model folders: each model can live in its own
models/<id>/folder described by amodel.inifile, loaded in one call withCVS_LoadModels. - Per-model tuning in
model.ini: headlight, taillight, and wheel/mudguard position offsets. - Pure Pawn API with a single include file, plus a ready-to-run example gamemode.
How it works
- The gamemode registers each custom model, either with
CVS_AddModel(custom ID, base vehicle ID and a pair of files in the servermodels/folder) or in bulk withCVS_LoadModels, which readsmodels/<id>/model.inifolders. An optional.ifpanimation file is attached withCVS_SetModelAnimor theIFPkey ofmodel.ini. CVS_Startstarts the HTTP file server on the game server's TCP port. The server exposes/connect,/manifest,/vehicles,/files/<name>, and/progress.- When a player joins,
OnPlayerConnectcallsCVS_StartPlayerDownload(playerid)at the very top (before login/account systems).vehskin.asipolls/connectso nothing appears during the SA-MP loading screen; as soon asOnPlayerConnectsignals ready, the client fetches/manifest, displays the modern download table overlay, downloads any missing or changed files (.dff,.txd,.ifp), and notifies/progresswhen done soOnPlayerCVSDownloadFinish(playerid)runs the login flow. - Vehicles created with
CVS_CreateVehicleare spawned using the base vehicle ID. The plugin keeps track of their custom model and position, and the client swaps in the custom model for those vehicles only. If the model has an.ifp, the client also swaps in the custom rider animations while the player is on, or next to, that vehicle.
Repository structure
CustomVehicle/
|-- client/
| |-- main.cpp Client plugin source (vehskin.asi)
| `-- build.ps1 Legacy build script
|-- server/
| |-- main.cpp Server plugin source (cvs.dll / cvs.so)
| `-- sdk/ SA-MP plugin SDK headers and sources
|-- example/
| |-- cvs.inc Pawn include (copy to pawno/include)
| `-- example.pwn Example gamemode with the /vehmodel command
|-- docs/ Images used by this README
|-- models/ Place your .dff, .txd and .ifp files here (ignored by Git)
|-- dist/ Build output (ignored by Git)
|-- build-windows.sh Builds cvs.dll and vehskin.asi into dist/ (clang, Windows)
|-- build-linux.sh Builds cvs.so into dist/ (Zig, Linux)
|-- .gitattributes
|-- .gitignore
`-- README.md
Requirements
Build tools (Windows)
These are needed for build-windows.sh, which builds cvs.dll and vehskin.asi.
| Requirement | Notes |
|---|---|
| Windows 10 or later | Required to build the Windows plugins and to run the client |
| Git for Windows | Provides git and Git Bash, which runs build-windows.sh (an MSYS2 shell also works) |
Clang (clang++) or MinGW-w64 g++ | Must target 32-bit i686-w64-windows-gnu / i686-w64-mingw32. Both SA-MP and GTA: San Andreas are 32-bit, so a 64-bit target will not work |
| MinGW-w64 runtime for i686 | Headers, import libraries (winhttp, d3d9, gdi32, gdiplus, ws2_32) and static winpthread |
| SA-MP server package | Supplies pawno (the Pawn compiler) for the example gamemode |
zcmd.inc | Only needed to compile example/example.pwn |
Confirm that the compiler is available:
clang++ --version
Build tools (Linux / cross-compile)
These are needed for build-linux.sh (or compiling cvs.so from Windows with Zig). The client plugin (vehskin.asi) is Windows only.
| Requirement | Notes |
|---|---|
| Linux (x86-64 or x86) or Windows | The 32-bit ELF target is cross-compiled by Zig, so no 32-bit system libraries are needed |
| Zig | Version 0.11 or newer, from https://ziglang.org/download/. zig must be in PATH. Zig bundles its own clang, libc headers and libc++, so no separate gcc, clang or multilib packages are required |
| Bash | Runs build-linux.sh |
Confirm that Zig is available:
zig version
Runtime
| Side | Requirement |
|---|---|
| Server | SA-MP server (all versions) for Windows (cvs.dll), or Linux (cvs.so, beta) |
| Client | SA-MP (all versions) with GTA: San Andreas 1.0 (US) and an ASI loader, such as Ultimate ASI Loader |
| Network | The game server port must be open for both UDP (game traffic) and TCP (model downloads) |
Building
The build is split into one script per platform. Both write their output to dist/.
| Script | Platform | Compiler | Output |
|---|---|---|---|
build-windows.sh | Windows (Git Bash or MSYS2) | clang++ | dist/cvs.dll, dist/vehskin.asi |
build-linux.sh | Linux (or Windows with Zig) | zig c++ | dist/cvs.so |
Windows
build-windows.sh compiles the server plugin and the client plugin in one go.
Install the build tools listed under Build tools (Windows), including Git for Windows.
Open Git Bash and download the project:
git clone https://github.com/derrick0930/Costum-Vehicle-Samp.git cd Costum-Vehicle-SampIf you downloaded a ZIP instead, extract it and run
cdinto the extracted folder (for examplecd CustomVehicle).Check that the compiler is found:
clang++ --versionRun the build script:
./build-windows.shIf the script is not executable on your system, run
bash build-windows.shinstead. From PowerShell, usebash .\build-windows.sh. Note thatvehskin.asilinks-lwinhttp -ld3d9 -lgdi32 -lgdiplus.Collect the results from the
dist/folder:File Goes to dist/cvs.dllThe plugins/folder of your SA-MP serverdist/vehskin.asiThe GTA: San Andreas folder on each player's PC
| Command | Action |
|---|---|
./build-windows.sh | Builds the server plugin and the client plugin |
./build-windows.sh server | Builds only dist/cvs.dll |
./build-windows.sh client | Builds only dist/vehskin.asi |
./build-windows.sh clean | Removes cvs.dll and vehskin.asi from dist/ |
The script stops at the first error. To use a different compiler, set CXX, for example CXX=/c/llvm/bin/clang++ ./build-windows.sh.
Linux
build-linux.sh builds the 32-bit SA-MP server plugin with Zig.
Install Zig as described under Build tools (Linux) and check it with
zig version.From the project folder, run:
./build-linux.shIf the script is not executable, run
bash build-linux.shinstead.Copy
dist/cvs.soto theplugins/folder of your SA-MP Linux server.
| Command | Action |
|---|---|
./build-linux.sh | Builds dist/cvs.so (same as ./build-linux.sh build) |
./build-linux.sh clean | Removes dist/cvs.so |
The script stops at the first error. It reads two optional environment variables:
| Variable | Default | Purpose |
|---|---|---|
ZIG | zig | Path to the Zig executable, for example ZIG=/opt/zig/zig ./build-linux.sh |
TARGET | x86-linux-gnu.2.17 | Zig target triple. The .2.17 suffix sets the minimum glibc version, so the plugin also loads on older distributions. Raise or lower it if your server needs a different glibc |
To verify the result:
file dist/cvs.so # should say: ELF 32-bit LSB shared object, Intel 80386
readelf -d dist/cvs.so | grep NEEDED # should not list libstdc++.so.6
Installation
Server
Copy
dist/cvs.dllto theplugins/folder of your SA-MP server.Add the plugin to
server.cfg:plugins cvsCopy
example/cvs.inctopawno/include/.Create a
models/folder in the server root (next tosamp-server.exe) and place your.dff,.txdand optional.ifpfiles in it, either directly or inmodels/<id>/sub-folders (see Model folders and model.ini).Open the game port for TCP as well as UDP in your firewall.
Linux server (beta)
A .so build of the server plugin is released for SA-MP Linux servers. It is still in beta. If you find an error, please open an issue (see Reporting issues).
Download
cvs.sofrom the Releases page, or build it yourself with./build-linux.sh(see Building), and copy it to theplugins/folder of your server.Add the plugin to
server.cfg:plugins cvs.soFollow steps 3 to 5 of the Server section. The
models/folder goes in the server root (note that Linux file names are case-sensitive), and players still usevehskin.asi.
Client
- Copy
dist/vehskin.asito the GTA: San Andreas installation folder, next togta_sa.exe. - Make sure an ASI loader is installed.
- Connect through the SA-MP launcher. The client reads the server address and port from the launcher arguments, so connecting through unusual methods that skip them is not supported.
Cached files (.dff, .txd and .ifp) are stored in Documents\GTA San Andreas User Files\SAMP\cvs_cache\, in one sub-folder per server address and port. A file is downloaded again only when its size or checksum differs from the server's.
Usage
Register models and start the file server in OnGameModeInit, then create vehicles with CVS_CreateVehicle:
#include <a_samp>
#include "cvs"
public OnGameModeInit()
{
CVS_AddModel(20001, 411, "infernus_red.dff", "infernus_red.txd");
CVS_AddModel(20002, 451, "turismo_gold.dff", "turismo_gold.txd");
CVS_Start();
return 1;
}
Create and remove vehicles:
new vehicleid = CVS_CreateVehicle(20001, x, y, z, angle);
CVS_DestroyVehicle(vehicleid);
The file names passed to CVS_AddModel are resolved inside the server models/ folder. The .dff, .txd and .ifp names must be plain file names (no paths) and must differ from each other. Files are looked up by name when a client downloads them, so every file name must be unique across all models: two models cannot both use a file called model.dff.
Model folders and model.ini
Instead of one CVS_AddModel call per model, put each model in its own folder named after its custom ID and call CVS_LoadModels() once, before CVS_Start:
models/
|-- 20001/
| |-- model.ini
| |-- huracan.dff
| `-- huracan.txd
`-- 20003/
|-- model.ini
|-- chopper.dff
|-- chopper.txd
`-- chopper.ifp
model.ini:
[Model]
Name=Chopper
VisualBase=463
DFF=chopper.dff
TXD=chopper.txd
IFP=chopper.ifp
[Lighting]
HeadlightOffsetX=0.0
HeadlightOffsetY=0.0
HeadlightOffsetZ=0.0
TaillightOffsetX=0.0
TaillightOffsetY=0.0
TaillightOffsetZ=0.0
[Offsets]
FrontWheelOffsetY=0.0
FrontWheelOffsetZ=0.0
RearWheelOffsetY=0.0
RearWheelOffsetZ=0.0
| Key | Meaning |
|---|---|
Name | Display name of the model (informational) |
VisualBase (or Base) | Base vehicle ID, 400 to 611. The vehicle keeps this vehicle's handling and physics |
DFF, TXD | Model and texture file names, in the same folder |
IFP | Optional animation file in the same folder. If it is missing or unreadable, the model loads without it |
HeadlightOffset*, TaillightOffset* | Added to the headlight and taillight positions of the base vehicle |
FrontWheelOffsetY/Z, RearWheelOffsetY/Z | Added to the front wheel (and mudguard on bikes) and rear wheel positions of the base vehicle |
Lines starting with # or ; are comments and every offset defaults to 0.0. The folder name is the custom ID (20001 to 30000). A folder is skipped, and a message is written to the server log, when model.ini is missing, the base or file names are invalid, or the .dff or .txd is not found. A model that was already registered with CVS_AddModel is not replaced. CVS_LoadModels returns the number of models loaded.
Custom animations (IFP)
A model can ship a custom .ifp animation file. Attach it in model.ini with the IFP key, or in Pawn after registering the model:
CVS_AddModel(20003, 463, "chopper.dff", "chopper.txd");
CVS_SetModelAnim(20003, "chopper.ifp");
Requirements and behaviour:
- The file must be a GTA: San Andreas
ANP3animation file placed in the servermodels/folder (or the model's folder). Files in another format are ignored and a message is written to the client log. - Animations are matched by name against the originals, so the
.ifpshould contain animations with the same names as the standard bike animations it replaces. - The custom animations replace the rider animations of the bike groups (
bike*andchoppa) viaCAnimBlendStaticAssociation::Init, preserving the original sequence arrays when restored. They are active while the player is on a custom vehicle that has an.ifp, or standing within about 4 metres of one (for mounting/dismounting), and the default animations are restored afterwards. - The
.ifpis downloaded and cached like the.dffand.txd.
Download progress overlay and login flow
When a player connects, the client renders a modern ImGui-style download table overlay directly in-game (showing TYPE, FILE, PROGRESS 0%–100%, download speed in KB/s, and an overall progress bar). DIALOG_STYLE_TABLIST_HEADERS is no longer shown.
To ensure the overlay only appears on OnPlayerConnect (not during the SA-MP loading screen) and that model downloads finish before your login/account system runs:
public OnPlayerConnect(playerid)
{
if (IsPlayerNPC(playerid)) return 1;
// Gate login/server systems until model download or cache check finishes
CVS_StartPlayerDownload(playerid);
TogglePlayerSpectating(playerid, true);
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
CVS_ClearPlayerDownload(playerid);
return 1;
}
forward OnPlayerCVSDownloadFinish(playerid);
public OnPlayerCVSDownloadFinish(playerid)
{
// Start your account check / login dialog here
return 1;
}
CVS_StartPlayerDownload(playerid) records the player's initial connection name (so CVS_ClearPlayerDownload(playerid) still cleans it up properly even if your login system renames the player to a roleplay character name). If all models are already cached on the client, the download table is skipped and OnPlayerCVSDownloadFinish(playerid) fires immediately.
Players can press F3 at any time in-game (handled directly by vehskin.asi across all SA-MP versions, no Pawn script required) to toggle the interactive Custom Models panel showing each model's ID, file name, base ID, size, and READY status. While open, the cursor is unlocked so you can scroll with the mouse wheel (or Up/Down) and close via the top-right X button or by pressing F3 again.
Example gamemode
example/example.pwn registers sample models, loads any models/<id>/model.ini folders, integrates CVS_StartPlayerDownload / CVS_ClearPlayerDownload / OnPlayerCVSDownloadFinish, and provides test commands:
| Command / Key | Result |
|---|---|
/vehmodel 411 | Spawns a standard Infernus with its original model |
/vehmodel 20001 | Spawns the custom model 20001, using Infernus (411) as its base |
F3 | Opens or closes the interactive Custom Models panel |
Compile it with pawno after placing zcmd.inc and cvs.inc in pawno/include/.
API reference
asifilterscriptfilterscriptspawnpluginpluginssa-mpsa-mp-developmentsa-mp-pluginsamp
Cette page est construite à partir de ce que GitHub publie sur le dépôt. samp.directory n’héberge pas le code. Signaler un problème avec cette fiche