# net.WriteData

- **Ortam:** İstemci, Sunucu
- **İngilizce aslı:** https://wiki.facepunch.com/gmod/net.WriteData
- **Çeviri tarihi:** 2025-09-08

```lua
net.WriteData( string binaryData, number length = #binaryData )
```

## Açıklama

Mesaja bir parça ikili (binary) veri yazar.

## Argümanlar

1. [string](https://gmod.tr/wiki/string) **binaryData**: Gönderilecek ikili (binary) veri.
2. [number](https://gmod.tr/wiki/number) **length** = #binaryData: Gönderilecek ikili (binary) verinin bayt cinsinden uzunluğu.

### Örnek

WriteString kullanmadan sunucuya bir mesaj gönderir.

> **NOT:** Eğer net mesajı içinde **bu fonksiyonu sadece bir kez kullanıyorsanız**, [net.WriteUInt](https://gmod.tr/wiki/net.WriteUInt) kullanmanıza gerek yoktur.
> Bayt miktarını, mesaj uzunluğunu 8'e bölerek elde edebilirsiniz. **Şu şekilde:**
>
> ```lua
> local compressed_message = net.ReadData( len / 8 ) -- Uzunluğu Bit'ten Bayt'a dönüştürür.
> ```

```lua
if ( CLIENT ) then
	local message = "This is a cool message"
	local compressed_message = util.Compress( message )
	local bytes_amount = #compressed_message

	concommand.Add( "send_message_data", function( ply, cmd, args )
		net.Start( "SendMessage" )
			net.WriteUInt( bytes_amount, 16 ) -- Sahip olduğumuz bayt miktarını yazar. Veriyi okumak için gereklidir
			net.WriteData( compressed_message, bytes_amount ) -- Verileri yazar
		net.SendToServer()
	end )
end

if ( SERVER ) then
	util.AddNetworkString( "SendMessage" )

	net.Receive( "SendMessage", function( len, ply )
		local bytes_amount = net.ReadUInt( 16 ) -- Verimizin sahip olduğu bayt miktarını geri alır
		local compressed_message = net.ReadData( bytes_amount ) -- Sıkıştırılmış mesajımızı geri alır
		local message = util.Decompress( compressed_message ) -- Mesajımızın sıkıştırmasını açar

		print( message )
	end)
end
```

**Çıktı:**

```lua
This is a cool message
```

- [GMod Wiki ana sayfası](https://gmod.tr/wiki)

---

[Tüm sunucular](https://gmod.tr/) · [GmodTR Launcher](https://gmod.tr/launcher) · [Rehber](https://gmod.tr/rehber) · [GMod Wiki](https://gmod.tr/wiki) · [GmodTR nedir?](https://gmod.tr/hakkinda) · [Sunucu ekle](https://gmod.tr/sunucu-ekle) · [Discord](https://discord.gg/gmodtr)

Kaynak: https://gmod.tr/wiki/net.WriteData
