Help with timers and dialogs
#1

I am working on a tutorial filterscript for my RP server that I'm doing from scratch. Now I am experiencing a wierd problem with my system. When a player spawns, there should be 3 seconds until a dialog pops up asking about what kind of tutorial player wants to have. However, this tutorial never pops up, the code is run to the point where NextStep(playerid) is called but it doesn't go that further. So I'd need help with troubleshooting this problem, if you manage to find out the reason for this bug, a rep+ or two are guaranteed!


Filterscript code:

Код:
	//Tutorial dialogs
	#define Dialog_Tutorial_Question 1000
	#define Dialog_BasicsTutorial_Camera 1001
	#define Dialog_BasicsTutorial_Movement 1002

forward NextStep(playerid);

public OnPlayerConnect(playerid)
{
	SetPVarString(playerid, "ServerTutorial", "false");
	SetPVarString(playerid, "BasicsTutorial", "false");
}

public OnPlayerSpawn(playerid)
{
	new NewPlayer[24];
	GetPVarString(playerid, "NewPlayer", NewPlayer, sizeof(NewPlayer));
	
	if (strcmp(NewPlayer, "true") == 0)
	{
		SetPlayerPos(playerid, 1294.5718, 4.4446, 1004.2735);
		SetCameraBehindPlayer(playerid);
		SetPlayerInterior(playerid, 18);
		SetPVarString(playerid, "InTutorial", "true");
		SetPVarInt(playerid, "TutorialStep", 0);
		NextStepTimer(playerid, 3);
		if (TutorialDebug == 1) printf("[tutorial] Player spawned in tutorial place.");
		return 1;
	}
	return 0;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	new PName[MAX_PLAYER_NAME];
	GetPlayerName(playerid, PName, sizeof(PName));
	
	if (dialogid == Dialog_Tutorial_Question)
	{
		if (response == Dialog_Button_Left)
		{
			SetPVarString(playerid, "BasicsTutorial", "true");
			SetPVarString(playerid, "NewPlayer", "false");
			SetPVarInt(playerid, "TutorialStep", 1); 
			NextStepTimer(playerid, 3);
			if (TutorialDebug == 1) printf("[tutorial] Player %s selected the basic tutorial.", PName);
			return 1;
		}
		
		else if (response == Dialog_Button_Right)
		{
			SetPVarString(playerid, "ServerTutorial", "true");
			SetPVarString(playerid, "NewPlayer", "false");
			SetPVarInt(playerid, "TutorialStep", 1); 
			NextStepTimer(playerid, 3);
			if (TutorialDebug == 1) printf("[tutorial] Player %s selected the server tutorial.", PName);
			return 1;
		}
	}
	
	if (response == Dialog_BasicsTutorial_Camera)
	{
		NextStepTimer(playerid, 15);
		if (TutorialDebug == 1) printf("[basics tutorial] Player %s is learning camera movement.", PName);
	}
	return 0;
}

public NextStep(playerid)
{
	new BasicsTutorial[24], ServerTutorial[24], Title[256], Text[2048], PName[MAX_PLAYER_NAME];
	GetPlayerName(playerid, PName, sizeof(PName));
	
	GetPVarString(playerid, "BasicsTutorial", BasicsTutorial, sizeof(BasicsTutorial));
	GetPVarString(playerid, "ServerTutorial", ServerTutorial, sizeof(ServerTutorial));
	
	if (TutorialDebug == 1) printf("[tutorial] NextStep %d for player %s.", GetPVarInt(playerid, "TutorialStep"), PName);
	
	if (GetPVarInt(playerid, "TutorialStep") == 0)
	{
		ShowPlayerDialog(playerid, Dialog_Tutorial_Question, DIALOG_STYLE_MSGBOX, "Tutorial", ReadFile("Question"), "No", "Yes");
	}
	
	else if (strcmp(BasicsTutorial, "true") == 0)
	{
		if (GetPVarInt(playerid, "TutorialStep") == 1)
		{
			format(Title, sizeof(Title), "%s", ReadFile("Basics/CameraTitle"));
			format(Text, sizeof(Text), "%s", ReadFile("Basics/Camera"));
			ShowPlayerDialog(playerid, Dialog_BasicsTutorial_Camera, DIALOG_STYLE_MSGBOX, Title, Text, "Ok", "");
			NextStepTimer(playerid, 10);
		}
		
		else if (GetPVarInt(playerid, "TutorialStep") == 2)
		{
			format(Title, sizeof(Title), "%s", ReadFile("Basics/MovementTitle"));
			format(Text, sizeof(Text), "%s", ReadFile("Basics/Movement"));
			ShowPlayerDialog(playerid, Dialog_BasicsTutorial_Movement, DIALOG_STYLE_MSGBOX, Title, Text, "Ok", "");
			NextStepTimer(playerid, 2);
		}
		
		else if (GetPVarInt(playerid, "TutorialStep") == 3)
		{
			GameTextForPlayer(playerid, "Move around using ~k~~GO_FORWARD~, ~k~~GO_LEFT~, ~k~~GO_BACK~ and ~k~~GO_RIGHT~.", 10*1000, 3);
			SetPVarString(playerid, "CountMoves", "true");
		}
	}
	
	SetPVarInt(playerid, "TutorialStep", GetPVarInt(playerid, "TutorialStep") + 1);
}

stock NextStepTimer(playerid, time)
{
	SetTimerEx("NextStep", time*1000, false, "%d", playerid);
}
Server log file:

Quote:

[18:10:19] [tutorial] Player spawned in tutorial place.
[18:10:22] [tutorial] NextStep 0 for player sekonoppa. //This is the place where the dialog should be shown
[18:10:46] [part] seontonppa has left the server (0:1)

Reply
#2

I still haven't figured out wheres the problem, can anyone help? If you need additional info just ask. I'm not using any plugins and the ReadFile("Filename") reads a file and then returns the text the file contained as a string
Reply
#3

Bump
Reply
#4

pawn Код:
SetTimerEx("NextStep", time*1000, false, "d", playerid); // this would be only d not %d
Reply
#5

Quote:
Originally Posted by iZN
Посмотреть сообщение
pawn Код:
SetTimerEx("NextStep", time*1000, false, "d", playerid); // this would be only d not %d
Thanks man it worked! I was trying to show the dialogs for invalid player ids :P I am very greatfull on your help
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)