Need help with OnPlayerKeyStateChange
#1

Well, i tried to make some kinda entering with enter key (KEY_SECONDARY_ATTACK)
Here's the code but in game i just can't enter just pressing F/ENTER, i have to hold spacebar down, then press f/enter and then release spacebar. Also tried to start with else if (newkeys == KEY_SECONDARY_ATTACK, but this also didn't worked. Can anybody help me?
pawn Код:
else if (newkeys & KEY_SECONDARY_ATTACK )
    {
        for(new i = 0; i < sizeof(HouseInfo); i++)
        {
            if (IsPlayerInRangeOfPoint(playerid, 10,HouseInfo[i][hEntrancex], HouseInfo[i][hEntrancey], HouseInfo[i][hEntrancez]))
            {
                //printf("Found House :%d",i);
                if(PlayerInfo[playerid][pPhousekey] == i || HouseInfo[i][hLock] == 0)
                {
                    if(PlayerInfo[playerid][pWanted] == 0)
                    {
                        SafeSetPlayerInterior(playerid,HouseInfo[i][hInt]);
                        SetPlayerVirtualWorld(playerid,HouseInfo[i][hWorld]);
                        SafeSetPlayerPos(playerid,HouseInfo[i][hExitx],HouseInfo[i][hExity],HouseInfo[i][hExitz]);
                        GameTextForPlayer(playerid, "~w~Welcome Home", 5000, 1);
                        PlayerInfo[playerid][pLocal] = i;
                        PlayerInfo[playerid][pVirWorld] = HouseInfo[i][hWorld];
                        HouseEntered[playerid] = i;
                        PlayerInfo[playerid][pInteriorNr] = 39;
                    }
                    else
                    {
                        GameTextForPlayer(playerid, "~r~Criminals can't hide in houses!", 5000, 1);
                        return 1;
                    }
                }
                else
                {
                    GameTextForPlayer(playerid, "~r~Locked", 5000, 1);
                    return 1;
                }
            }
        }
    }
Reply
#2

Read Wrong.
Reply
#3

pawn Код:
if ((newkeys & KEY_SECONDARY_ATTACK) && (newkeys & KEY_SPRINT))
Reply
#4

Try this:

pawn Код:
if (newkeys & 16)
{
       // Your function
}
This is the value of KEY_SECUNDARY_ATTACK, and should at least work with F.
Reply
#5

Quote:
Originally Posted by judothijs
Посмотреть сообщение
Try this:

pawn Код:
if (newkeys & 16)
{
       // Your function
}
This is the value of KEY_SECUNDARY_ATTACK, and should at least work with F.
EDIT: Got it working, big thanks!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)