14.02.2015, 08:06
This is a really simple guide to find the forward and reverse keys. Seriously. It's that simple.
Step 1: First we decide, why are you reading this guide? Because, by default, W and S do not register under GetPlayerKeys...or do they?
Step 2: We can take a look at the Keys wiki found here: https://sampwiki.blast.hk/wiki/Keys
If you look closely, You will see VEHICLE_ACCELERATE and VEHICLE_BRAKE. (I personally made some corrections to fix WSAD showing up as KEY_UP, KEY_DOWN, etc.)
Step 3: Now we get to our scripting. First of all, we will be using GetPlayerKeys, however, instead of the up/down parameter, we are going to be getting keys. The reason of this is because the key value for accelerate and brake must be collected from their input values, which is returned from the keys paramater.
Since we are trying to obtain the information while in a vehicle, you will need to check if a player is in a vehicle with IsPlayerInVehicle, then as the wiki page shows, we need to check that the value of keys is equal to accelerate ( 8 ) or brake ( 32 ).
The simplest way I found was simply to use:
Thank you for reading, and I hope you learned something today.
Step 1: First we decide, why are you reading this guide? Because, by default, W and S do not register under GetPlayerKeys...or do they?
Step 2: We can take a look at the Keys wiki found here: https://sampwiki.blast.hk/wiki/Keys
If you look closely, You will see VEHICLE_ACCELERATE and VEHICLE_BRAKE. (I personally made some corrections to fix WSAD showing up as KEY_UP, KEY_DOWN, etc.)
Step 3: Now we get to our scripting. First of all, we will be using GetPlayerKeys, however, instead of the up/down parameter, we are going to be getting keys. The reason of this is because the key value for accelerate and brake must be collected from their input values, which is returned from the keys paramater.
pawn Код:
new keys, ud, lr;
GetPlayerKeys(playerid, keys, ud, lr);
The simplest way I found was simply to use:
pawn Код:
if(keys == 8)
//or
if(keys == 32)