# search.AddProvider

- **Ortam:** İstemci
- **İngilizce aslı:** https://wiki.facepunch.com/gmod/search.AddProvider
- **Çeviri tarihi:** 2025-09-08

```lua
search.AddProvider( function provider, string id = nil )
```

## Açıklama

Bir arama sonucu sağlayıcısı ekler. Örnekler için [gamemodes/sandbox/gamemode/cl_search_models.lua](https://github.com/Facepunch/garrysmod/blob/7c23addd2c35d3d046c80e3d0cb6052055eca3e2/garrysmod/gamemodes/sandbox/gamemode/cl_search_models.lua) dosyasına bakın.

## Argümanlar

1. [function](https://gmod.tr/wiki/function) **provider**: Sağlayıcı fonksiyonu. Fonksiyon argüman(lar)ı: 1. [string](https://gmod.tr/wiki/string) **searchQuery** - Kullanıcının girdiği arama sorgusu. Fonksiyon dönüş değer(ler)i: 1. [table](https://gmod.tr/wiki/table) **data** - Şu şekilde yapılandırılmış tabloların bir listesini döndürmelisiniz: [string](https://gmod.tr/wiki/string) text - "Panoya Kopyala" için metin [function](https://gmod.tr/wiki/function) func - Öğeyi kullanmak/doğurmak için fonksiyon [Panel](https://gmod.tr/wiki/Panel) icon - Spawnmenu'ye eklenecek bir panel [table](https://gmod.tr/wiki/table) words - Kelimelerden oluşan bir tablo?
2. [string](https://gmod.tr/wiki/string) **id** = nil: Eğer belirtilirse, belirli bir kimliğe (ID) sahip yalnızca bir sağlayıcının aynı anda var olmasını sağlar.

### Örnek

gamemodes/sandbox/gamemode/cl_search_models.lua dosyasından eklenmiş yorumlarla birlikte model araması

```lua
--
-- Model Araması
--
local model_list = nil
search.AddProvider( function( str )

	if ( model_list == nil ) then

		model_list = {}
		GetAllFiles( model_list, "models/", ".mdl", "GAME" )

	end

	local models = {}

	for k, v in pairs( model_list ) do

		-- Her modelin models/ ve .mdl kısımlarında arama yapmayın, çünkü her model bu kısımlara sahiptir, tabii doğrudan model yolunu aramıyorlarsa
		local modelpath = v
		if ( modelpath:StartWith( "models/" ) && modelpath:EndsWith( ".mdl" ) && !str:EndsWith( ".mdl" ) ) then modelpath = modelpath:sub( 8, modelpath:len() - 4 ) end

		if ( modelpath:find( str, nil, true ) ) then

			if ( IsUselessModel( v ) ) then continue end

			local entry = {
				text = v:GetFileFromFilename(), -- "Panoya Kopyala" için metin
				func = function() RunConsoleCommand( "gm_spawn", v ) end, -- Öğeyi kullanmak/doğurmak için fonksiyon
				icon = spawnmenu.CreateContentIcon( "model", g_SpawnMenu.SearchPropPanel, { model = v } ), -- Spawnmenu'ye eklenecek bir panel
				words = { v } -- Kelimelerden oluşan bir tablo?
			}

			table.insert( models, entry )

		end

		if ( #models >= sbox_search_maxresults:GetInt() / 2 ) then break end

	end

	return models

end, "props" ) -- ID: "props"
```

- [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/search.AddProvider
