Forum

> > CS2D > Scripts > Menu languages
Forums overviewCS2D overview Scripts overviewLog in to reply

English Menu languages

10 replies
To the start Previous 1 Next To the start

old Menu languages

Gajos
BANNED Off Offline

Quote
How to make the menu when I create a file english.txt it is added to the menu? And when I click on it then it start him function.

Example:
I make files:
• polish.txt
• english.txt

Menu:
1. polish
2. english
3.
4.
5.
6.
7.
8.
9.

old Re: Menu languages

Deleted User

Quote
You can't loop through the folder.
Or you can if you will import Starkzz/BlazingNote's libraries.

old Re: Menu languages

mafia_man
User Off Offline

Quote
Factis has no brain for this, so I made it:
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
lang = {
	["English"] = {
		["langMenuTitle"] = "Select your Language";
		
		["menu1"] = {
			"English Menu 1"; -- Title
			"Button 1,Factis is moderator"; -- Buttons
		};
		["menu2"] = {
			"English Menu 2";
			"Button 1,Factis likes pie";
		};
	};
	
	["Polski"] = {
		["langMenuTitle"] = "Wybierz swoj Jezyk";
		
		["menu1"] = {
			"Polskie Menu 1";
			"Przycisk 1,Factis to cipa";
		};
		["menu2"] = {
			"Polskie Menu 2";
			"Przycisk 1,Factis lubi ruchac";
		};
	};
}

Player = {};

LANGUAGES = {"English", "Polski"}

function langMenu(id)
	local _, i;
	local str = lang[Player[id].lang]["langMenuTitle"] .. ",";
	for _, i in pairs(LANGUAGES) do
		str = str .. i;
		if _ < #LANGUAGES then
			str = str .. ",";
		end
	end
	menu(id, str);
end

function menu1(id)
	local l = lang[Player[id].lang]["menu1"];
	menu(id, l[1] .. "," .. l[2]);
end

function menu2(id)
	local l = lang[Player[id].lang]["menu2"];
	menu(id, l[1] .. "," .. l[2]);
end

addhook("join", "onJoin")
function onJoin(id)
	Player[id] = {
		lang = "English";
	};
end

addhook("serveraction", "onKey")
function onKey(id, k)
	if (k == 1) then
		langMenu(id);
	elseif (k == 2) then
		menu1(id);
	elseif (k == 3) then
		menu2(id);
	end
end

addhook("menu", "onMenu")
function onMenu(id, t, b)
	local l = lang[Player[id].lang];
	if (t == l["langMenuTitle"]) then
		if b > 0 then
			Player[id].lang = LANGUAGES[b];
		end
	elseif (t == l["menu1"][1]) then
		msg("Button["..b.."] in menu1 with title: "..t);
	elseif (t == l["menu2"][1]) then
		msg("Button["..b.."] in menu2 with title: "..t);
	end
end

Admin/mod comment

Rules §3.1 - No posts which offend/provoke/insult (flame) Well, At least I like pie. And you translated this sentence wrong BTW.

old Re: Menu languages

useigor
User Off Offline

Quote
user mafia_man has written
Factis has no brain for this, so I made it:
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
lang = {
	["English"] = {
		["langMenuTitle"] = "Select your Language";
		
		["menu1"] = {
			"English Menu 1"; -- Title
			"Button 1,Factis is moderator"; -- Buttons
		};
		["menu2"] = {
			"English Menu 2";
			"Button 1,Factis likes pie";
		};
	};
	
	["Polski"] = {
		["langMenuTitle"] = "Wybierz swoj Jezyk";
		
		["menu1"] = {
			"Polskie Menu 1";
			"Przycisk 1,Factis to cipa";
		};
		["menu2"] = {
			"Polskie Menu 2";
			"Przycisk 1,Factis lubi ruchac";
		};
	};
}

Player = {};

LANGUAGES = {"English", "Polski"}

function langMenu(id)
	local _, i;
	local str = lang[Player[id].lang]["langMenuTitle"] .. ",";
	for _, i in pairs(LANGUAGES) do
		str = str .. i;
		if _ < #LANGUAGES then
			str = str .. ",";
		end
	end
	menu(id, str);
