string.Explode
Örnek
Bir cümleyi içindeki kelimelerin tablosuna ayırır.
local sentence = "hello there my name is Player1"
local words = string.Explode( " ", sentence )
PrintTable( words )
Çıkış:
1 = hello
2 = there
3 = my
4 = name
5 = is
6 = Player1
Örnek
Bir oyuncunun söylediği kelimeleri sıralamak için Explode kullanır.
hook.Add( "PlayerSay", "GiveHealth", function( ply, text )
local playerInput = string.Explode( " ", text )
if ( playerInput[1] == "!givehealth" ) then
if ( tonumber( playerInput[2] ) ) then
ply:SetHealth( tonumber( playerInput[2] ) )
print( ply:Nick() .. " set their health to " .. playerInput[2] )
end
end
end)
Çıkış:
Player1 set their health to 100.
Örnek
Bir cümleyi her basamakta bir tabloya ayırır.
local sentence = "Separated 4 every digit like 1 and 2"
local words = string.Explode("%d", sentence, true)
PrintTable( words )
Çıkış:
1 = Separated
2 = every digit like
3 = and
4 =
Tüm sunucular · GmodTR Launcher · Rehber · GMod Wiki · GmodTR nedir? · Sunucu ekle · Discord