basdon.net aviation server


IP: basdon.net:7777 (How to join)[Log In]

Articles > Internal docs > SAMP internals

SAMP internals

Everything on this page is about SA-MP 0.3.7-R4

Client console commands

See samp.dll+690D0.

When launching SA-MP Debug (samp_debug.exe), following commands are also available:

Vehicle Categories (client)

Some vehicle things are handled differently by the client depending on the category of the vehicle. The category of a vehicle is determined at runtime by its vtable. SAMP defines following categories:

Full vehicle list
modelactual vtableassigned categoryvehicle name
4000x8711201Landstalker
4010x8711201Bravura
4020x8711201Buffalo
4030x8711201Linerunner
4040x8711201Perennial
4050x8711201Sentinel
4060x8717D80(1)Dumper
4070x8711201Fire Truck
4080x8711201Trashmaster
4090x8711201Stretch
4100x8711201Manana
4110x8711201Infernus
4120x8711201Voodoo
4130x8711201Pony
4140x8711201Mule
4150x8711201Cheetah
4160x8711201Ambulance
4170x8716803Leviathan
4180x8711201Moonbeam
4190x8711201Esperanto
4200x8711201Taxi
4210x8711201Washington
4220x8711201Bobcat
4230x8711201Mr Whoopee
4240x8711201BF Injection
4250x8716803Hunter
4260x8711201Premier
4270x8711201Enforcer
4280x8711201Securicar
4290x8711201Banshee
4300x8721A04Predator
4310x8711201Bus
4320x8711201Rhino
4330x8711201Barracks
4340x8711201Hotknife
4350x871C280Artic Trailer 1
4360x8711201Previon
4370x8711201Coach
4380x8711201Cabbie
4390x8711201Stallion
4400x8711201Rumpo
4410x8711201RC Bandit
4420x8711201Romero
4430x8711201Packer
4440x8717D80(1)Monster
4450x8711201Admiral
4460x8721A04Squalo
4470x8716803Seasparrow
4480x8713602Pizzaboy
4490x8723707Tram
4500x871C280Artic Trailer 2
4510x8711201Turismo
4520x8721A04Speeder
4530x8721A04Reefer
4540x8721A04Tropic
4550x8711201Flatbed
4560x8711201Yankee
4570x8711201Caddy
4580x8711201Solair
4590x8711201Berkley's RC Van
4600x8719485Skimmer
4610x8713602PCJ-600
4620x8713602Faggio
4630x8713602Freeway
4640x8719485RC Baron
4650x8716803RC Raider
4660x8711201Glendale
4670x8711201Oceanic
4680x8713602Sanchez
4690x8716803Sparrow
4700x8711201Patriot
4710x871AE80(1)Quadbike
4720x8721A04Coast Guard
4730x8721A04Dinghy
4740x8711201Hermes
4750x8711201Sabre
4760x8719485Rustler
4770x8711201ZR-350
4780x8711201Walton
4790x8711201Regina
4800x8711201Comet
4810x8715286BMX
4820x8711201Burrito
4830x8711201Camper
4840x8721A04Marquis
4850x8711201Baggage
4860x8711201Dozer
4870x8716803Maverick
4880x8716803News Chopper
4890x8711201Rancher
4900x8711201FBI Rancher
4910x8711201Virgo
4920x8711201Greenwood
4930x8721A04Jetmax
4940x8711201Hotring Racer
4950x8711201Sandking
4960x8711201Blista Compact
4970x8716803Police Maverick
4980x8711201Boxville
4990x8711201Benson
5000x8711201Mesa
5010x8716803RC Goblin
5020x8711201Hotring Racer A
5030x8711201Hotring Racer B
5040x8711201Bloodring Banger
5050x8711201Lure Rancher
5060x8711201Super GT
5070x8711201Elegant
5080x8711201Journey
5090x8715286Bike
5100x8715286Mountain Bike
5110x8719485Beagle
5120x8719485Cropduster
5130x8719485Stuntplane
5140x8711201Tanker
5150x8711201Roadtrain
5160x8711201Nebula
5170x8711201Majestic
5180x8711201Buccaneer
5190x8719485Shamal
5200x8719485Hydra
5210x8713602FCR-900
5220x8713602NRG-500
5230x8713602HPV1000
5240x8711201Cement Truck
5250x8711201Towtruck
5260x8711201Fortune
5270x8711201Cadrona
5280x8711201FBI Truck
5290x8711201Willard
5300x8711201Forklift
5310x8711201Tractor
5320x8711201Combine Harvester
5330x8711201Feltzer
5340x8711201Remington
5350x8711201Slamvan
5360x8711201Blade
5390x8719485Vortex
5400x8711201Vincent
5410x8711201Bullet
5420x8711201Clover
5430x8711201Sadler
5440x8711201Fire Truck Ladder
5450x8711201Hustler
5460x8711201Intruder
5470x8711201Primo
5480x8716803Cargobob
5490x8711201Tampa
5500x8711201Sunrise
5510x8711201Merit
5520x8711201Utility Van
5530x8719485Nevada
5540x8711201Yosemite
5550x8711201Windsor
5560x8717D80(1)Monster A
5570x8717D80(1)Monster B
5580x8711201Uranus
5590x8711201Jester
5600x8711201Sultan
5610x8711201Stratum
5620x8711201Elegy
5630x8716803Raindance
5640x8711201RC Tiger
5650x8711201Flash
5660x8711201Tahoma
5670x8711201Savanna
5680x8711201Bandito
5690x8711207Freight flat
5700x8711207Brown Streak Carriage
5710x8711201Kart
5720x8711201Mower
5730x8717D80(1)Dune
5740x8711201Sweeper
5750x8711201Broadway
5760x8711201Tornado
5770x8719485AT-400
5780x8711201DFT-30
5790x8711201Huntley
5800x8711201Stafford
5810x8713602BF-400
5820x8711201Newsvan
5830x8711201Tug
5840x871C280Tanker Trailer
5850x8711201Emperor
5860x8713602Wayfarer
5870x8711201Euros
5880x8711201Hotdog
5890x8711201Club
5900x8723707Freight box
5910x871C280Artic Trailer 3
5920x8719485Andromada
5930x8719485Dodo
5940x8711201RC Cam
5950x8721A04Launch
5960x8711201Police LS
5970x8711201Police SF
5980x8711201Police LV
5990x8711201Ranger
6000x8711201Picador
6010x8711201S.W.A.T.
6020x8711201Alpha
6030x8711201Phoenix
6040x8711201Damaged Glendale
6050x8711201Damaged Sadler
6060x871C280Baggage Box A
6070x871C280Baggage Box B
6080x871C280Tug Stairs
6090x8711201Black Boxville
6100x871C280Farm Trailer
6110x871C280Utility Trailer

