Forum

> > CS2D > Scripts > Teleport menu
Forums overviewCS2D overview Scripts overviewLog in to reply

English Teleport menu

10 replies
To the start Previous 1 Next To the start

old Teleport menu

Black Wolf
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
administradores = {16270,52331,89308}

addhook("menu","menu")
addhook("serveraction","sa")
addhook("say", "speedpl")
	function speedpl(id, txt)
			for _, usgn in ipairs(adiministradores) do
		function teleport_menu(id)
     menu(id,'teleport,pos 1,pos 2')
end

function sa(id,key)
     if key==3 then
          teleport_menu(id)
     end
end

function menu(id,title,button)
     if (title=='teleport') then
          if button==1 then
               parse('setpos '..id..' '..pos1[1]..' '..pos1[2])
          end
          if button==2 then
               parse('setpos '..id..' '..pos2[1]..' '..pos2[2])
          end
          end
          end

Why this doesn't worK?

old Re: Teleport menu

Black Wolf
User Off Offline

Quote
user Suprise has written
you forgot pos1[1], pos1[2], etc


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
administradores = {16270,52331,89308}

addhook("menu","menu")
addhook("serveraction","sa")
addhook("say", "speedpl")
	function speedpl(id, txt)
			for _, usgn in ipairs(adiministradores) do
		function teleport_menu(id)
     menu(id,'teleport,pos 1,pos 2')
end

function sa(id,key)
     if key==3 then
          teleport_menu(id)
     end
end

function menu(id,title,button)
     if (title=='teleport') then
          if button==1 then
               parse("setpos "..id.." "3500 4000")
          end
          if button==2 then
               parse("setpos "..id.." "3500 4000")
          end
     end
	end
	end
	end
	end
still don't work… -(

old Re: Teleport menu

Suprise
BANNED 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
administradores = {16270,52331,89308}

addhook("menu","menu")
addhook("serveraction","sa")
addhook("say", "speedpl")

function speedpl(id, txt)
		for _, usgn in ipairs(adiministradores) do
end

function teleport_menu(id)
	menu(id,'teleport,pos 1,pos 2')
end

function sa(id,key)
	if key==3 then
		teleport_menu(id)
	end
end

function menu(id,title,button)
	if (title=='teleport') then
		if button==1 then
			parse("setpos "..id.." "3500 4000")
		elseif button==2 then
			parse("setpos "..id.." "3500 4000")
		end
	end
end

one question. The teleport menu works only for admins?

old Re: Teleport menu

Glix
User Off Offline

Quote
user Suprise has written
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
administradores = {16270,52331,89308}

addhook("menu","menu")
addhook("serveraction","sa")
addhook("say", "speedpl")

function speedpl(id, txt)
		for _, usgn in ipairs(adiministradores) do
end

function teleport_menu(id)
	menu(id,'teleport,pos 1,pos 2')
end 

function sa(id,key)
	if key==3 then
		teleport_menu(id)
	end
end

function menu(id,title,button)
	if (title=='teleport') then
		if button==1 then
			parse("setpos "..id.." "3500 4000")
		elseif button==2 then
			parse("setpos "..id.." "3500 4000")
		end
	end
end

one question. The teleport menu works only for admins?


Yes only for admins

old Re: Teleport menu

Jynxxx
User Off Offline

Quote
Try this, didn't test it.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
administradores = {16270,52331,89308}
Player = {pos1 = {3500,4000}, pos2 = {3500,4000}}

addhook("serveraction","sa")
function sa(id,key)
	for _, usgn in ipairs(adiministradores) do
		if player(id,"usgn") == usgn then
			if key==3 then
				menu(id,'teleport,pos 1,pos 2')
			end
		end
	end
end

addhook("menu","menu")
function menu(id,title,button)
	if (title=='teleport') then
		if button==1 then
			parse('setpos '..id..' '..Player.pos1[1]..' '..Player.pos1[2])
		elseif button==2 then
			parse('setpos '..id..' '..Player.pos2[1]..' '..Player.pos2[2])
		end
	end
end

old Re: Teleport menu

Glix
User Off Offline

Quote
user Jynxxx has written
Try this, didn't test it.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
administradores = {16270,52331,89308}
Player = {pos1 = {3500,4000}, pos2 = {3500,4000}}

addhook("serveraction","sa")
function sa(id,key)
	for _, usgn in ipairs(adiministradores) do
		if player(id,"usgn") == usgn then
			if key==3 then
				menu(id,'teleport,pos 1,pos 2')
			end
		end
	end
end

addhook("menu","menu")
function menu(id,title,button)
	if (title=='teleport') then
		if button==1 then
			parse('setpos '..id..' '..Player.pos1[1]..' '..Player.pos1[2])
		elseif button==2 then
			parse('setpos '..id..' '..Player.pos2[1]..' '..Player.pos2[2])
		end
	end
end


LUA ERROR: sys/lua/1.lua:6: bad argument #1 'ipairs' (table expected, got nil)

old Re: Teleport menu

Suprise
BANNED Off Offline

Quote
user Glix has written
LUA ERROR: sys/lua/1.lua:6: bad argument #1 'ipairs' (table expected, got nil)


remove 'i' from the ipairs.

old Re: Teleport menu

Glix
User Off Offline

Quote
user Suprise has written
user Glix has written
LUA ERROR: sys/lua/1.lua:6: bad argument #1 'ipairs' (table expected, got nil)


remove 'i' from the ipairs.


=( STILL DONT WORK…

old Re: Teleport menu

Cure Pikachu
User Off Offline

Quote
There's a typo error at this line:
1
for _, usgn in ipairs(adiministradores)
It should be
1
for _, usgn in ipairs(administradores)
Which is why it's best to avoid giving variables a long name like adiministradores.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview