English file:read Tutorial

3 replies
Goto Page
To the start Previous 1 Next To the start
03.09.12 02:13:59 am
Up
Gajosik
BANNED
Offline Off
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]
Code:
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
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.
edited 1×, last 03.09.12 07:32:55 am
Ban Reason: Multiple Accounts
03.09.12 08:44:15 am
Up
Klin
User
Offline Off
http://lua-users.org/wiki/IoLibraryTutorial

This should slove your problem.

Klin
IMG:http://www.klinsoft.de/forum/dfk.png
03.09.12 10:23:23 am
Up
Shawni
User
Offline Off
Just write the Vip Value(name) there then write "then"
We die once, do i have to hide to be visible ?
03.09.12 10:24:21 am
Up
Gajosik
BANNED
Offline Off
LoL, I created it.

Code:
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


Code:
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
edited 1×, last 03.09.12 11:36:39 am
Ban Reason: Multiple Accounts
To the start Previous 1 Next To the start