Notes

(1) vehicles with a vtable that isn't one of the explicitely checked values are put in category 0. Besides all trailers, this also (maybe unexpectedly) includes Dumper, Monster, Monster A, Monster B, Quadbike, Dune. This is because the Dumper, Dune and all Monster vehicles are instances of CMonsterTruck and the Quadbike has its own unique CQuadBike class.

Vehicle damage status

See https://basdon.github.io/documented-samp-pawn-api/main.xml#Appendix_Vehicle_Damage_Status globe icon for an overview of vehicle support, behavior, and some quirks.

Server receiving damage from client

Server ignores damage status updates if it's not coming from the driver of the vehicle, otherwise it's applied and synced unconditionally and OnVehicleDamageStatusUpdate is invoked.

Client receiving damage from server

Behavior depends on the vehicle model it's being applied to, see also Vehicle categories. Most import to take into account: Dumper, Monster, Monster A, Monster B, Quadbike, Dune are categorized as "unknown", meaning none of their damage gets synced. The bumper may get damaged in the driver's game (or tires of a quad bike), but none of the other players will see any damage to that vehicle.

Client applies tire damage at CSampVehicle::ApplyVehicleDamageTires(char) with following behavior:

Client applies other damage at CSampVehicle::ApplyVehicleDamagePanelsDoorsLights(int,int,char) with following behavior:

Notes

(1) while CPlane inherits from CAutomobile, it overrides the Fix method yet SAMP still calls the base CAutomobile::Fix for CPlane instances. This is what causes the 'ghost door' effect(6) on some planes after doing RepairVehicle()(2) or updating damage status to 0 on planes.

For comparison, MTA dispatches to specific overridden methods based on the vehicle's model info:

if (pModelInfo->IsCar() || pModelInfo->IsMonsterTruck() || pModelInfo->IsTrailer())
    dwFunc = FUNC_CAutomobile__Fix(3);
else if (pModelInfo->IsPlane())
    dwFunc = FUNC_CPlane__Fix(3);
else if (pModelInfo->IsHeli())
    dwFunc = FUNC_CHeli__Fix(3);
else if (pModelInfo->IsBike())
    dwFunc = FUNC_CBike_Fix(3);

Source: https://github.com/multitheftauto/mtasa-blue/blob/bb0b32cb90f3379853fb9eab0a651caabd837d6f/Client/game_sa/CVehicleSA.cpp#L1120 globe icon.

It also defines FUNC_CQuadBike__Fix(3), yet that is not used in the above.

(2) RepairVehicle(vehicleid) is implemented in SAMP by doing SetVehicleHealth(vehicleid, 1000.0); UpdateVehicleDamageStatus(vehicleid, 0, 0, 0, 0);.

(3) Implementations of the Fix proc:

(4) uiModelFlags mask 0x100 means NO_DOORS, as per data/handling.cfg comments (field modelFlags (af)).

(5) a damagemanager door value of 4 means that the door is removed/detached.

(6) https://basdon.github.io/documented-samp-pawn-api/main.xml#Appendix_Vehicle_Damage_Status_planeghostdoors globe icon

