help with OnPlayerKeyStateChange
#1

I just wanted to make a speed boost for the jump key but ingame when you press the key nothing happens ;S how can i fix this ?
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(IsPlayerInAnyVehicle(playerid))
{
new veh = GetPlayerVehicleID(playerid);
if(newkeys & KEY_JUMP)
{
new Float:xf;
new Float:yf;
new Float:zf;
GetVehicleVelocity(veh,xf,yf,zf);
SetVehicleVelocity(veh,xf*1.3,yf*1.3,zf*1.3);
}
return 1;
}
}
Reply
#2

KEY_JUMP? Since when where you able to create new functions?
Reply
#3

Quote:
Originally Posted by |№іі7
KEY_JUMP? Since when where you able to create new functions?
sry i dont understand what you want
Reply
#4

Quote:
Originally Posted by KIDUL
Quote:
Originally Posted by |№іі7
KEY_JUMP? Since when where you able to create new functions?
sry i dont understand what you want
Oh, I'm sorry, KEY_JUMP does exist

That code looks correct to me, are you testing it whilst in a vehicle?
Reply
#5

Quote:
Originally Posted by |№іі7
Quote:
Originally Posted by KIDUL
Quote:
Originally Posted by |№іі7
KEY_JUMP? Since when where you able to create new functions?
sry i dont understand what you want
Oh, I'm sorry, KEY_JUMP does exist

That code looks correct to me, are you testing it whilst in a vehicle?
yes i do but nothing happens , but i noticed that there is something wrong with the keys...for example when i do it with KEY_CROUCH , it works ingame with the horn key
Reply
#6

I made this speedboost yesterday. It works when you press the mouse button in a vehicle:

pawn Код:
#define PRESSED(%0) (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if (PRESSED(KEY_FIRE))
    {
    if(!IsPlayerInAnyVehicle(playerid)) return 0;
    new Float:Velocity[3];
        GetVehicleVelocity(GetPlayerVehicleID(playerid), Velocity[0], Velocity[1], Velocity[2]);
        SetVehicleVelocity(GetPlayerVehicleID(playerid), Velocity[0]*1.3, Velocity[1]*1.3, Velocity[2]*1.3);
    }
    return 1;
}
I tried changing the key to KEY_JUMP but it didn't work for me either.. maybe it is something about the fact that you are in a vehicle so you can't jump? I'm not sure.
Reply
#7

Quote:
Originally Posted by radhakr
I made this speedboost yesterday. It works when you press the mouse button in a vehicle:

pawn Код:
#define PRESSED(%0) (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if (PRESSED(KEY_FIRE))
    {
    if(!IsPlayerInAnyVehicle(playerid)) return 0;
    new Float:Velocity[3];
        GetVehicleVelocity(GetPlayerVehicleID(playerid), Velocity[0], Velocity[1], Velocity[2]);
        SetVehicleVelocity(GetPlayerVehicleID(playerid), Velocity[0]*1.3, Velocity[1]*1.3, Velocity[2]*1.3);
    }
    return 1;
}
I tried changing the key to KEY_JUMP but it didn't work for me either.. maybe it is something about the fact that you are in a vehicle so you can't jump? I'm not sure.
I tried many other keys now and it seems do be that most of the keys are bugged or something (KEY_JUMP = KEY_ANALOG_DOWN....lol?)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)