English Adding Usgn to Table

11 replies
Goto Page
To the start Previous 1 Next To the start
05.03.12 05:31:19 am
Up
unlimited-
User
Offline Off
Hi, i am improving on my script, and everything works, when i type:
Code:
1
!admin +usgn

then sucessful add a table on my script, BUT, it adds on a new line like:
Code:
1
2
adminlist = {playerUsgn1}
adminlist = {playerUsgn2}

But when this is done, only one of the currents usgn can be the Admin. So what i want is, instead creating a new line, just make a >,< on it, so many people can be Admins, like:
Code:
1
adminlist = {playerUsgn1,playerUsgn2}


You know? So i will be very gratefull if you help me

More >


More >


"Awp_grey Pro Player"
05.03.12 05:39:15 am
Up
EngiN33R
Moderator
Offline Off
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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

function saveToFile()
     local script={}
     File = io.open("maps/users.lua", "r")
     for line in File:lines() do
          if line~="adminlist = {" then
               table.insert(script,line)
          else
               break
          end
     end
     File:close()
     
     File = io.open("maps/users.lua", "w")
     for _,l in pairs(script) do
          File:write(l)
     end
     File:write("\nadminlist = {")
     for k,u in pairs(adminlist) do
          File:write("["..k.."] = "..us)
     end
     File:write("}")
     File:close()
end

addhook("say","dresadd")
function dresadd(id,txt)
     local p = totable(txt)
     local cmd = (p[1])
     if cmd == "!admin" then
          local us = tonumber(p[2])
          table.insert(adminlist,us)
          saveToFile()
     end
end


It would be easier if you saved it to an external file and not the script, but I think the above code should work. It's longer because I save the whole actual script before adding the admin list thing.
Codito ergo sum. [sic] | My YouTube channel | Visit my blog for Lua tips and other interesting info | thread cs2d Space RPG 2.0 - Development Thread
05.03.12 09:37:33 pm
Up
unlimited-
User
Offline Off
@user EngiN33R Dresa: !admin 44092
LUA ERROR: sys/lua/[D]Arena/Dfunc.lua:294: attempt to index global 'File' (a nil value)

Help? '-' pls
"Awp_grey Pro Player"
05.03.12 09:44:55 pm
Up
EngiN33R
Moderator
Offline Off
You might want to tell me what line is line 294.
Codito ergo sum. [sic] | My YouTube channel | Visit my blog for Lua tips and other interesting info | thread cs2d Space RPG 2.0 - Development Thread
05.03.12 09:48:03 pm
Up
sheeL
User
Offline Off
LUA ERROR: sys/lua/lvl.lua:15: attempt to index global 'File' (a nil value)

line 15 = table.insert(script,line)
Visit WorldQuality2D website: http://wq2d.com.br /// Upload your map at http://uploadwq2d.tk
05.03.12 09:57:55 pm
Up
unlimited-
User
Offline Off
user sheeL has written:
LUA ERROR: sys/lua/lvl.lua:15: attempt to index global 'File' (a nil value)

line 15 = table.insert(script,line)



Thanks
"Awp_grey Pro Player"
05.03.12 10:06:51 pm
Up
EngiN33R
Moderator
Offline Off
How is that possible? The File variable is not used on line 15.
Codito ergo sum. [sic] | My YouTube channel | Visit my blog for Lua tips and other interesting info | thread cs2d Space RPG 2.0 - Development Thread
05.03.12 10:09:25 pm
Up
unlimited-
User
Offline Off
user EngiN33R has written:
How is that possible? The File variable is not used on line 15.


Please if you can, just test it on your sv '-'
"Awp_grey Pro Player"
05.03.12 10:13:56 pm
Up
sheeL
User
Offline Off
user unlimited- has written:
user EngiN33R has written:
How is that possible? The File variable is not used on line 15.


Please if you can, just test it on your sv '-'


use

More >
Visit WorldQuality2D website: http://wq2d.com.br /// Upload your map at http://uploadwq2d.tk
05.03.12 10:17:07 pm
Up
EngiN33R
Moderator
Offline Off
Code >


This works perfectly on my server.
Codito ergo sum. [sic] | My YouTube channel | Visit my blog for Lua tips and other interesting info | thread cs2d Space RPG 2.0 - Development Thread
06.03.12 12:03:33 am
Up
unlimited-
User
Offline Off
user EngiN33R has written:
This works perfectly on my server.


In mine too! Thanks again @user EngiN33R: you re the best
"Awp_grey Pro Player"
27.03.12 12:44:54 am
Up
Jhony
User
Offline Off
user unlimited- has written:
user EngiN33R has written:
This works perfectly on my server.


In mine too! Thanks again @user EngiN33R: you re the best


no , no works

look the error
Code:
1
LUA ERROR: sys/lua/adv.lua:13: attempt to index local 'File' (a nil value)
To the start Previous 1 Next To the start