Player position and server streaming

Player position and streaming is processed when:

First it will unconditionally store the passed position into the player's data.

Then it checks if the player has an expected location after being teleported (which gets set when calling either of: PlayerSpectateVehicleglobe icon / PlayerSpectatePlayerglobe icon / PutPlayerInVehicleglobe icon / SetVehiclePosglobe icon (only for the driver of the vehicle*)). If the expected position has been set less than 5000ms ago (not configurable), streaming will be aborted if the player is not yet within stream_distance of it.

*there is some inconsistent/unexpected behavior regarding this, it seems that tracking of who is driver of the vehicle isn't always reset correctly (it seems to be relying on receiving onuccupied sync packets). This results in the following behavior: when teleporting a vehicle with SetVehiclePos to a location further than the configured stream distance from the last driver of that vehicle, that player may experience a 5 second period where streaming may not be processed.

When triggered by receiving sync data, it will first check if enough time has passed since the last time streaming was processed (stream_rate console/server.cfg variable) and skip if this is not the case.

When triggered by the script functions, streaming is processed immediately. Note that this completely bypasses the stream rate check, so it is possible that next streaming processing will occur much earlier than what the normal stream_rate delay would be from this moment.

After streaming, the checkpoint and race checkpoint are tested. If one is active and the player is now inside and was not before, the appropriate callback is called (OnPlayerEnterCheckpoint/OnPlayerEnterRaceCheckpoint). If one is active and the player is not inside, and was before, the "Leave" callback is called. Note that state seems to be reset when disabling a checkpoint, so disabling the checkpoint while a player is in it will not trigger the "Leave" callback.

Streaming

Player markers

Player markers are streamed if the global setting for marker mode is not set to 0. Markers are updated every 2500ms (not configurable). Markers are included of players who are in the same virtual world, are not in state "none" or "spectating", not NPCs, and within the distance limit if marker mode is "streamed".

Vehicles

A vehicle is streamed in when it exists, has field_7A set to 1, is in the same virtual world, is not of model FREIFLAT or STREAKC (those are never streamed to the client, the client always automatically creates 3 carriages when the train engine vehicle is created), and is within stream_distance.

If that is not the case and the vehicle is still streamed in, it will be streamed out.

(note that no more vehicles will be streamed in if a client already has 700 vehicles streamed in)

Trivia: when it decides to stream in a vehicle, the function to stream in the vehicle checks the stream distance condition again even though we know it already passed that check. This doesn't happen for any of the other elements being streamed in this section.

Players

A player is streamed in when they exist, are not in state "none" or "spectating", are in the same virtual world, and is within stream_distance (calculated from the player position, except if the player is a passenger of a vehicle because then the position of the vehicle is used).

If that is not the case and the player is still streamed in, they will be streamed out.

(note that no more players will be streamed in if a client already has 200 players streamed in)

TextLabels

A 3D text label is streamed in when it is in use and, if attached to a player or vehicle: if that player or vehicle is streamed in, if not attached: if the label is in the same virtual world and the player is within its draw distance.

If that is not the case and the text label is still streamed in, it will be streamed out.

Pickups

A pickup is streamed in when it is in use, is in the same virtual world, and within stream_distance.

If that is not the case and the pickup is still streamed in, it will be streamed out.

Actors

An actor is streamed in when they are in use, are in the same virtual world, and within stream_distance.

If that is not the case and the actor is still streamed in, they will be streamed out.

Packet priority, reliability, ordering channel

packetpriorityreliabilityord
Connection rejectedHIGH_PRIORITYUNRELIABLE0
Legacy destroy pickup (151)HIGH_PRIORITYRELIABLE0
Scores & pings updateHIGH_PRIORITYRELIABLE0
Request ClassHIGH_PRIORITYRELIABLE0
On foot syncHIGH_PRIORITYUNRELIABLE_SEQUENCED1
(all other scripting functions)HIGH_PRIORITYRELIABLE_ORDERED2
Chat messageHIGH_PRIORITYRELIABLE3

Misc

Scoreboard: the client periodically requests an update for player scores & pings (rpc 155). The server only responds if it has been more than 2000ms since the last request.

Legacy pickup rpcs: the server can receive rpc 97 which reads a single 2-byte pickup id, to which the server will broadcast rpc 151 to all clients (containing that 2-byte pickup id). Clients receiving rpc 151 will read a 1-byte value and delete a pickup identified by that value. It doesn't seem like clients ever send rpc 97.

rpc 102: when sent by the client (no payload), the server will respond (if player is rcon admin) with 196 bytes of raknet stats (assumption) (stats of UNASSIGNED_PLAYER_ID, so does this mean global stats?).

Category: Internal docs
SAMP internalsTables
CodePreprocessor Definitions
File formatsFlight file formatMap file formatTextdraw file format
ServicesEchoFlighttracker

This article has been accessed 249 time(s).
Main page Article index