Tutorial System issue with timer.
#1

pawn Код:
forward GuideTime(playerid);
public GuideTime(playerid)
{
    new string[128];
    if(TutStage[playerid] == 2)
    {
        SetPlayerCameraPos(playerid, -179.2579,1031.5060,24.0391);
        SetPlayerCameraLookAt(playerid, -201.4486,1165.9543,19.7422);//fc main
        format(string, sizeof(string), "Business System.");
        SendClientMessage(playerid, COLOUR_BLUE, string);
        format(string, sizeof(string), "Bone County is littered with businesses, all of which are enterable and have a variety of items.");
        SendClientMessage(playerid, COLOUR_WHITE, string);
        format(string, sizeof(string), "Business types include: "COL_ORANGE"Furniture Stores, General Stores, Gas Stations, Bars/Clubs, Pawn shops, Clothes stores etc.");
        SendClientMessage(playerid, COLOUR_WHITE, string);
        format(string, sizeof(string), "Businesses are available for purchase, of which there is no limit to the amount you can own. ");
        SendClientMessage(playerid, COLOUR_WHITE, string);
        format(string, sizeof(string), "Tax is set by the government, currently the rate is (default) $150 per business, all optionally payable at the county hall.");
        SendClientMessage(playerid, COLOUR_WHITE, string);
        KillTimer(GuideTimer[playerid]);
        GuideTimer[playerid] = SetTimerEx("GuideTime", 10000, false, "i", playerid);
        TutStage[playerid] = 3;
    }
    if(TutStage[playerid] == 3)
    {
        SetPlayerCameraPos(playerid, -32.6758,1108.7784,19.8135);
        SetPlayerCameraLookAt(playerid,-19.0663,1115.3185,20.9399);//house view
        format(string, sizeof(string), "House System.");
        SendClientMessage(playerid, COLOUR_ORANGE, string);
        format(string, sizeof(string), "Bone County has a wide range of houses available for purchase (or breaking into if that's your thing).");
        SendClientMessage(playerid, COLOUR_WHITE, string);
        format(string, sizeof(string), "There is no limit to the amount of houses you own, but houses are taxed based upon their value. The amounts vary.");
        SendClientMessage(playerid, COLOUR_WHITE, string);
        format(string, sizeof(string), "As with everything else, you can sell your house to other players. Houses can also be broken into. Security is purchaseable.");
        SendClientMessage(playerid, COLOUR_WHITE, string);
        format(string, sizeof(string), "You cannot store items in houses per-se, but you can store items in furniture, just make sure your house is secure.");
        SendClientMessage(playerid, COLOUR_WHITE, string);
        KillTimer(GuideTimer[playerid]);
        GuideTimer[playerid] = SetTimerEx("GuideTime", 10000, false, "i", playerid);
        TutStage[playerid] = 4;
    }
Here is a snippet of what I am doing.

GuideTimer should be killed and then call after 10 seconds again but it rushes through all of the code and spawns the player, it doesn't freeze for 10 seconds, except for the first one (not inside the timer.)

pawn Код:
TutStage[playerid] = 1;
            if(TutStage[playerid] == 1)
            {
                SetPlayerCameraPos(playerid, -566.1818,1647.4830,156.1962);
                SetPlayerCameraLookAt(playerid, -229.3934,1401.9023,73.0859);// general shot
                format(string, sizeof(string), "Welcome to "COL_GREEN"Bone County Roleplay"COL_WHITE"! This short guide should help you get around a little easier.");
                SendClientMessage(playerid, COLOUR_WHITE, string);
                format(string, sizeof(string), "Thank you "COL_WHITE"for registering, we do hope you enjoy your stay.");
                SendClientMessage(playerid, COLOUR_GREEN, string);
                format(string, sizeof(string), "Script:"COL_WHITE" This script is completely unique and scripted from scratch over a long period of time by a single developer.");
                SendClientMessage(playerid, COLOUR_GREY, string);
                format(string, sizeof(string), "Script:"COL_WHITE" It has never been released to the public and never will be, the script compromises of over 40,000 lines of code.");
                SendClientMessage(playerid, COLOUR_GREY, string);
                format(string, sizeof(string), "You may encounter bugs, if you do, please report them on the forums...Alright. "COL_GREEN"Let's begin.");
                SendClientMessage(playerid, COLOUR_GREY, string);
                TutStage[playerid] = 2;
            }
            GuideTimer[playerid] = SetTimerEx("GuideTime", 10000, false, "i", playerid);
This is where I begin the tutorial.
Reply
#2

Does stage 2 works? or only stage 1 ?
Reply
#3

Only stage 1. Stage 1 is not in the timer I set the timer after I show the messages
Reply
#4

Did you try putting timer inside Tutstage[playerid] == 1 case?
Reply
#5

I don't know how that would do anything
Reply
#6

The timer right now is doing this:

Get's inside Stage 1 and then it doesnt do anything else because you don't call timer again inside stage 1 to move on.

EDIT: To be honest, your code is a little confusing. There is a more efficient way to do this.
Reply
#7

No. Stage 1 is not in the timer at all. I call the timer after I display stage 1
Reply
#8

Try this:
PHP код:
forward GuideTime(playerid);
public 
GuideTime(playerid)
{
    new 
string[128];
if(
TutStage[playerid] == 1)
            {
                 
SetPlayerCameraPos(playerid, -566.1818,1647.4830,156.1962);
                
SetPlayerCameraLookAt(playerid, -229.3934,1401.9023,73.0859);// general shot
                
format(stringsizeof(string), "Welcome to "COL_GREEN"Bone County Roleplay"COL_WHITE"! This short guide should help you get around a little easier.");
                
SendClientMessage(playeridCOLOUR_WHITEstring);
                
format(stringsizeof(string), "Thank you "COL_WHITE"for registering, we do hope you enjoy your stay.");
                
SendClientMessage(playeridCOLOUR_GREENstring);
                
format(stringsizeof(string), "Script:"COL_WHITE" This script is completely unique and scripted from scratch over a long period of time by a single developer.");
                
SendClientMessage(playeridCOLOUR_GREYstring);
                 
format(stringsizeof(string), "Script:"COL_WHITE" It has never been released to the public and never will be, the script compromises of over 40,000 lines of code.");
                
SendClientMessage(playeridCOLOUR_GREYstring);
                  
format(stringsizeof(string), "You may encounter bugs, if you do, please report them on the forums...Alright. "COL_GREEN"Let's begin.");
                
SendClientMessage(playeridCOLOUR_GREYstring);
GuideTimer[playerid] = SetTimerEx("GuideTime"10000false"i"playerid);
                
TutStage[playerid] = 2;
            }
    if(
TutStage[playerid] == 2)
    {
         
SetPlayerCameraPos(playerid, -179.2579,1031.5060,24.0391);
        
SetPlayerCameraLookAt(playerid, -201.4486,1165.9543,19.7422);//fc main
          
format(stringsizeof(string), "Business System.");
        
SendClientMessage(playeridCOLOUR_BLUEstring);
          
format(stringsizeof(string), "Bone County is littered with businesses, all of which are enterable and have a variety of items.");
        
SendClientMessage(playeridCOLOUR_WHITEstring);
            
format(stringsizeof(string), "Business types include: "COL_ORANGE"Furniture Stores, General Stores, Gas Stations, Bars/Clubs, Pawn shops, Clothes stores etc.");
        
SendClientMessage(playeridCOLOUR_WHITEstring);
         
format(stringsizeof(string), "Businesses are available for purchase, of which there is no limit to the amount you can own. ");
        
SendClientMessage(playeridCOLOUR_WHITEstring);
           
format(stringsizeof(string), "Tax is set by the government, currently the rate is (default) $150 per business, all optionally payable at the county hall.");
        
SendClientMessage(playeridCOLOUR_WHITEstring);
          
KillTimer(GuideTimer[playerid]);
        
GuideTimer[playerid] = SetTimerEx("GuideTime"10000false"i"playerid);
        
TutStage[playerid] = 3;
    }
     if(
TutStage[playerid] == 3)
    {
         
SetPlayerCameraPos(playerid, -32.6758,1108.7784,19.8135);
        
SetPlayerCameraLookAt(playerid,-19.0663,1115.3185,20.9399);//house view
          
format(stringsizeof(string), "House System.");
        
SendClientMessage(playeridCOLOUR_ORANGEstring);
          
format(stringsizeof(string), "Bone County has a wide range of houses available for purchase (or breaking into if that's your thing).");
        
SendClientMessage(playeridCOLOUR_WHITEstring);
            
format(stringsizeof(string), "There is no limit to the amount of houses you own, but houses are taxed based upon their value. The amounts vary.");
        
SendClientMessage(playeridCOLOUR_WHITEstring);
         
format(stringsizeof(string), "As with everything else, you can sell your house to other players. Houses can also be broken into. Security is purchaseable.");
        
SendClientMessage(playeridCOLOUR_WHITEstring);
           
format(stringsizeof(string), "You cannot store items in houses per-se, but you can store items in furniture, just make sure your house is secure.");
        
SendClientMessage(playeridCOLOUR_WHITEstring);
        
KillTimer(GuideTimer[playerid]);
        
GuideTimer[playerid] = SetTimerEx("GuideTime"10000false"i"playerid);
          
TutStage[playerid] = 4;
    } 
To your other callback
PHP код:
TutStage[playerid] = 1;
GuideTimer[playerid] = SetTimerEx("GuideTime"10000false"i"playerid); 
EDIT: in case you dont want timer inside stage 1
Use inside stage 1
PHP код:
TutStage[playerid] = 1;
               if(
TutStage[playerid] == 1)
            {
                 
SetPlayerCameraPos(playerid, -566.1818,1647.4830,156.1962);
                
SetPlayerCameraLookAt(playerid, -229.3934,1401.9023,73.0859);// general shot
                
format(stringsizeof(string), "Welcome to "COL_GREEN"Bone County Roleplay"COL_WHITE"! This short guide should help you get around a little easier.");
                
SendClientMessage(playeridCOLOUR_WHITEstring);
                
format(stringsizeof(string), "Thank you "COL_WHITE"for registering, we do hope you enjoy your stay.");
                
SendClientMessage(playeridCOLOUR_GREENstring);
                
format(stringsizeof(string), "Script:"COL_WHITE" This script is completely unique and scripted from scratch over a long period of time by a single developer.");
                
SendClientMessage(playeridCOLOUR_GREYstring);
                 
format(stringsizeof(string), "Script:"COL_WHITE" It has never been released to the public and never will be, the script compromises of over 40,000 lines of code.");
                
SendClientMessage(playeridCOLOUR_GREYstring);
                  
format(stringsizeof(string), "You may encounter bugs, if you do, please report them on the forums...Alright. "COL_GREEN"Let's begin.");
                
SendClientMessage(playeridCOLOUR_GREYstring);
                
TutStage[playerid] = 2;
                                
GuideTime(playerid);
            }
            
GuideTimer[playerid] = SetTimerEx("GuideTime"10000false"i"playerid); 
Reply
#9

Still unresolved.
Reply
#10

Didn't what i tell you work ?
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)