OnPlayerKeyStateChange Help - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: OnPlayerKeyStateChange Help (
/showthread.php?tid=259784)
OnPlayerKeyStateChange Help -
[RVRP]Tyler - 05.06.2011
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.
Re: OnPlayerKeyStateChange Help -
Gamer_Z - 05.06.2011
well maybe you are not checking what the playerinfo variable holds?
Re: OnPlayerKeyStateChange Help -
xRyder - 05.06.2011
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....
Re: OnPlayerKeyStateChange Help -
[RVRP]Tyler - 05.06.2011
Quote:
Originally Posted by xRyder
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.
Re: OnPlayerKeyStateChange Help -
Gamer_Z - 06.06.2011
then do it while the player is HOLDING the action key and when he releases it will disapear and do counter++..
Re: OnPlayerKeyStateChange Help -
[RVRP]Tyler - 06.06.2011
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?