Forum

> > CS2D > Scripts > add USGN
Forums overviewCS2D overview Scripts overviewLog in to reply

English add USGN

23 replies
Page
To the start Previous 1 2 Next To the start

old add USGN

GooDCaT
User Off Offline

Quote
Heeey !

I wanted a script that was so
You typed "@give <USGN>"
Or Something Similar ...
> Not < I want a script like, Please Do not insist

adminlist = {70746}

@give <USGN>

exemple :

@give 1
More >

adminlist = {70746,1}

help me?
please

old Re: add USGN

EngiN33R
Moderator Off Offline

Quote
1
2
3
4
5
6
7
8
addhook("say","insertusgn",10001)
function insertusgn(id,t)
	if (t:sub(1,5)=="@give") then
		local usgn=tonumber(t:sub(7))
		table.insert(adminlist,usgn)
		msg2(id,usgn.." has been promoted to admin!")
	end
end

You will have to make it executable by admins only yourself.

old Re: add USGN

GooDCaT
User Off Offline

Quote
user EngiN33R has written
1
2
3
4
5
6
7
8
addhook("say","insertusgn",10001)
function insertusgn(id,t)
	if (t:sub(1,5)=="@give") then
		local usgn=tonumber(t:sub(7))
		table.insert(adminlist,usgn)
		msg2(id,usgn.." has been promoted to admin!")
	end
end

You will have to make it executable by admins only yourself.


yeah, it works
more I type "give @ 56421"
and USGN not get to "adminlist"
...

when I type "@give <USGN>" so the message appears
But when the USGN is not in "adminlist"

old Re: add USGN

GooDCaT
User Off Offline

Quote
user MikuAuahDark has written
nothing wrong with that script. it should going to adminlist! if not tell user EngiN33R!


it works
but when I type the command with USGN
USGN to what I write is not going to adminlist

old Re: add USGN

GooDCaT
User Off Offline

Quote
user EngiN33R has written
Is your admin list table called 'adminlist'?


∗ yes
it that way


adminlist = {70746}
Test to see if the script actually works

old Re: add USGN

MikuAuahDark
User Off Offline

Quote
user GooDCaT has written
Test to see if the script actually works
looks fine for me, i test it! trying to add this after 1 end:
1
2
3
for i,v in pairs(adminlist) do
	print(string.char(169).."Admin USGN: "..v)
end
that code above is to test, is working or not!

old Re: add USGN

GooDCaT
User Off Offline

Quote
user MikuAuahDark has written
user GooDCaT has written
Test to see if the script actually works
looks fine for me, i test it! trying to add this after 1 end:
1
2
3
for i,v in pairs(adminlist) do
	print(string.char(169).."Admin USGN: "..v)
end
that code above is to test, is working or not!


1
2
3
4
5
6
7
8
9
10
11
12
13
adminlist = {}

addhook("say","insertusgn",10001)
function insertusgn(id,t)
     if (t:sub(1,5)=="@give") then
          local usgn=tonumber(t:sub(7))
          table.insert(adminlist,usgn)
          msg2(id,usgn.." has been promoted to admin!")
          for i,v in pairs(adminlist) do
          print(string.char(169).."Admin USGN: "..v)
          end
     end
end

no works

please help me URGENT <--

old Re: add USGN

MikuAuahDark
User Off Offline

Quote
hmm not like that:
1
2
3
4
5
6
7
8
9
10
11
12
13
adminlist = {}

addhook("say","insertusgn",10001)
function insertusgn(id,t)
	if (t:sub(1,5)=="@give") then
		local usgn=tonumber(t:sub(7))
		table.insert(adminlist,usgn)
		msg2(id,usgn.." has been promoted to admin!")
	end
	for i,v in pairs(adminlist) do
		print(string.char(169).."Admin USGN: "..v)
	end
end
test that code. and see what console says

old Re: add USGN

GooDCaT
User Off Offline

Quote
user MikuAuahDark has written
hmm not like that:
1
2
3
4
5
6
7
8
9
10
11
12
13
adminlist = {}

