if(PRESSED(KEY_SPRINT)) - Failing
#1

Well, Basically one of the script that I have has a tutorial in it, and It says when pressing spacebar it should move onto the next one, but it seems like spacebar doesnt work the code:


pawn Код:
if(PRESSED(KEY_SPRINT))
    {
        if(PlayerisTut[playerid] >= 1)
        {
            if(PlayerisTut[playerid] == 1)
            {
                PlayerisTut[playerid] = 2;
                SetPlayerPos(playerid,1279.6980,-1542.4175,13.5274);
                SetPlayerCameraPos(playerid,1299.7954,-1594.4066,35.6015);//Driving School
                SetPlayerCameraLookAt(playerid,1279.6980,-1542.4175,13.5274);
                format(string,sizeof(string),"Driving school ~n~You will be able to take a driving test here for 5000$");
                TextDrawSetString(Textdraw98[playerid],string);
                TextDrawShowForPlayer(playerid,Textdraw98[playerid]);
                SendClientMessage(playerid,COLOR_WHITE,"{FF6633}Use SPACEBAR to continue,SHIFT to go back.");
                return 1;
            }
            if(PlayerisTut[playerid] == 2)
            {
                PlayerisTut[playerid] = 3;
                SetPlayerPos(playerid, 1221.7010,-1328.6449,-5.00);
                SetPlayerCameraPos(playerid, 1204.3781,-1313.3323,16.3984);
                SetPlayerCameraLookAt(playerid, 1174.7167,-1323.4485,14.5938);
                format(string,sizeof(string),"If you're feeling sick~n~come to the hospital~n~to get healed and fixed by the EMS");
                TextDrawSetString(Textdraw98[playerid],string);
                TextDrawShowForPlayer(playerid,Textdraw98[playerid]);
                SendClientMessage(playerid,COLOR_WHITE,"{FF6633}Tutorial:{FFFFFF}Use SPACEBAR to continue,SHIFT to go back.");
                return 1;
            }
            if(PlayerisTut[playerid] == 3)
            {
                PlayerisTut[playerid] = 4;
                SetPlayerPos(playerid,590.7849,-1243.1808,17.9521);
                SetPlayerCameraPos(playerid,609.0580,-1219.5914,29.2979);//Bank
                SetPlayerCameraLookAt(playerid,590.7849,-1243.1808,17.9521);
                format(string,sizeof(string),"Bank is located here~n~You can get your paychecks by~n~going over to the money icon~n~COMMANDS:/withdraw,/savings,/deposit,/transfer");
                TextDrawSetString(Textdraw98[playerid],string);
                TextDrawShowForPlayer(playerid,Textdraw98[playerid]);
                SendClientMessage(playerid,COLOR_WHITE,"{FF6633}Tutorial:{FFFFFF}Use SPACEBAR to continue,SHIFT to go back.");
                return 1;
            }
            if(PlayerisTut[playerid] == 4)
            {
                PlayerisTut[playerid] = 5;
                SetPlayerPos(playerid,543.6426,-1277.8851,17.2422);
                SetPlayerCameraPos(playerid,538.1927,-1259.2106,29.4667);//Grotti Dealership
                SetPlayerCameraLookAt(playerid,543.6426,-1277.8851,17.2422);
                format(string,sizeof(string),"You can buy sport vehicles over here if you have enough money.~n~Command:/v.");
                TextDrawSetString(Textdraw98[playerid],string);
                TextDrawShowForPlayer(playerid,Textdraw98[playerid]);
                SendClientMessage(playerid,COLOR_WHITE,"{FF6633}Tutorial:{FFFFFF}Use SPACEBAR to continue,SHIFT to go back.");
                return 1;
            }
            if(PlayerisTut[playerid] == 5)
            {
                PlayerisTut[playerid] = 6;
                SetPlayerCameraPos(playerid,2125.4453,-1119.0323,37.1580);
                SetPlayerCameraLookAt(playerid,2131.0527,-1150.2542,24.1689);
                SetPlayerPos(playerid,2130.0605,-1119.6272,25.3773);
                format(string,sizeof(string),"Over here is the other dealership where you can buy non-sport cars.~n~/v for commands");
                TextDrawSetString(Textdraw98[playerid],string);
                TextDrawShowForPlayer(playerid,Textdraw98[playerid]);
                SendClientMessage(playerid,COLOR_WHITE,"{FF6633}Use SPACEBAR to continue,SHIFT to go back.");
                return 1;
            }
            if(PlayerisTut[playerid] == 6)
            {
                PlayerisTut[playerid] = 7;
                SetPlayerPos(playerid, 1786.1758,-1258.4976,-5.00);
                SetPlayerCameraPos(playerid, 1779.4259,-1275.1025,15.6328);
                SetPlayerCameraLookAt(playerid, 1785.7263,-1296.0200,13.4213);
                format(string,sizeof(string),"Here is where you can make advertisements ~n~So if you need to make a advertisement.~n~ Come down and /ad or /cad~n~For company advertisement. ");
                TextDrawSetString(Textdraw98[playerid],string);
                TextDrawShowForPlayer(playerid,Textdraw98[playerid]);
                SendClientMessage(playerid,COLOR_WHITE,"{FF6633}Tutorial:{FFFFFF}Use SPACEBAR to continue,SHIFT to go back.");
                return 1;
            }
            if(PlayerisTut[playerid] == 7)
            {
                PlayerisTut[playerid] = 0;
                SetPlayerInterior(playerid, 0);
                SetPlayerPos(playerid, 1642.2334,-2240.4983,13.4952);
                SetCameraBehindPlayer(playerid);
                SetPlayerVirtualWorld(playerid, 0);
                TogglePlayerControllable(playerid, 1);
                TextDrawHideForPlayer(playerid,Textdraw98[playerid]);
                OnPlayerDataSave(playerid);
                SetCameraBehindPlayer(playerid);
                SendClientMessage(playerid,COLOR_WHITE,"{FF6633}Tutorial:{FFFFFF}The tutorial is now finished,good luck!.");
                return 1;
            }
        }
    }
Reply
#2

sorry for the early bump but I need this fixed fast
Reply
#3

Where do you have this? OnPlayerKeyStateChange, I hope? Debug the code.
Reply
#4

Yeah, I do, OnPlayerKeyStateChange
Reply
#5

Then one of your variables is not set correctly. Print the variables BEFORE they're checked. EG:

pawn Код:
if(PRESSED(KEY_SPRINT))
    {
        printf( "%d", PlayerisTut[playerid] );
        if(PlayerisTut[playerid] >= 1)
        {
Reply
#6

This is not my script, plus I got a minor scripting knowledge, so please explain...
Reply
#7

Print the PlayerisTut variable.
Reply
#8

I'll test it tommorow
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)