[help] KeyStateChange - 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] KeyStateChange (
/showthread.php?tid=109583)
[help] KeyStateChange -
Matthew_Murdoch - 21.11.2009
Is it possible to use Shift/KEY_JUMP to start
AND stop a engine.
This is my code which doesnt work, completely bugged.
if(newkeys == KEY_JUMP && EngineStatus[GetPlayerVehicleID(playerid)] == 0)
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
TogglePlayerControllable(playerid, 1);
EnginStatus[GetPlayerVehicleID(playerid)] = 1;
PlayerActionMessage(playerid,15.0,"turns on the engine");
}
}
if(newkeys == KEY_JUMP && EngineStatus[GetPlayerVehicleID(playerid)] != 0)
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
TogglePlayerControllable(playerid,0);
EngineStatus[GetPlayerVehicleID(playerid)] = 0;
PlayerActionMessage(playerid,15.0,"turns off the engine");
}
}
sorry about no indentation, but indentation is perfect in my .pwn.
Re: [help] KeyStateChange -
Matthew_Murdoch - 21.11.2009
?
Re: [help] KeyStateChange -
homijs - 21.11.2009
It is possible
I saw it on one GM
Re: [help] KeyStateChange -
dice7 - 21.11.2009
Is there a reason you can't test it ?
Re: [help] KeyStateChange -
member - 21.11.2009
Try this:
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
if ((newkeys & KEY_JUMP) && !(oldkeys & KEY_JUMP))
{
if(EngineStatus[GetPlayerVehicleID(playerid)] == 0)
{
TogglePlayerControllable(playerid, 1);
EnginStatus[GetPlayerVehicleID(playerid)] = 1;
PlayerActionMessage(playerid,15.0,"turns on the engine");
}
else
{
TogglePlayerControllable(playerid,0);
EngineStatus[GetPlayerVehicleID(playerid)] = 0;
PlayerActionMessage(playerid,15.0,"turns off the engine");
}
}
}
return 1;
}