search.AddProvider
Açıklama
Bir arama sonucu sağlayıcısı ekler. Örnekler için gamemodes/sandbox/gamemode/cl_search_models.lua dosyasına bakın.
Argümanlar
Örnek
gamemodes/sandbox/gamemode/cl_search_models.lua dosyasından eklenmiş yorumlarla birlikte model araması
--
-- 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"
Tüm sunucular · GmodTR Launcher · Rehber · GMod Wiki · GmodTR nedir? · Sunucu ekle · Discord