Forum

> > CS2D > Scripts > file:read Tutorial
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch file:read Tutorial

3 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt file:read Tutorial

Gajosik
BANNED Off Offline

Zitieren
How to write a script in which:
In [your usgn].lua would have written:
vip
and when it vip, can open the menu [menu_vip]
1
2
3
function menu_vip(id)
menu(id,"Menu VIP,button 1,button 2")
end

I do not know how to write serveraction
Please code
1
2
3
4
5
6
7
8
addhook("serveraction","sa")
function sa(id,key)
	if key==3 then
		if [THIS CODE] //*only vips in »your usgn.lua«
			menu_vip(id)
		end
	end
end

I can write save.
1× editiert, zuletzt 03.09.12 07:32:55

alt Re: file:read Tutorial

Gajosik
BANNED Off Offline

Zitieren
LoL, I created it.

1
2
3
4
5
6
7
8
function totable(t,match)
     local cmd = {}
     if not match then match = "[^%s]+" end
     for word in string.gmatch(t, match) do
          table.insert(cmd, word)
     end
     return cmd
end

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
function lvl(id)
	local filename = "server_data/"..player(id,"usgn")..".txt"
	local file = io.open(filename)
	if file then
		for line in file:lines() do
			local parses = totable(line)
			if parses[1] ~= nil then
				if parses[1] == "member" then
					return 1
				elseif parses[1] == "mod" then
					return 2
				elseif parses[1] == "gamemaster" then
					return 3
				elseif parses[1] == "admin" then
					return 4
				end
			else
				return 0
			end
		end
		if file ~= nil then
			file:close()
		end
	end
	return 0
end
1× editiert, zuletzt 03.09.12 11:36:39
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht