KEY_FIRE?
#1

Does detecting KEY_FIRE under OnPlayerKeyStateChange work properly? Because in my script, it's not functioning, I tried to debug it, and it seems as if it's not even detecting it correctly..

pawn Код:
else if ((newkeys & (KEY_FIRE)) == (KEY_FIRE))
        {
          SendClientMessage(playerid, red, "works");
          if(bombplaced[playerid] == 1)
          {
            if(GetPlayerWeapon(playerid) == 40)
            {
              new plname[MAX_PLAYER_NAME];
                new year, month,day;
                    getdate(year, month, day);
                    GetPlayerName(playerid, plname, sizeof(plname));
                CreateExplosion(Float:BombX[playerid], Float:BombY[playerid], Float:BombZ[playerid], 6, 10.0);
                SendClientMessage(playerid, red, "Your bomb has been detonated.");
                bombplaced[playerid] = 0;
                DestroyObject(bomb[playerid]);
            }
          }
        }
Reply
#2

Quote:
Originally Posted by Seif_
else if (newkeys & KEY_FIRE)
Still isn't working, if I hold down the fire key, it should be spamming me to fuck, and it's not doing anything.
Reply
#3

Quote:
Originally Posted by Seif_
OnPlayerKeyStateChange only detects when you press a key, it won't work if you hold it. For holding, use a timer with GetPlayerKeys.
Not even working if I click, if it's actually detecting it correctly, it should say "works", but as I stated, it's not.
Reply
#4

Quote:
Originally Posted by Seif_
OnPlayerKeyStateChange only detects when you press a key, it won't work if you hold it. For holding, use a timer with GetPlayerKeys.
Or you both should read the explaination of ****** in wiki.
https://sampwiki.blast.hk/wiki/OnPlayerKeyStateChange
Reply
#5

It gets called when you press and when you release a key
Reply
#6

Quote:
Originally Posted by sizeof(Sky));
Quote:
Originally Posted by Seif_
OnPlayerKeyStateChange only detects when you press a key, it won't work if you hold it. For holding, use a timer with GetPlayerKeys.
Not even working if I click, if it's actually detecting it correctly, it should say "works", but as I stated, it's not.
Then the problem isnt there, maybe some other if statment is preventing the execution of this one
Reply
#7

Seif already answered it for me, apparently I had my KEY_FIRE inside my KEY_SECONDARY_ATTACK, thanks seif.

Quote:
Originally Posted by ♣ ⓐⓢⓢ
Quote:
Originally Posted by sizeof(Sky));
Quote:
Originally Posted by Seif_
OnPlayerKeyStateChange only detects when you press a key, it won't work if you hold it. For holding, use a timer with GetPlayerKeys.
Not even working if I click, if it's actually detecting it correctly, it should say "works", but as I stated, it's not.
Then the problem isnt there, maybe some other if statment is preventing the execution of this one
Bingo.
Reply
#8

Why don't you just do
pawn Код:
if(newkeys&KEY_FIRE)
{
  // code
}
Reply
#9

Quote:
Originally Posted by MenaceX^
Why don't you just do
pawn Код:
if(newkeys&KEY_FIRE)
{
  // code
}
I am now... which is why it's working.
Reply
#10

Quote:
Originally Posted by sizeof(Sky));
Quote:
Originally Posted by MenaceX^
Why don't you just do
pawn Код:
if(newkeys&KEY_FIRE)
{
  // code
}
I am now... which is why it's working.
I ain't sure if it's even possible, because you try to do bitwise and, and equal to..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)