Network Protocol
Wire format, RPC ids and compatibility notes.
Knight speaks the SA-MP 0.3.7 wire protocol, including the 0.3.DL additions. It is byte-compatible with the official client, so no client patch is needed.
Transport
- UDP with the RakNet legacy offline handshake (cookie + auth key).
- Obfuscation: the server port masks the encryption key.
- Reliable ordered channels 0–31, unreliable and unreliable-sequenced packets.
- Payload fragmentation above the MTU with reassembly.
Connection handshake
text
client server
| OpenConnectionRequest1 -> |
| <- OpenConnectionReply1 |
| OpenConnectionRequest2 ->
| <- OpenConnectionReply2 | (cookie challenge)
| ConnectionRequest ->
| <- AuthKey | (GPCI serial challenge)
| AuthKey(response) ->
| <- ConnectionAccepted |
| NewIncomingConnection ->
| RPC_ClientJoin (25) -> | version, name, serial, version string
| <- RPC_InitGame (139) | hostname, limits, vehicle models
Key RPCs
| Id | Name | Direction |
|---|---|---|
| 25 | ClientJoin | client → server |
| 139 | InitGame | server → client |
| 128 / 129 | RequestClass / RequestSpawn | client → server |
| 52 | Spawn | client → server |
| 101 | Chat | client → server |
| 93 | ClientMessage | server → client |
| 61 / 62 | ShowDialog / DialogResponse | both |
| 153 | SetPlayerSkin | server → client |
| 164 / 165 | WorldVehicleAdd / Remove | server → client |
| 179 | ModelRequest (0.3.DL) | server → client |
| 183 | ModelUrl (0.3.DL redirect) | server → client |
Client versions
| Number | Client |
|---|---|
| 4057 | SA-MP 0.3.7 |
| 4062 | SA-MP 0.3.DL |
Knight reads the version from ClientJoin and only sends custom-model RPCs to 0.3.DL clients. Older clients receive base models instead.
Text encoding
SA-MP strings are Windows-1252. Knight encodes gamemode UTF-8 strings to CP1252 on the wire and decodes incoming text back to UTF-8.