Forum

> > CS2D > Scripts > add USGN
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch add USGN

23 Antworten
Seite
Zum Anfang Vorherige 1 2 Nächste Zum Anfang

alt add USGN

GooDCaT
User Off Offline

Zitieren
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
Mehr >

adminlist = {70746,1}

help me?
please

alt Re: add USGN

EngiN33R
Moderator Off Offline

Zitieren
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.

alt Re: add USGN

GooDCaT
User Off Offline

Zitieren
user EngiN33R hat geschrieben
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"

alt Re: add USGN

GooDCaT
User Off Offline

Zitieren
user MikuAuahDark hat geschrieben
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

alt Re: add USGN

GooDCaT
User Off Offline

Zitieren
user EngiN33R hat geschrieben
Is your admin list table called 'adminlist'?


∗ yes
it that way


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

alt Re: add USGN

MikuAuahDark
User Off Offline

Zitieren
user GooDCaT hat geschrieben
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!

alt Re: add USGN

GooDCaT
User Off Offline

Zitieren
user MikuAuahDark hat geschrieben
user GooDCaT hat geschrieben
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 <--

alt Re: add USGN

MikuAuahDark
User Off Offline

Zitieren
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

alt Re: add USGN

GooDCaT
User Off Offline

Zitieren
user MikuAuahDark hat geschrieben
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

alt Re: add USGN

EngiN33R
Moderator Off Offline

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

alt Re: add USGN

MikuAuahDark
User Off Offline

Zitieren
@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

alt Re: add USGN

Infinite Rain
Reviewer Off Offline

Zitieren
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.

alt Re: add USGN

GooDCaT
User Off Offline

Zitieren
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

alt Re: add USGN

EngiN33R
Moderator Off Offline

Zitieren
@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 >

alt Re: add USGN

GooDCaT
User Off Offline

Zitieren
user EngiN33R hat geschrieben
@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 )

alt Re: add USGN

EngiN33R
Moderator Off Offline

Zitieren
My mistake. Should be fixed now.

Code >
Zum Anfang Vorherige 1 2 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht