SA-MP Forums Archive
OnPlayerKeyStateChange NOT working! - 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: OnPlayerKeyStateChange NOT working! (/showthread.php?tid=103846)



OnPlayerKeyStateChange NOT working! - Andom - 21.10.2009

Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	if(newkeys & KEY_LEFT)
	{
		print("Player has pressed KEY_LEFT");
	}
	if(newkeys & KEY_RIGHT)
	{
		print("Player has pressed KEY_RIGHT");
	}
	if(newkeys & KEY_SPRINT)
	{
		print("Player has pressed KEY_SPRINT");
	}
	if(newkeys & KEY_SPRINT)
	{
		print("Player has pressed KEY_SPRINT");
	}
	if(newkeys & KEY_SECONDARY_ATTACK)
	{
		print("Player has pressed KEY_SECONDARY_ATTACK");
	}
	return 1;
}
Problem:

I press key left - nothing hapends.
I press key right - nothing hapends.
I press key shift - nothing hapends.
I press key enter - it prints "Player has pressed KEY_SECONDARY_ATTACK".


Re: OnPlayerKeyStateChange NOT working! - MenaceX^ - 21.10.2009

Use wiki, ****** posted a big explaination there.


Re: OnPlayerKeyStateChange NOT working! - dice7 - 21.10.2009

Left, right, up and down are not processed by OnPlayerKeyStateChange, and KEY_SPRINT is space, not shift


Re: OnPlayerKeyStateChange NOT working! - Andom - 21.10.2009

Quote:
Originally Posted by dice7
Left, right, up and down are not processed by OnPlayerKeyStateChange, and KEY_SPRINT is space, not shift
Thanks you, but how can you check if a players pressed keys like → ?

Quote:
Originally Posted by MenaceX^
Use wiki, ****** posted a big explaination there.
Can you give me a link? i cannot find it there.


Re: OnPlayerKeyStateChange NOT working! - dice7 - 21.10.2009

You can't, only keys like in single player aka these
https://sampwiki.blast.hk/wiki/GetPlayerKeys#Key_List


Re: OnPlayerKeyStateChange NOT working! - MenaceX^ - 21.10.2009

Quote:
Originally Posted by [NL
WackoX ]
Quote:
Originally Posted by dice7
Left, right, up and down are not processed by OnPlayerKeyStateChange, and KEY_SPRINT is space, not shift
Thanks you, but how can you check if a players pressed keys like → ?

Quote:
Originally Posted by MenaceX^
Use wiki, ****** posted a big explaination there.
Can you give me a link? i cannot find it there.
Search better, it's like a poor excuse because you just write the address, a slash and then the public name.
Quote:
Originally Posted by dice7
You can't, only keys like in single player aka these
https://sampwiki.blast.hk/wiki/GetPlayerKeys#Key_List
Yes he can. I saw it somewhere there.


Re: OnPlayerKeyStateChange NOT working! - Andom - 21.10.2009

Quote:
Originally Posted by MenaceX^
Quote:
Originally Posted by [NL
WackoX ]
Quote:
Originally Posted by dice7
Left, right, up and down are not processed by OnPlayerKeyStateChange, and KEY_SPRINT is space, not shift
Thanks you, but how can you check if a players pressed keys like → ?

Quote:
Originally Posted by MenaceX^
Use wiki, ****** posted a big explaination there.
Can you give me a link? i cannot find it there.
Search better, it's like a poor excuse because you just write the address, a slash and then the public name.
Quote:
Originally Posted by dice7
You can't, only keys like in single player aka these
https://sampwiki.blast.hk/wiki/GetPlayerKeys#Key_List
Yes he can. I saw it somewhere there.
Okay now i use ShowPlayerDialog instead of keys, it better i think.
But how can i delete the Dialog without pressing any key?


Re: OnPlayerKeyStateChange NOT working! - MenaceX^ - 21.10.2009

Why you gave up so fast? You could've done it still using OnPlayerKeyStateChange.


Re: OnPlayerKeyStateChange NOT working! - Andom - 21.10.2009

Quote:
Originally Posted by Y_Leѕѕ
Show one that doesn't exist (such as -1).
Do you mean like this?

ShowPlayerDialog(playerid, -1, DIALOG_STYLE_MSGBOX, " ", " ", " "," ");

Quote:
Originally Posted by MenaceX^
Why you gave up so fast? You could've done it still using OnPlayerKeyStateChange.
Because i just want to use key > and < but that isn't posible as some said.


Re: OnPlayerKeyStateChange NOT working! - Andom - 23.10.2009

bump