KEY_FIRE? - 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: KEY_FIRE? (
/showthread.php?tid=105516)
KEY_FIRE? -
(.Aztec); - 29.10.2009
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]);
}
}
}
Re: KEY_FIRE? -
(.Aztec); - 29.10.2009
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.
Re: KEY_FIRE? -
(.Aztec); - 29.10.2009
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.
Re: KEY_FIRE? -
MenaceX^ - 29.10.2009
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
Re: KEY_FIRE? -
dice7 - 29.10.2009
It gets called when you press and when you release a key
Re: KEY_FIRE? -
Nero_3D - 29.10.2009
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
Re: KEY_FIRE? -
(.Aztec); - 29.10.2009
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.
Re: KEY_FIRE? -
MenaceX^ - 29.10.2009
Why don't you just do
pawn Код:
if(newkeys&KEY_FIRE)
{
// code
}
Re: KEY_FIRE? -
(.Aztec); - 29.10.2009
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.
Re: KEY_FIRE? -
MenaceX^ - 29.10.2009
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..