help with OnPlayerKeyStateChange - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: help with OnPlayerKeyStateChange (
/showthread.php?tid=105792)
help with OnPlayerKeyStateChange -
KIDUL - 31.10.2009
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;
}
}
Re: help with OnPlayerKeyStateChange -
Danny_Costelo - 31.10.2009
KEY_JUMP? Since when where you able to create new functions?
Re: help with OnPlayerKeyStateChange -
KIDUL - 31.10.2009
Quote:
Originally Posted by |№іі7
KEY_JUMP? Since when where you able to create new functions?
|
sry i dont understand what you want
Re: help with OnPlayerKeyStateChange -
Danny_Costelo - 31.10.2009
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?
Re: help with OnPlayerKeyStateChange -
KIDUL - 31.10.2009
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
Re: help with OnPlayerKeyStateChange -
radhakr - 31.10.2009
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.
Re: help with OnPlayerKeyStateChange -
KIDUL - 31.10.2009
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?)