DNumberWang:OnValueChanged
Örnek
Her bir sayı seçicinin yeni değerine göre bir erkek soru ses baytı ve bir kadın cevap ses baytı çalan, iki sayı seçicili bir panel oluşturur.
-- Arka plan paneli
BGPanel = vgui.Create("DPanel")
BGPanel:SetPos(20, 20)
BGPanel:SetSize(100, 55)
-- İfade etiketi
local lbl1 = vgui.Create("DLabel", BGPanel)
lbl1:SetPos(5, 5)
lbl1:SetSize(100, 20)
lbl1:SetText("Statement: ")
lbl1:SetColor(Color(64, 64, 255))
-- Yanıt etiketi
local lbl2 = vgui.Create("DLabel", BGPanel)
lbl2:SetPos(5, 30)
lbl2:SetSize(100, 20)
lbl2:SetText("Response: ")
lbl2:SetColor(Color(255, 0, 255))
-- "Sorular" için sayı seçici
local question = vgui.Create("DNumberWang", BGPanel)
question:SetPos(65, 5)
question:SetSize(30, 20)
question:SetMinMax(1, 30)
-- Cevaplar için sayı seçici
local answer = vgui.Create("DNumberWang", BGPanel)
answer:SetPos(65, 30)
answer:SetSize(30, 20)
answer:SetMinMax(1, 40)
-- Bu, üst üste binen konuşmaları önlemek için kullanılır
local null = Sound("common/null.wav")
-- Soyutlama = daha temiz kod
function TalkSound(snd)
EmitSound(snd, LocalPlayer():GetPos(), LocalPlayer():EntIndex(), CHAN_VOICE, 1, 80, 0, 100)
end
-- Yeni sayıya göre bir ifade oynat
function question:OnValueChanged(val)
TalkSound(null)
TalkSound(Sound("vo/npc/male01/question"..string.format("%02d", val)..".wav"))
end
-- Yeni sayıya göre bir cevap oynat
function answer:OnValueChanged(val)
TalkSound(null)
TalkSound(Sound("vo/npc/female01/answer"..string.format("%02d", val)..".wav"))
end
Tüm sunucular · GmodTR Launcher · Rehber · GMod Wiki · GmodTR nedir? · Sunucu ekle · Discord