addhook("say","insertusgn",10001)
function insertusgn(id,t)
	if (t:sub(1,5)=="@give") then
		local usgn=tonumber(t:sub(7))
		table.insert(adminlist,usgn)
		msg2(id,usgn.." has been promoted to admin!")
	end
	for i,v in pairs(adminlist) do
		print(string.char(169).."Admin USGN: "..v)
	end
end
test that code. and see what console says


I typed the command with USGN
and when I look at the "adminlist," there was not USGN
help me, urgent, pleaseI implore

old Re: add USGN

EngiN33R
Moderator Off Offline

Quote
Well, it won't insert the USGN ID into the script text, if you mean that. The script works perfectly.

old Re: add USGN

MikuAuahDark
User Off Offline

Quote
@user GooDCaT: oo hmm. so that is you mean? uuu. the script works perfectly!
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
adminlist = {}

addhook("second","addallusgn")
function addallusgn()
	function totable(t,m)
		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
	openfile=io.open("sys/lua/adminlist.txt")
	for line in openfile:lines do
		parses=totable(line)
		if line~=nil then
			if tonumber(parses[1])~=nil then
				table.insert(adminlist,tonumber(parses[1]))
			end
		end
	end
	freehook("second","addallusgn")
end

addhook("say","insertusgn",10001)
function insertusgn(id,t)
	if (t:sub(1,5)=="@give") then
		local usgn=tonumber(t:sub(7))
		table.insert(adminlist,usgn)
		msg2(id,usgn.." has been promoted to admin!")
		saveusgn = io.open("sys/lua/adminlistfile.txt")
		saveusgn:write("\n"..usgn)
	end
end
untested. you need a emptyfile called adminlist.txt in sys/lua

old Re: add USGN

Infinite Rain
Reviewer Off Offline

Quote
Actually it is because of Engi's script don't take effect on file.
So after server close table will be the same as before.

That USGN get admin only before mapchange, or serve close.

old Re: add USGN

GooDCaT
User Off Offline

Quote
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
adminlist = {}

addhook("second","addallusgn")
function addallusgn()
     function totable(t,m)
          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
     openfile=io.open("sys/lua/adminlist.txt")
     for line in openfile:lines do
          parses=totable(line)
          if line~=nil then
               if tonumber(parses[1])~=nil then
                    table.insert(adminlist,tonumber(parses[1]))
               end
          end
     end
     freehook("second","addallusgn")
end

addhook("say","insertusgn",10001)
function insertusgn(id,t)
     if (t:sub(1,5)=="@give") then
          local usgn=tonumber(t:sub(7))
          table.insert(adminlist,usgn)
          msg2(id,usgn.." has been promoted to admin!")
          saveusgn = io.open("sys/lua/adminlistfile.txt")
          saveusgn:write("\n"..usgn)
     end
end


I like what you said I followed, and in the end gave two errors


LUA ERROR: sys / moon / fail.lua: 14: function arguments expected near 'the'
and other error of the word "Parses", line 15

old Re: add USGN

EngiN33R
Moderator Off Offline

Quote
@user MikuAuahDark: I haven't suggested to make it like this and I'm not sure if user GooDCaT wanted that initially. Nevertheless, since he approves, I haven't seen code messier than this in a while. You don't need to add a second hook, do everything inside it and then free it. Better version - USGN reading function is executed upon first script execution.

Code >

old Re: add USGN

GooDCaT
User Off Offline

Quote
user EngiN33R has written
@user MikuAuahDark: I haven't suggested to make it like this and I'm not sure if user GooDCaT wanted that initially. Nevertheless, since he approves, I haven't seen code messier than this in a while. You don't need to add a second hook, do everything inside it and then free it. Better version - USGN reading function is executed upon first script execution.

Code >



i type :

√ @give 1

and the error appears

× LUA ERROR: sys/lua/server.lua:34: attempt to index global 'saveusgn' (a nil value)

( help me URGENT )

old Re: add USGN

EngiN33R
Moderator Off Offline

Quote
My mistake. Should be fixed now.

Code >
To the start Previous 1 2 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview