Player Keys W,S,A,D - UP,DOWN,LEFT,RIGHT [Problem]
#1

When using this code it doesn't work when I'm pressing they keys.. I pressed buttons on my numpad and it worked. What am I doing wrong?

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if ((newkeys & KEY_UP) && !(oldkeys & KEY_UP))
    {
        PlayerMoving[playerid] = 1;
        SendClientMessage(playerid, COLOR_YELLOW, "You are moving!");
    }
    if ((newkeys & KEY_DOWN) && !(oldkeys & KEY_DOWN))
    {
        PlayerMoving[playerid] = 1;
        SendClientMessage(playerid, COLOR_YELLOW, "You are moving!");
    }
    if ((newkeys & KEY_LEFT) && !(oldkeys & KEY_LEFT))
    {
        PlayerMoving[playerid] = 1;
        SendClientMessage(playerid, COLOR_YELLOW, "You are moving!");
    }
    if ((newkeys & KEY_RIGHT) && !(oldkeys & KEY_RIGHT))
    {
        PlayerMoving[playerid] = 1;
        SendClientMessage(playerid, COLOR_YELLOW, "You are moving!");
    }
    if ((oldkeys & KEY_UP) && !(newkeys & KEY_UP))
    {
        if ((newkeys & KEY_UP) || (newkeys & KEY_DOWN) || (newkeys & KEY_LEFT) || (newkeys & KEY_RIGHT))
        {
            return 0;
        }
        else
        {
            PlayerMoving[playerid] = 0;
            SendClientMessage(playerid, COLOR_YELLOW, "You stopped moving!");
        }
    }
    if ((oldkeys & KEY_DOWN) && !(newkeys & KEY_DOWN))
    {
        if ((newkeys & KEY_UP) || (newkeys & KEY_DOWN) || (newkeys & KEY_LEFT) || (newkeys & KEY_RIGHT))
        {
            return 0;
        }
        else
        {
            PlayerMoving[playerid] = 0;
            SendClientMessage(playerid, COLOR_YELLOW, "You stopped moving!");
        }
    }
    if ((oldkeys & KEY_LEFT) && !(newkeys & KEY_LEFT))
    {
        if ((newkeys & KEY_UP) || (newkeys & KEY_DOWN) || (newkeys & KEY_LEFT) || (newkeys & KEY_RIGHT))
        {
            return 0;
        }
        else
        {
            PlayerMoving[playerid] = 0;
            SendClientMessage(playerid, COLOR_YELLOW, "You stopped moving!");
        }
    }
    if ((oldkeys & KEY_RIGHT) && !(newkeys & KEY_RIGHT))
    {
        if ((newkeys & KEY_UP) || (newkeys & KEY_DOWN) || (newkeys & KEY_LEFT) || (newkeys & KEY_RIGHT))
        {
            return 0;
        }
        else
        {
            PlayerMoving[playerid] = 0;
            SendClientMessage(playerid, COLOR_YELLOW, "You stopped moving!");
        }
    }
Reply


Messages In This Thread
Player Keys W,S,A,D - UP,DOWN,LEFT,RIGHT [Problem] - by Phil_Cutcliffe - 28.02.2014, 19:52

Forum Jump:


Users browsing this thread: 2 Guest(s)