[Help] OnPlayerKey....
#1

I want that my KEY_JUMP function ( if(newkeys == KEY_JUMP) ) works only if someone is in the tutorial ( if(RegStep[playerid] < 1) ) how can i do it ?

Now its like this:

Code:
	if(newkeys == KEY_JUMP)
            {
            // my  function
Reply
#2

Are you talking about that?
pawn Code:
if(newkeys == KEY_JUMP && RegStep[playerid] < 1)
{
// ...
}
Reply
#3

yes thanks

but i get error then that playerid is not defined
Reply
#4

Better not to check them in 1 statement:

pawn Code:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys == KEY_JUMP) {
        if(RegStep[playerid] < 1) {
            // Your code here
        }
    }
}
Reply
#5

ty no errors

EDIT: now if i press the key nothing happens
Reply
#6

Quote:
Originally Posted by Sinner
View Post
Better not to check them in 1 statement:

pawn Code:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys == KEY_JUMP) {
        if(RegStep[playerid] < 1) {
            // Your code here
        }
    }
}
KEY_JUMP will still be passed to those whose value is greater than 1!

pawn Code:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys == KEY_JUMP)
    {
        if(RegStep[playerid] > 1) return 0;
    }
    return 1;
}
Reply
#7

pawno is crashing (Ghost)
Reply
#8

Quote:
Originally Posted by Gh05t_
View Post
KEY_JUMP will still be passed to those whose value is greater than 1!

pawn Code:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys == KEY_JUMP)
    {
        if(RegStep[playerid] > 1) return 0;
    }
    return 1;
}
That was not the question, though. My code works just fine.
Reply
#9

Quote:
Originally Posted by Sinner
View Post
That was not the question, though. My code works just fine.
No, it doesn't.

pawn Code:
new bool:variable;
main()
{
    if(variable == false)
    {
        print("0");
    }
    print("1"); //<<<< is still passed.
}
pawn Code:
main()
{
    if(variable == true) return 0;
    print("0");
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)