KEY_ACTION?
#1

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 Код:
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
if(newkeys & KEY_ACTION)
{
//so on...
}
}
Reply
#2

pawn Код:
if(newkeys == KEY_ACTION)
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
//so on...
}
}
Reply
#3

Quote:
Originally Posted by Riddick94
Посмотреть сообщение
pawn Код:
if(newkeys == KEY_ACTION)
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
//so on...
}
}
Nope that doesnt solve it
Still same problem
Reply
#4

Try this:
pawn Код:
//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
}
Reply
#5

No still doesnt work
is annoying why the hell doesnt it work ??
Reply
#6

KEY_ACTION works only onfoot I think...
Reply
#7

Quote:
Originally Posted by [GF]Sasino97
Посмотреть сообщение
KEY_ACTION works only onfoot I think...
You think?
https://sampwiki.blast.hk/wiki/GetPlayerKeys
Better stop thinking it's your bad side.

Topic:
Tell me what you need to do with vehicle and what key..
Reply
#8

Quote:
Originally Posted by Riddick94
Посмотреть сообщение
You think?
https://sampwiki.blast.hk/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).
Reply
#9

pawn Код:
#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.
Reply
#10

Keys On-Foot and Incar aren't same.
Reply
#11

I lost about something.. add in pressed keys:
pawn Код:
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER)return false;
It'll work only for driver in car.
Reply
#12

Thanks dude it worked but just the engine is with W but ill change it to something else
THANKS
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)