SA-MP Forums Archive
Detect w - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Detect w (/showthread.php?tid=456807)



Detect w - Harry_F. - 07.08.2013

I am wondering, is it possible/how to detect if player is pressing W button. I've tried with KEY_UP, but it doesnt work like it should be... - https://sampwiki.blast.hk/wiki/Keys

I am trying to detect two keys pressed, as I stated above one of them is W or KEY_UP button. I've also tried it on many other ways.. Script compiles perfectly but when I test it in game, it just doesnt work.


Re: Detect w - StuartD - 07.08.2013

Try KEY_SPRINT


Re: Detect w - Harry_F. - 07.08.2013

It detects SPACE, not W. W is for slow running ( not fast ).

I think it cant be anything else but KEY_UP for default settings of W, I just want to know how to use it or how to make it usable since currently it doesnt work for me.


Re: Detect w - Vince - 07.08.2013

Movement keys do not trigger OnPlayerKeyStateChange. If you want to check you need OnPlayerUpdate. However, you cannot detect the 'W' key specifically, you can only detect KEY_UP. KEY_UP happens to be bound to Z in my game. (Azerty keyboard).


Re: Detect w - FUDDS - 07.08.2013

Use GetPlayerKeys. UpDown part will detect W and S keys. Using OnPlayerKeyStateChange won't work as it doesn't register directional keys


Re: Detect w - Harry_F. - 07.08.2013

Quote:

Movement keys do not trigger OnPlayerKeyStateChange. If you want to check you need OnPlayerUpdate. However, you cannot detect the 'W' key specifically, you can only detect KEY_UP. KEY_UP happens to be bound to Z in my game. (Azerty keyboard).

I only wanted to detect default of KEY_UP - W.

Quote:

Use GetPlayerKeys. UpDown part will detect W and S keys. Using OnPlayerKeyStateChange won't work as it doesn't register directional keys

How could I combinate UpDown, LeftRight part if I want to detect two diffrent keys while holding?

Anyways I want to detect when player is using W to move/walk/slow run.


Re: Detect w - Harry_F. - 07.08.2013

Quote:

You can't detect specific keys, you can only detect actions bound to keys but you have no way to know what keys those actions are bound to. So for some people KEY_SPRINT might be "w", but for others it might not, you can't know.

Bro, I know that, I wanted a default keys, most of the people dont change them, I would say 99%.. Why changing them when you got used to default in SA singleplayer..


Re: Detect w - Harry_F. - 08.08.2013

Why people would change controls? Default controls are much easier to use than edited ones. Anyways, I've changed my mind, how could I make stock to detect if player has moved/ran or smthing..


Re: Detect w - Vince - 08.08.2013

Dude, did you even read my previous post? I, for example, have an Azerty keyboard which means I control movement with ZQSD instead of WASD (click here). Several other countries use their own layouts as well.

Anyway, include the key definitions in every message sent to the player. So instead of writing 'Press W to do stuff' you write 'Press ~k~~GO_FORWARD~ to do stuff'.


Re: Detect w - Harry_F. - 08.08.2013

Ppl, are you gonna argue with me or help. Okay I made a misstake. I apology, not everyone has WASD, but I still want to detect if player has moved if I cant detect the keys they press to move...

EDIT: I just found one by Misco and it works perfectly, solved my problem. Thanks anyways for your time.. You may close this.