Quick Help Needed! [OnPlayerKeyStateChange]
#1

Sup guys i need help with detecting if the player has pressed a key, and if he released it.

At the top of the script i have added:
pawn Код:
#define PRESSED(%0) \
    (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
#define RELEASED(%0) \
    (((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0)))
And:

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(PlayerInfo[playerid][XXX] == 1 && PlayerInfo[playerid][XXXY] == 1) // Line 286
    { // Line 287
        if(PRESSED(KEY_AIM)) // Line 288
        { // Line 289
            SendClientMessage(playerid, WHITE, "Something."); // Line 290
        } // Line 291
        else if(RELEASED(KEY_AIM)) // Line 292
        { // Line 293
            ClearAnimations(playerid); // Line 294
        } // Line 295
        if((newkeys & KEY_WALK) && !(oldkeys & KEY_WALK)) //line 296
        { //line 297
            ApplyAnimation(playerid,"PED","WALK_armed",4.1, 1, 1, 1, 0, 0, 0); //Line 298
        } // Line 299
    } // Line 300
}
Errors:
Код:
(Line: 288 ) : error 029: invalid expression, assumed zero
(Line: 290) : error 001: expected token: ")", but found ";"
(Line: 290) : error 036: empty statement
(Line: 292) : error 029: invalid expression, assumed zero
(Line: 294) : error 001: expected token: ")", but found ";"
(Line: 294) : error 036: empty statement
(Line: 296) : error 010: invalid function or declaration
Thanks to all the kind helpers.
Reply
#2

Did you define KEY_AIM? This one's not defined by default.
Reply
#3

Damn, i forgot it.
Thanks it has solved it.
Reply
#4

It seems fine to me, I even compiled it (ignoring PlayerInfo).

EDIT: I didn't refresh the page and I didn't see the above replies.

Although, wouldn't it just give error about undefined symbol "KEY_AIM" and not those it gave?
Reply
#5

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
It seems fine to me, I even compiled it (ignoring PlayerInfo).

EDIT: I didn't refresh the page and I didn't see the above replies.

Although, wouldn't it just give error about undefined symbol "KEY_AIM" and not those it gave?
Yea it should have, that's so stupid it didn't.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)