Adding Usgn to Table
11 replies
1

05.03.12 05:31:19 am
Hi, i am improving on my script, and everything works, when i type:
then sucessful add a table on my script, BUT, it adds on a new line like:
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:
You know? So i will be very gratefull if you help me
Code:
1
!admin +usgn
then sucessful add a table on my script, BUT, it adds on a new line like:
Code:
1
2
2
adminlist = {playerUsgn1}
adminlist = {playerUsgn2}
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
"Awp_grey Pro Player"
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
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
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 | US Sim: The Two
@
EngiN33R Dresa: !admin 44092
LUA ERROR: sys/lua/[D]Arena/Dfunc.lua:294: attempt to index global 'File' (a nil value)
Help? '-' pls
EngiN33R Dresa: !admin 44092LUA ERROR: sys/lua/[D]Arena/Dfunc.lua:294: attempt to index global 'File' (a nil value)
Help? '-' pls
"Awp_grey Pro Player"
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 | US Sim: The Two
LUA ERROR: sys/lua/lvl.lua:15: attempt to index global 'File' (a nil value)
line 15 = table.insert(script,line)
line 15 = table.insert(script,line)
Que se Realize, oque sempre sonhei, que se Torne verdade, oque Maginei, só então saberei..., que não errei, quanto a ti olhar, eu Amei (8)
sheeL has written:LUA ERROR: sys/lua/lvl.lua:15: attempt to index global 'File' (a nil value)
line 15 = table.insert(script,line)
line 15 = table.insert(script,line)
Thanks
"Awp_grey Pro Player"
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 | US Sim: The Two
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"
unlimited- has written:
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
Que se Realize, oque sempre sonhei, que se Torne verdade, oque Maginei, só então saberei..., que não errei, quanto a ti olhar, eu Amei (8)
Codito ergo sum. [sic] | My YouTube channel | Visit my blog for Lua tips and other interesting info | US Sim: The Two
EngiN33R has written:This works perfectly on my server.
In mine too! Thanks again @
EngiN33R: you re the best
"Awp_grey Pro Player"
unlimited- has written:no , no works
look the error
Code:
1
LUA ERROR: sys/lua/adv.lua:13: attempt to index local 'File' (a nil value)
1








Adding Usgn to Table

