GetPlayerKeys - 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: GetPlayerKeys (
/showthread.php?tid=96343)
GetPlayerKeys -
Remi-X - 07.09.2009
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?
Re: GetPlayerKeys -
Remi-X - 07.09.2009
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

"
Re: GetPlayerKeys -
Correlli - 07.09.2009
Are you spawned?
Re: GetPlayerKeys -
Remi-X - 07.09.2009
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.
Re: GetPlayerKeys -
Tr1viUm - 07.09.2009
Do you tap the upkey or hold it? Holding it should work.
Re: GetPlayerKeys -
Remi-X - 07.09.2009
I hold it. And i've tested the up key, and W key.
Re: GetPlayerKeys -
MenaceX^ - 07.09.2009
Quote:
Originally Posted by Don Correlli
Are you spawned?
|
His code doesn't check if the player is spawned.
Try that.
Re: GetPlayerKeys -
Correlli - 07.09.2009
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.
Re: GetPlayerKeys -
MenaceX^ - 07.09.2009
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.
Re: GetPlayerKeys -
Remi-X - 07.09.2009
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.
Re: GetPlayerKeys -
Correlli - 07.09.2009
Quote:
Originally Posted by MenaceX^
No not really.
|
Yep, really.
Re: GetPlayerKeys -
Remi-X - 07.09.2009
Maybe (lol)
Re: GetPlayerKeys -
dice7 - 07.09.2009
Try with SetTimerEx and not looping through all the players