Special Actions & KeyStates Bug
#1

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.
Reply
#2

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)