end

function menu1(id)
	local l = lang[Player[id].lang]["menu1"];
	menu(id, l[1] .. "," .. l[2]);
end

function menu2(id)
	local l = lang[Player[id].lang]["menu2"];
	menu(id, l[1] .. "," .. l[2]);
end

addhook("join", "onJoin")
function onJoin(id)
	Player[id] = {
		lang = "English";
	};
end

addhook("serveraction", "onKey")
function onKey(id, k)
	if (k == 1) then
		langMenu(id);
	elseif (k == 2) then
		menu1(id);
	elseif (k == 3) then
		menu2(id);
	end
end

addhook("menu", "onMenu")
function onMenu(id, t, b)
	local l = lang[Player[id].lang];
	if (t == l["langMenuTitle"]) then
		if b > 0 then
			Player[id].lang = LANGUAGES[b];
		end
	elseif (t == l["menu1"][1]) then
		msg("Button["..b.."] in menu1 with title: "..t);
	elseif (t == l["menu2"][1]) then
		msg("Button["..b.."] in menu2 with title: "..t);
	end
end

Your translation have some errors. I lol'd.

old Re: Menu languages

mafia_man
User Off Offline

Quote
user useigor has written
Your translation have some errors. I lol'd.

I know, who cares anyway. It's just example.

Admin/mod comment

Removed useless quote. /Starkkz

old Re: Menu languages

gotya2
GAME BANNED Off Offline

Quote
@user mafia_man: i think this is not entirely the solution to his question. He wants to automatically read a directory.

Admin/mod comment

Removed useless quote. /Starkkz

old Re: Menu languages

Cure Pikachu
User Off Offline

Quote
user gotya2 has written
@user mafia_man: i think this is not entirely the solution to his question. He wants to automatically read a directory.

Plus changing the language of the game via menu, if that's what user Gajos meant with the english.txt and stuff. That would be impossible, unless there are server-sided commands for that, which I don't think there is any.
If the english.txt files are custom-made, never mind what I said above, but you'll still need file cs2d Stream functions library for Lua or file File does not exist (12623) to loop through folders.
edited 3×, last 27.11.12 02:25:08 am

old Re: Menu languages

Gajos
BANNED Off Offline

Quote
I don't know how to make.
Who can make code for me?
Quote
You can use your permisson in script


READ BEFORE YOU ARE START MAKING THE SCRIPT thread cs2d Menu languages

old Re: Menu languages

sheeL
User Off Offline

Quote
I do this simples script example, you can upgrade it... using some lib's, also, you can find it on unrealsoftware files archive... i don't have time for help you more, sorry.

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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
if English == nil then English = {} end if Polish == nil then Polish = {} end

Messages = {"English Message",
             "Polish Message",
             "Your Messages here"
}

addhook('serveraction','_serveraction')
function _serveraction(playerid,actionid)
	if actionid == 1 then
		menu(playerid,"Menu,Polish,English")
	end
end

addhook('menu','_menu')
function _menu(playerid,tittleid,buttonid)
if tittleid == 'Menu' then
	if buttonid == 1 then
		Polish[playerid]=1
		debug(playerid)
		msg2(playerid,"©255255255Polish Language Enabled")
	elseif buttonid == 2 then
		English[playerid]=1
		debug(playerid)
		msg2(playerid,"©255255255English Language Enabled")
		end
	end
end


function debug(id)
	if Polish[id] == 1 then
		English[id]=0
	elseif English[id] == 1 then
		Polish[id]=0
	end
end

addhook('minute','_minute') -- hook minute
function _minute()
	for _,id in pairs(player(0,"table")) do
		if English[id] == 1 then
			MSG = Messages[1]
			msg2(id,MSG)
		end
	if Polish[id] == 1 then
		MSG = Messages[2]
			msg2(id,MSG)
		end
	end
end

addhook('join','_join')
function _join(id)
	English[id]=0
	Polish[id]=0
end
edited 2×, last 24.07.14 03:00:51 am
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview