hook.Call
Örnek
DoSomething fonksiyonunu çalıştırır, bu fonksiyon sonunda DoneDoingSomething olayını çağırır ve hook'lanmış DoSomethingElse fonksiyonunu tetikler.
local function DoSomething()
-- Bir şeyler yapar
hook.Call( "DoneDoingSomething" )
end
local function DoSomethingElse()
-- "DoneDoingSomething" hook'u çağrıldığında başka bir şey yapar.
print( "Done!" )
end
hook.Add( "DoneDoingSomething", "Does something else", DoSomethingElse )
DoSomething()
Çıktı:
Done!
Örnek
Ayrıca özel fonksiyonları hook'lar aracılığıyla kontrol edilebilir hale getirebilirsiniz.
local function MakeCheese()
local shouldMakeCheese = hook.Call( "MakeCheezPleez" )
if shouldMakeCheese then
print( "yay" )
else
print( "nay" )
end
end
local function MakeCheeseOrNot()
return player.GetCount() >= 1
end
hook.Add( "MakeCheezPleez", "Does something else", MakeCheeseOrNot )
MakeCheese()
Çıktı: Sunucuda oyuncu varsa
yay, yoksa nay yazdırılır.Örnek
Tüm sunucular · GmodTR Launcher · Rehber · GMod Wiki · GmodTR nedir? · Sunucu ekle · Discord