OnPlayerKeyStateChange
#1

I have problem, when i press "S" my car jump, but i want that my car jump with "SHIFT" or "H"

Here is code:

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(PRESSED(KEY_FIRE))
    {
        new vehid = GetPlayerVehicleID(playerid);
        new model = GetVehicleModel(vehid);
        if(model == 522 || model == 461 || model == 463 || model == 468 || model == 523)
        {
            new Float:Velocity[3];
            GetVehicleVelocity(vehid, Velocity[0], Velocity[1], Velocity[2]);
            if(Velocity[0] <1.3  && Velocity[1] < 1.3 && Velocity[0] > -1.3 && Velocity[1] > -1.3)
            {
                SetVehicleVelocity(vehid, Velocity[0]*2, Velocity[1]*2, 0.0);
                if(countpos[playerid] == 0)
                {
                    countpos[playerid] = 1;
                    if(model != 468)
                    {
                        Flame[playerid][0] = CreateObject(18693, 0.0, 0.0, 0.0, 0.0, 0, 0, 0);
                        Flame[playerid][1] = CreateObject(18693, 0.0, 0.0, 0.0, 0.0, 0, 0, 0);
                        if(model == 522)
                        {
                            AttachObjectToVehicle(Flame[playerid][0], vehid, 0.194999, 0.439999, 0.044999, 86.429962, 0.000000, 0.000000);
                            AttachObjectToVehicle(Flame[playerid][1], vehid, -0.204999, 0.439999, 0.044999, 86.429962, 0.000000, 0.000000);
                        }
                        else if(model == 461)
                        {
                            AttachObjectToVehicle(Flame[playerid][0], vehid, -0.354999, 0.374999, -0.164999, 84.419967, 3.645001, 0.000000);
                            AttachObjectToVehicle(Flame[playerid][1], vehid, 0.135000, 0.374999, -0.164999, 84.419967, 3.645001, 0.000000);
                        }
                        else if(model == 463)
                        {
                            AttachObjectToVehicle(Flame[playerid][0], vehid, 0.164999, 0.909999, -0.379999, 86.429962, 3.645001, 0.000000);
                            AttachObjectToVehicle(Flame[playerid][1], vehid, -0.419999, 0.909999, -0.379999, 86.429962, 3.645001, 0.000000);
                        }
                        else if(model == 523)
                        {
                            AttachObjectToVehicle(Flame[playerid][0], vehid, -0.345999, 0.459999, -0.141999, 89.444953, 3.645001, 0.000000);
                            AttachObjectToVehicle(Flame[playerid][1], vehid, 0.119000, 0.459999, -0.141999, 89.444953, 3.645001, 0.000000);
                        }
                    }
                    else
                    {
                        Flame[playerid][0] = CreateObject(18693, 0.0, 0.0, 0.0, 0.0, 0, 0, 0);
                        AttachObjectToVehicle(Flame[playerid][0], vehid, -0.095999, 0.734999, 0.159999, 90.449951, 3.645001, 0.000000);
                    }
                }
            }
        }
    }
    if (PRESSED(KEY_JUMP))
    {
        if(IsPlayerInAnyVehicle(playerid))
        SetVehicleVelocity(GetPlayerVehicleID(playerid), 0.0, 0.0, 0.2);
    }
}
Reply
#2

heres a list of all KEY_ constants:
https://sampwiki.blast.hk/wiki/GetPlayerKeys
you only need to change this line
Код:
if(PRESSED(KEY_FIRE))
to
Код:
if(PRESSED(KEY_CROUCH))
in a vehicle the keys are asigned slightly different than on foot...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)