English Teleport Glitch?

5 replies
Goto Page
To the start Previous 1 Next To the start
27.07.16 12:03:22 am
Up
Gripex
User
Offline Off
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

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
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
27.07.16 01:07:52 am
Up
Baloon
GAME BANNED
Offline Off
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
Code:
1
math.rad(player(id,"rot")-180)
27.07.16 01:23:23 am
Up
little bite
BANNED
Offline Off
What you teleport glitch go ask ZxC i think he can help you.
edited 1×, last 27.07.16 05:02:25 am
27.07.16 11:23:52 am
Up
Fraizeraust
Moderator
Offline Off
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.
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
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.
27.07.16 11:50:37 am
Up
Baloon
GAME BANNED
Offline Off
@user Fraizeraust: you are wrong in line 20 to 25 it should be :
Code:
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?
Code:
1
math.rad(player(id,"rot")-180)
or maybe your code works.

Edit: bug fix.
27.07.16 12:04:12 pm
Up
Fraizeraust
Moderator
Offline Off
user Baloon has written:
@user Fraizeraust: 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