Thanks for help
Forum
CS2D Scripts Script bridgeScript bridge
4 Antworten 1
Thanks for help
Here's how I'd do it:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
languages = { [1] = {"labas","as esu","krabas"}, [2] = {"hi","I am","a crab"}, ["used"] = {} } addhook("menu","_m") function _m(id,t,b) 	if t == "example title A" then 		for k,v in pairs (languages[b]) do 			languages["used"][k] = v 		end 	elseif t == "example title B" then 		menu(id,"Title (can also be a variable)",languages["used"][1], languages["used"][2], languages["used"][3]) 	end end
This is just an example of how it would work. It doesn't actually work because I didn't create appropriate menus and hooks to call them.
If the player talk "!German run german.lua"
only for the specific player show your language specific
You need to make text files for each language. Here's English.txt:
1
2
3
2
3
Language Selection Welcome, %s! You pressed button %d!
1
2
3
2
3
Pemilihan Bahasa Selamat datang, %s! Anda menekan tombol %d!
Now to load the text files you need to insert the following code.
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
availablelanguages = {"English", "Indonesian"} languages = {} for index, language in ipairs(availablelanguages) do 	local file = assert(io.open("<directory-to-your-languages>/" .. language .. ".txt", "r")) 	languages[language] = {} 	local line = 1 	 	for lines in file:lines() do 		languages[language][line] = lines 		line = line + 1 	end end
1
languages["<language>"][<line>]
How do you use the languages? Well, here's an example on how to use the languages.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
local language = {} for id = 1, 32 do 	language[id] = "English" end function joinhook(id) 	msg2(id, languages[language[id]][1]:format(player(id, "name"))) end function serveractionhook(id, action) 	if (action == 1) then 		menu(id, languages[language[id]][1] .. "," .. table.concat(availablelanguages, ",")) 	elseif (action == 2) then 		menu(id, "Menu,1,2,3") 	end end function menuhook(id, title, button) 	if (title == languages[language[id]][1]) then 		if (button >= 1 and button <= 9) then 			if (availablelanguages[button]) then 				language[id] = availablelanguages[button] 			end 		end 	if (title == "Menu") then 		if (button >= 1 and button <= 9) then 			msg2(id, languages[language[id]][2]:format(button)) 		end 	end end for index, hook in ipairs({"join", "serveraction", "menu"}) do 	addhook(hook, hook .. "hook") end
You can extend them more if you like.
1