Diretional keys Problem
#1

I'm trying to detect the directional keys and can not.
I read something about my OS is windows vista but nothing concrete, then I wonder what is happening.
pawn Код:
public OnPlayerKeyStateChange(playerid,newkeys,oldkeys)
{
    new string[20];
    format(string,20,"KEY: %d OLDKEY: %d",newkeys,oldkeys);
    SendClientMessage(playerid,Sistema,string);
 
    if(newkeys & KEY_RIGHT)
    {
        if(GetPlayerSelState(playerid) > 0)
           SetPlayerSelectionID(playerid,GetPlayerSelectionID(playerid)+1);
        else
           return 1;
    }
    if(newkeys & KEY_LEFT)
    {
        if(GetPlayerSelState(playerid) > 0)
           SetPlayerSelectionID(playerid,GetPlayerSelectionID(playerid)-1);
        else
           return 1;
    }

    return 1;
}
I made debug, and when press the diretional keys, nothing happens, while the others wwere send via client message.
Reply
#2

https://sampwiki.blast.hk/wiki/GetPlayerKeys
pawn Код:
public OnPlayerUpdate(playerid)
{
    new Keys,ud,lr;
    GetPlayerKeys(playerid,Keys,ud,lr);
   
    if(lr > 0)
    {
        if(GetPlayerSelState(playerid) > 0)
        SetPlayerSelectionID(playerid,GetPlayerSelectionID(playerid)+1);
        else
           return 1;
    }
    if(lr < 0)
    {
     //etc
     return 1;
     }
     return 1;
}
Reply
#3

Thanks ****** and O_x, i was tried use GetPlayerKeys in the OnPlayerKeyStateChange, but i will try again.


EDIT: No sucess, now i will try using the OnPlayerUpdate.
pawn Код:
public OnPlayerKeyStateChange(playerid,newkeys,oldkeys)
{
    new string[20];
    new keys,ud,lr;
    GetPlayerKeys(playerid,keys,ud,lr);
    format(string,20,"UD: %d LR: %d",ud,lr);
    SendClientMessage(playerid,Sistema,string);
 
    if(lr == KEY_RIGHT)
    {
        if(GetPlayerSelState(playerid) > 0)
           SetPlayerSelectionID(playerid,GetPlayerSelectionID(playerid)+1);
        else
           return 1;
    }
    else if(lr == KEY_LEFT)
    {
        if(GetPlayerSelState(playerid) > 0)
           SetPlayerSelectionID(playerid,GetPlayerSelectionID(playerid)-1);
        else
           return 1;
    }

    return 1;
}
EDIT 2: In the OnPlayerUpdate works, i want use in the KeyStateChange but looks impossible.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)