SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 09/03/2011, 07:17 PM   #1
park4bmx
High-roller
 
park4bmx's Avatar
 
Join Date: Dec 2009
Location: Samokov,Bulgaria
Posts: 2,361
Reputation: 240
Default KEY_ACTION?

Hi
I got this probblem where when i press the action-key it doesnt work but when i press "S" it works.
How can that be fixed ?

The Code
pawn Code:
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
if(newkeys & KEY_ACTION)
{
//so on...
}
}
park4bmx is offline  
Old 09/03/2011, 07:34 PM   #2
Riddick94
Banned
 
Join Date: Mar 2010
Location: Poland
Posts: 1,767
Reputation: 223
Default Re: KEY_ACTION?

pawn Code:
if(newkeys == KEY_ACTION)
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
//so on...
}
}
Riddick94 is offline  
Old 09/03/2011, 07:51 PM   #3
park4bmx
High-roller
 
park4bmx's Avatar
 
Join Date: Dec 2009
Location: Samokov,Bulgaria
Posts: 2,361
Reputation: 240
Default Re: KEY_ACTION?

Quote:
Originally Posted by Riddick94 View Post
pawn Code:
if(newkeys == KEY_ACTION)
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
//so on...
}
}
Nope that doesnt solve it
Still same problem
park4bmx is offline  
Old 09/03/2011, 07:52 PM   #4
alpha500delta
High-roller
 
alpha500delta's Avatar
 
Join Date: Feb 2010
Posts: 1,152
Reputation: 91
Default Re: KEY_ACTION?

Try this:
pawn Code:
//Somewhere at the top, under your includes
#define PRESSED(%0) \
    (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))

//Under OnPlayerKeyStateChange
new playerState = GetPlayerState(playerid);
if(PRESSED(KEY_ACTION) && playerState == PLAYER_STATE_DRIVER)
{
    //Put your code here
}
__________________
Skype: Alpha500delta | Steam: Alpha500delta
alpha500delta is offline  
Old 10/03/2011, 02:56 PM   #5
park4bmx
High-roller
 
park4bmx's Avatar
 
Join Date: Dec 2009
Location: Samokov,Bulgaria
Posts: 2,361
Reputation: 240
Default Re: KEY_ACTION?

No still doesnt work
is annoying why the hell doesnt it work ??
park4bmx is offline  
Old 10/03/2011, 02:58 PM   #6
Sasino97
High-roller
 
Sasino97's Avatar
 
Join Date: Dec 2010
Location: Tampa, FL
Posts: 1,413
Reputation: 139
Default Re: KEY_ACTION?

KEY_ACTION works only onfoot I think...
__________________
Sasino97 is offline  
Old 10/03/2011, 03:09 PM   #7
Riddick94
Banned
 
Join Date: Mar 2010
Location: Poland
Posts: 1,767
Reputation: 223
Default Re: KEY_ACTION?

Quote:
Originally Posted by [GF]Sasino97 View Post
KEY_ACTION works only onfoot I think...
You think?
http://wiki.sa-mp.com/wiki/GetPlayerKeys
Better stop thinking it's your bad side.

Topic:
Tell me what you need to do with vehicle and what key..
Riddick94 is offline  
Old 10/03/2011, 03:16 PM   #8
park4bmx
High-roller
 
park4bmx's Avatar
 
Join Date: Dec 2009
Location: Samokov,Bulgaria
Posts: 2,361
Reputation: 240
Default Re: KEY_ACTION?

Quote:
Originally Posted by Riddick94 View Post
You think?
http://wiki.sa-mp.com/wiki/GetPlayerKeys
Better stop thinking it's your bad side.

Topic:
Tell me what you need to do with vehicle and what key..
ok basically i want it when the player presses the key number 2the cars lights turn On/Off (No need to script the lights i got it allredy).
and then i got a another key which will be Shift to start up the car's engine (No need to script the Engine i got it allredy).
park4bmx is offline  
Old 10/03/2011, 04:02 PM   #9
Riddick94
Banned
 
Join Date: Mar 2010
Location: Poland
Posts: 1,767
Reputation: 223
Default Re: KEY_ACTION?

pawn Code:
#include <a_samp>

#define PRESSED(%0) (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    new engine, lights, alarm, doors, bonnet, boot, objective;
    GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective);

    if(PRESSED(KEY_SPRINT))
    {
        if(!engine)SetVehicleParamsEx(GetPlayerVehicleID(playerid), VEHICLE_PARAMS_ON, lights, alarm, doors, bonnet, boot, objective);
        else SetVehicleParamsEx(GetPlayerVehicleID(playerid), VEHICLE_PARAMS_OFF, lights, alarm, doors, bonnet, boot, objective);
    }

    if(PRESSED(KEY_SUBMISSION))
    {
        if(!lights)SetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, VEHICLE_PARAMS_ON, alarm, doors, bonnet, boot, objective);
        else SetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, VEHICLE_PARAMS_OFF, alarm, doors, bonnet, boot, objective);
    }
    return true;
}

Check this out.
Riddick94 is offline  
Old 10/03/2011, 04:12 PM   #10
Mean
High-roller
 
Join Date: Jul 2010
Location: 14th annual lemon party
Posts: 2,726
Reputation: 229
Default Re: KEY_ACTION?

Keys On-Foot and Incar aren't same.
__________________
I'm pretty much the creator of the PUB: macro used in many scripts today, therefore I'm a legitimate genius.

Ground breaking stuff
Quote:
Originally Posted by ******
I've met Mean on a few occasions in real life, a true genius and a 400 pound all-muscle gorilla alpha male. He has had a great influence on my life.
Quote:
Originally Posted by Kalcor
I don't know where I'd be today without Mean. He has helped me through some tough times in my life. He always brings a smile to my face. Such a positive lad!
Mean is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT. The time now is 03:38 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.