# Forum

CS2D Scripts Make a players walk reverse

# Make a players walk reverse

4 replies
Goto Page
1
14.09.17 12:45:00 am
Promaster
User
Offline
I need help with creating a curse that make a player walk reverse. Like when they want to walk up, they walks down, and instead of down they are walking up. the same goes for left and right.
edited 1×, last 14.09.17 02:06:35 am
Patch 13.1! Updated. 2018-02-14
14.09.17 01:21:11 pm
_l_l_
User
Offline
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
posx={}

function _j(id)
posx[id]={}
posx[id][1]=1
end

function _m(id,x,y)
table.insert(posx[id],x)
local lol = x-10
if posx[id][#posx[id]]>posx[id][#posx[id]-1] then
parse("setpos "..id.." "..lol.." "..y.."")
end
end

With 1 condition which will make the player move left when he is trying to move right. Add more conditions. Laggy maybe.
16.09.17 12:07:14 am
Promaster
User
Offline
@ _l_l_: Thank you for the answer. To be honest with you, i do not understand the why you did

Code:
1
if posx[id][#posx[id]]>posx[id][#posx[id]-1] then

Patch 13.1! Updated. 2018-02-14
18.09.17 12:56:14 pm
_l_l_
User
Offline
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
29
30
31
32
33
34
35
36
37
38
posx={}
posy={}

function _j(id)
posx[id]={}
posy[id]={}
posx[id][1]=1
posy[id][1]=1
end

function _m(id,x,y)
table.insert(posx[id],x)
table.insert(posy[id],y)
local nq = x-10
local sq = x+10
if posy[id][#posy[id]]==posy[id][#posy[id]-1] then
if posx[id][#posx[id]]>posx[id][#posx[id]-1] then
table.insert(posx[id],nq)
parse("setpos "..id.." "..nq.." "..y.."")
else
table.insert(posx[id],sq)
parse("setpos "..id.." "..sq.." "..y.."")
end
end
local mm = y-10
local em = y+10
if posx[id][#posx[id]]==posx[id][#posx[id]-1] then
if posy[id][#posy[id]]>posy[id][#posy[id]-1] then
table.insert(posy[id],mm)
parse("setpos "..id.." "..x.." "..mm.."")
else
table.insert(posy[id],em)
parse("setpos "..id.." "..x.." "..em.."")
end
end
end
18.09.17 04:21:58 pm
px20
GAME BANNED
Offline
Not effective in my opinion, how about diagonal directions?
1
﻿