Forum

> > CS2D > Scripts > Check if Shift key is pressed
Forums overviewCS2D overview Scripts overviewLog in to reply

English Check if Shift key is pressed

3 replies
To the start Previous 1 Next To the start

old Re: Check if Shift key is pressed

G3tWr3ck3d
User Off Offline

Quote
I tried to check it but it seems that is not working.

1
2
3
4
5
6
7
8
9
10
11
12
walking = {}

addhook('move','_move')
function _move(id,x,y,walk)
	if player(id,walk) == 1 then
		walking[id] = true
		msg2(id,'You are walking')
	else
		walking[id] = false
		msg2(id,'You are running')
	end
end

It just spams with the you are running statement.

old Re: Check if Shift key is pressed

Rainoth
Moderator Off Offline

Quote
That's because player table has no value "walk".
You can have
1
player(id,"name")
but not
1
player(id,"walk")

The move hook, however, provides that. So all you have to do is check like so:
1
if walk == 1 then -- walking
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview