OnPlayerKeyStateChange Help
#1

So basically I am making a tutorial using OnPlayerKeyStateChange

It looks like this:

Code:
if(PlayerInfo[playerid][TutorialStage] == 1)
{
        if ((oldkeys & KEY_FIRE) && !(newkeys & KEY_FIRE))
        {
                 PlayerInfo[playerid][TutorialStage] = 2;
                 SendClientMessage(playerid, WHITE, "Example.");
         }
}
And it repeats for tutorial stage 2-5.

However, the problem I have run into is when I press my fire key it plays the whole tutorial when it's only supposed to play one stage.
Reply
#2

well maybe you are not checking what the playerinfo variable holds?
Reply
#3

You could add another if statement and check how many times did player pressed some key...

Example:
pawn Code:
new counting[MAX_PLAYERS] = 1;
// ^Put this somewhere at the top and then...


if ((oldkeys & KEY_FIRE) && !(newkeys & KEY_FIRE) && counting == 1)
{
    SendClientMessage(playerid, WHITE, "This is tutorial no. 1");
    counting[playerid]++;
}
else if ((oldkeys & KEY_FIRE) && !(newkeys & KEY_FIRE) && counting == 2)
{
    SendClientMessage(playerid, WHITE, "This is tutorial no. 2");
    counting[playerid]++;
}

//and so on....
Reply
#4

Quote:
Originally Posted by xRyder
View Post
You could add another if statement and check how many times did player pressed some key...

Example:
pawn Code:
new counting[MAX_PLAYERS] = 1;
// ^Put this somewhere at the top and then...


if ((oldkeys & KEY_FIRE) && !(newkeys & KEY_FIRE) && counting == 1)
{
    SendClientMessage(playerid, WHITE, "This is tutorial no. 1");
    counting[playerid]++;
}
else if ((oldkeys & KEY_FIRE) && !(newkeys & KEY_FIRE) && counting == 2)
{
    SendClientMessage(playerid, WHITE, "This is tutorial no. 2");
    counting[playerid]++;
}

//and so on....
Still having the same issue, the entire tutorial plays through when I press the button 1 time.
Reply
#5

then do it while the player is HOLDING the action key and when he releases it will disapear and do counter++..
Reply
#6

I tried changing the format of it and everything, but I just can't seem to figure out how to do this properly.

I think I know what's wrong, but I don't know how to fix it:

I have it set so when I press the firing key it will check if the tutorial is in stage 1. If it is in stage one, it will tell me all the text and it sets my variable to stage two. However, it doesn't stop there it searches for stage two afterwards and when it sees that I have stage two it executes stage two, and so on.

How do I stop it once it's sent me the text commands for stage one without moving on to stage two?
Reply


Forum Jump:


Users browsing this thread: