Forum

> > CS2D > Scripts > Teleport Glitch?
Forums overviewCS2D overview Scripts overviewLog in to reply

English Teleport Glitch?

5 replies
To the start Previous 1 Next To the start

old Teleport Glitch?

Gripex
User Off Offline

Quote
I'm faceing a bug or something like that.. As you guys see down below its a lua that makes me go a while on my rot. Everything is fine but when I add bots or someone joins It goes farther. If you guys can help me I will be very happy

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
addhook("flashlight","genji_shift")
function genji_shift(id)
          genrot[id] = player(id,"rot")
genshift[id]=1
timer(2000,"aaa")
function aaa()
genshift[id] = 0
end
end


addhook("always","genji_move")
function genji_move(id)
for _,id in ipairs(player(0,"table")) do
for _,i in pairs(player(0,"tableliving")) do
if genshift[id]==1 then
local rot = math.rad(genrot[id])
    local c = player(id, "x") + math.sin(rot) * 10
    local d = player(id, "y") - math.cos(rot) * 10
          parse("setpos "..id.." "..c.." "..d)
		  if player(id,"tilex") == player(i,"tilex") and player(id,"tiley") == player(i,"tiley") and id ~= i then
	genshift[id]=0	  
	end
	end
	end
	end
	end

old Re: Teleport Glitch?

Baloon
GAME BANNED Off Offline

Quote
In always hook, there's no such id parameter in line 13 . You are right in line 14, you should loops the id.

In radians, it should be
1
math.rad(player(id,"rot")-180)

old Re: Teleport Glitch?

little bite
BANNED Off Offline

Quote
What you teleport glitch go ask ZxC i think he can help you.
edited 1×, last 27.07.16 05:02:25 am

old Re: Teleport Glitch?

GeoB99
Moderator Off Offline

Quote
What do you mean by "when I add bots or someone joins it goes farther"? I assume the player movement behaves incorrectly while pressing F, ain't it?

There's a work around with your script since the whole indentation is just a mess and couldn't be arsed to fix it standalone thus try this instead.
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
genshift = {}

addhook('flashlight', 'genji_shift')

function genji_shift(id)
  genshift[ id ] = 1
  timer(2000, 'aaa')
end

function aaa()
  genshift[ id ] = 0
end

addhook('always', 'genji_move')

function genji_move()
  for _, p in ipairs( player(0, 'tableliving') ) do
    if ( genshift[ id ] == 1 ) then
      local rot = math.rad( player(p, 'rot') - 90 )
      local X = player(p, 'x') + math.cos( rot ) * 12
      local Y = player(p, 'y') + math.sin( rot ) * 12
      
      if ( tile(X, Y, 'walkable') ) then
        parse('setpos ' .. p .. ' ' .. X .. ' ' .. Y)
      end
    end
  end
end
P.S: By any chance if this code returns an error then I might suggest someone to fix it. Apologies for this.

old Re: Teleport Glitch?

Baloon
GAME BANNED Off Offline

Quote
@user GeoB99: you are wrong in line 20 to 25 it should be :
1
2
3
4
5
6
local x, y = player(id,"x"), player(id,"y")
local xe, ye = -math.cos(rot)*16, math.sin(rot)*16
local tx, ty = math.floor((16+x+xe)/32), math.floor((16+y+ye)/32)
if tile(tx,ty,"walkable") then
 parse("setpos "..id.." "..x+xe.." "..y+ye)
end
At line 23 on your code,
x
and
y
is in pixels, you cannot use it for tile function, lol

And, making rotation into radian, I don't know, may my code works?
1
math.rad(player(id,"rot")-180)
or maybe your code works.

Edit: bug fix.

old Re: Teleport Glitch?

GeoB99
Moderator Off Offline

Quote
user Baloon has written
@user GeoB99: At line 23 on your code,
x
and
y
is in pixels, you cannot use it for tile function, lol.

I believe so. If that's the case
math.floor
will just solve it without a hassle so I don't see what's such of a big problem. By the way you have got to stop pushing the thread it's against the rules and the thread is just posted recently.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview