SA-MP Forums Archive
Button help - 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)
+--- Thread: Button help (/showthread.php?tid=658278)



Button help - ,TomY' - 31.08.2018

Hey all. I would like to create log, that show which keys player pressing. I know one way how to create it:
Код:
if(newkeys == KEY_WALK)
{
//LOG CODE
}
But maybe it is other way to create it easier, because in my way I should create for every button code separately + if player pressing 2 keys, code will show only first pressed key. I need that code will show all pressed keys ( if press 2 in same tame, show 2 ). Any other solutions?


Re: Button help - Calisthenics - 31.08.2018

You can log them when OnPlayerKeyStateChange is being called without the need to check for certain keys or combinations. However it will log way too frequently and depends on the method you will use for logging, there might be a noticeable lag.


Re: Button help - Eoussama - 31.08.2018

Just print the newkeys value?

PHP код:
public OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    
printf("newkeys: %d"newkeys);
    return 
1;




Re: Button help - ,TomY' - 31.08.2018

Quote:
Originally Posted by Eoussama
Посмотреть сообщение
Just print the newkeys value?

PHP код:
public OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    
printf("newkeys: %d"newkeys);
    return 
1;

Ye, this is good way. I tried it, and when I press space i got:

Код:
[21:24:31] newkeys: 8
[21:24:31] newkeys: 0
First line show space ID - 8, but why also that second line appeared? When I press other keys, that line with 0 also appears. How to do, that printf will show only first line?