FS Press Keybroad
#1

Hi all, i'm newbie, i have one server ( zombie survival ) i want to press E to loot item in the road, but how to do it ?
Any One Can Help Me ? Pleasee
Reply
#2

Hello,See Topic In Wiki

https://sampwiki.blast.hk/wiki/OnPlayerKeyStateChange
Reply
#3

With E you can't because you use that key to switch weapons
You can do with Y
PHP код:
public OnPlayerKeyStatChange(playeridoldkeysnewkeys
{
    if ((
newkeys KEY_YES) && !(oldkeys KEY_YES))
    {
            
//some action here
    
}
    return 
1;

Rep+ If i helped
Reply
#4

SA:MP can't detect when a player press 'E', it can only detect when he press a game key.

For example:
Let's say I set my game to jump on SHIFT and sprint on SPACE (which is deafult) and X set his game to jump on SPACE and sprint on SHIFT.

Ok, now when i jump I press SHIFT;
and when X jumps he press SPACE,
but we will both be detected by the server that they pressed 'KEY_JUMP'. So you can't say that all players will jump on SHIFT or sprint on SPACE.

Here is a link to all keys that can be detected and their default value (which can be changed in game by players)
https://sampwiki.blast.hk/wiki/Keys
Unfortunately, there is no default key for 'E' (unless in vehicle), but you can detect when a player press 'C' (KEY_CROUCH); Left alt (KEY_WALK), 'Y' (KEY_YES), 'N' (KEY_NO), etc.
Reply
#5

Quote:
Originally Posted by Arbico
Посмотреть сообщение
With E you can't because you use that key to switch weapons
You can do with Y
PHP код:
public OnPlayerKeyStatChange(playeridoldkeysnewkeys
{
    if ((
newkeys KEY_YES) && !(oldkeys KEY_YES))
    {
            
//some action here
    
}
    return 
1;

Rep+ If i helped
Quote:
Originally Posted by GaByM
Посмотреть сообщение
SA:MP can't detect when a player press 'E', it can only detect when he press a game key.

For example:
Let's say I set my game to jump on SHIFT and sprint on SPACE (which is deafult) and X set his game to jump on SPACE and sprint on SHIFT.

Ok, now when i jump I press SHIFT;
and when X jumps he press SPACE,
but we will both be detected by the server that they pressed 'KEY_JUMP'. So you can't say that all players will jump on SHIFT or sprint on SPACE.

Here is a link to all keys that can be detected and their default value (which can be changed in game by players)
https://sampwiki.blast.hk/wiki/Keys
Unfortunately, there is no default key for 'E' (unless in vehicle), but you can detect when a player press 'C' (KEY_CROUCH); Left alt (KEY_WALK), 'Y' (KEY_YES), 'N' (KEY_NO), etc.
Thanks ! it work, so, can you help me how to create file .SQL and config game mode to it ?
Reply
#6

Quote:
Originally Posted by Arbico
Посмотреть сообщение
With E you can't because you use that key to switch weapons
You can do with Y
PHP код:
public OnPlayerKeyStatChange(playeridoldkeysnewkeys
{
    if ((
newkeys KEY_YES) && !(oldkeys KEY_YES))
    {
            
//some action here
    
}
    return 
1;

Rep+ If i helped
It Work ! thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)