SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 24/11/2019, 12:44 AM   #1
weex
Big Clucker
 
Join Date: Dec 2016
Posts: 143
Reputation: 1
Default On press 2,4,6,8

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
pawn Code:
if(newkeys == 2048) SendClientMessage(playerid, COLOR_LIGHTRED, "8 Pressed"); //
    else if(newkeys == 4096) SendClientMessage(playerid, COLOR_LIGHTRED, "2 Pressed"); //
    else if(newkeys == 8192) SendClientMessage(playerid, COLOR_LIGHTRED, "4 Pressed"); //
    else if(newkeys == 16384) SendClientMessage(playerid, COLOR_LIGHTRED, "6 Pressed"); //

It shouldl be num lock or above f1,f2 numbers?
only 4,6 is working on num lock...
2 and 8 is not working

why?
weex is offline   Reply With Quote
Old 24/11/2019, 10:11 AM   #2
MrAuto
Little Clucker
 
Join Date: Sep 2019
Posts: 8
Reputation: 2
Default Re: On press 2,4,6,8

https://wiki.sa-mp.com/wiki/Keys

Quote:
(6) Only detected when "JOYPAD" configuration is selected for controller.
it should work fine in vehicle

also is better to use definitions like
pawn Code:
#define PRESSED(%0) \
    (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
so you can check if among keys pressed this specific one was pressed
MrAuto is offline   Reply With Quote
Old 30/11/2019, 12:23 AM   #3
weex
Big Clucker
 
Join Date: Dec 2016
Posts: 143
Reputation: 1
Default Re: On press 2,4,6,8

Even with your
pawn Code:
if(PRESSED(KEY_ANALOG_UP)) SendClientMessage(playerid, COLOR_LIGHTRED, "8 Pressed");
else if(PRESSED(KEY_ANALOG_DOWN)) SendClientMessage(playerid, COLOR_LIGHTRED, "2 Pressed");
else if(PRESSED(KEY_ANALOG_LEFT)) SendClientMessage(playerid, COLOR_LIGHTRED, "4 Pressed");
else if(PRESSED(KEY_ANALOG_RIGHT)) SendClientMessage(playerid, COLOR_LIGHTRED, "6 Pressed");

the keys 2 and 8 never works
weex is offline   Reply With Quote
Old 30/11/2019, 03:03 AM   #4
Nero_3D
High-roller
 
Nero_3D's Avatar
 
Join Date: Jun 2007
Location: Germany
Posts: 2,837
Reputation: 671
Default Re: On press 2,4,6,8

make sure you are in a vehicle, like MrAuto said, onfoot works only if the player has selected the JOYPAD configuration and I think that not many players did.

Also it depends on the players keymapping, use that gametext to find the keys or look them up
pawn Code:
GameTextForPlayer(playerid, "\
    KEY_ANALOG_UP = ~k~~VEHICLE_TURRETUP~\n\
    KEY_ANALOG_DOWN  = ~k~~VEHICLE_TURRETDOWN~ \n\
    KEY_ANALOG_LEFT  =  ~k~~VEHICLE_TURRETLEFT~ \n\
    KEY_ANALOG_RIGHT = ~k~~VEHICLE_TURRETRIGHT~"
, 10000, 2);
Nero_3D is online now   Reply With Quote
Old 30/11/2019, 04:38 AM   #5
Pottus
High-roller
 
Pottus's Avatar
 
Join Date: Jun 2012
Posts: 4,893
Reputation: 1321
Default Re: On press 2,4,6,8

Quote:
Originally Posted by Nero_3D View Post
make sure you are in a vehicle, like MrAuto said, onfoot works only if the player has selected the JOYPAD configuration and I think that not many players did.

Also it depends on the players keymapping, use that gametext to find the keys or look them up
pawn Code:
GameTextForPlayer(playerid, "\
    KEY_ANALOG_UP = ~k~~VEHICLE_TURRETUP~\n\
    KEY_ANALOG_DOWN  = ~k~~VEHICLE_TURRETDOWN~ \n\
    KEY_ANALOG_LEFT  =  ~k~~VEHICLE_TURRETLEFT~ \n\
    KEY_ANALOG_RIGHT = ~k~~VEHICLE_TURRETRIGHT~"
, 10000, 2);
I have seen plenty of servers that just assumes a keyboard configuration ~k~ for the win.
Pottus is offline   Reply With Quote
Old 30/11/2019, 10:10 PM   #6
weex
Big Clucker
 
Join Date: Dec 2016
Posts: 143
Reputation: 1
Default Re: On press 2,4,6,8

Sad only in joypad
Anyways thank you all, i rep everyone here
weex is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Ajuda] Press key PedroH PortuguÍs/Portuguese 7 04/08/2017 09:00 PM
I can press Jowere Scripting Help 13 30/11/2016 01:53 PM
SA-MP keeps crashing when I press esc or I press windows key. Goldino Client Support 3 27/02/2013 03:10 AM
I need Press C to Enter REP+ for HELP manishmulchandani11 Scripting Help 10 10/10/2012 08:27 PM
Key Press deather Help Archive 1 11/02/2010 04:31 PM


All times are GMT. The time now is 06:49 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.