GetPlayerKeys
#1

From the wiki:
Код:
public OneSecondTimer()
{
  new keys, updown, leftright;
  for(new playerid = 0; playerid < MAX_PLAYERS; playerid++)
  {
    if(IsPlayerConnected(playerid))
    {
      GetPlayerKeys(playerid, keys, updown, leftright);
 
      if(updown == KEY_UP)
      {
        SendClientMessage(playerid, 0xFF0000AA, "Up key pressed!");
      }
    }
  }
}
I don't recieve any message. I don't know if this is a 0.3 bug, but i use this script in 0.3. What's the problem?
Reply
#2

i'm doing that. lol :P
The callback does work:
Код:
public OneSecondTimer()
{
  new keys, updown, leftright;
  for(new playerid = 0; playerid < MAX_PLAYERS; playerid++)
  {
    if(IsPlayerConnected(playerid))
    {
      GetPlayerKeys(playerid, keys, updown, leftright);
 
      if(updown == KEY_UP)
      {
        SendClientMessage(playerid, 0xFF0000AA, "Up key pressed!");
      }
    }
    SendClientMessage(playerid, GREEN, "Hi :)");
  }
}
And i'm spammed with "Hi "
Reply
#3

Are you spawned?
Reply
#4

Yeah. i spawn before i look at this. In fact, i was using a thingy inside it which set my vehiclespeed every second faster, but that doesn't work, and this exact copy of the wiki also doesn't work.
Reply
#5

Do you tap the upkey or hold it? Holding it should work.
Reply
#6

I hold it. And i've tested the up key, and W key.
Reply
#7

Quote:
Originally Posted by Don Correlli
Are you spawned?
His code doesn't check if the player is spawned.

pawn Код:
if(updown & KEY_UP)
Try that.
Reply
#8

Quote:
Originally Posted by MenaceX^
His code doesn't check if the player is spawned.
And..?

I was asking if he was spawned, because keys UP, DOWN, LEFT and RIGHT can only be detected if player is spawned.
Reply
#9

Quote:
Originally Posted by Don Correlli
Quote:
Originally Posted by MenaceX^
His code doesn't check if the player is spawned.
And..?

I was asking if he was spawned, because keys UP, DOWN, LEFT and RIGHT can only be detected if player is spawned.
No not really.
Reply
#10

Omfg? Why it works now? (half) I don't know what i did, but it does work now. Bugged. And it seems that GetPlayerKeys works on foot with the up, left, right and backward keys and WASD keys, but in a vehicle only with WASD(bug?). << I've tried that, so still i don't know what was the problem, but it's fixed.
Reply
#11

Quote:
Originally Posted by MenaceX^
No not really.
Yep, really.
Reply
#12

Maybe (lol)
Reply
#13

Try with SetTimerEx and not looping through all the players
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)