SA-MP Forums Archive
Special Actions & KeyStates Bug - 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: Special Actions & KeyStates Bug (/showthread.php?tid=109008)



Special Actions & KeyStates Bug - Zeromanster - 17.11.2009

I've made up a system that does this:

If a player has a lighter and a cigarette he can type in /smoke and this would happen for him:

pawn Код:
PlayerActionMessage(playerid,10.0,"takes a lighter and lights up his cigarette");
SetPlayerSpecialAction(playerid,SPECIAL_ACTION_SMOKE_CIGGY);
PlayerSmoking[playerid] = 5;
Once a special action has been applied he can use KEY_FIRE (Left Mouse Button) to smoke a cigarette.

Under the callback OnPlayerKeyStateChage i made this:

pawn Код:
if(newkeys == KEY_FIRE) // LMB
{
  if(PlayerSmoking[playerid] > 1) // He's cigarette is lighted and he has more than 1 smokes remaining
  {
    PlayerSmoking[playerid] -= 1;
    GivePlayerHealth(playerid,2);
    PlayerActionMessage(playerid,10.0,"smokes a cigarette");
  }
  else // He has only one smoke left. He stops smoking.
  {
    PlayerSmoking[playerid] = 0;
    SetPlayerSpecialAction(playerid,SPECIAL_ACTION_NONE);
    PlayerActionMessage(playerid,10.0,"throws the cigarette away");
  }
}
And the bug is:

If a player is runing (SPACE) or walking (ALT) and if he presses (LMB) to smoke, nothing happens.

How can i make that he can smoke while runing or walking ?

Thank you for your answers.


Re: Special Actions & KeyStates Bug - JakeB - 17.11.2009

pawn Код:
if(newkeys & KEY_FIRE) // LMB
Read this.
You may also want to read this.


Re: Special Actions & KeyStates Bug - Zeromanster - 17.11.2009

Quote:
Originally Posted by JakeB
pawn Код:
if(newkeys & KEY_FIRE) // LMB
Read this.
You may also want to read this.
Thanks, it works.