Problem register and tut
#1

Hello. I have a problem with the registration, login, gender, origin, age and tutorial. How I choose gender in dialogue is the second time the same dialogue shows me. Please help!

Код:
#include <a_samp>
#include <a_mysql>
#include <whirlpool>
//
#include <foreach>

main(){}

#define		MYSQL_HOST 				"127.0.0.1"
#define		MYSQL_USER 				"root"
#define		MYSQL_PASSWORD 			"12345"
#define		MYSQL_DATABASE 			"mydatabse"

#define	DIALOG_LOGIN 1
#define	DIALOG_REGISTER 2

new MySQL:ggg_SQL;
new MySQL_raceCheck[MAX_PLAYERS];

enum pInfo
{
	ID,
	Name[MAX_PLAYER_NAME],
	Password[129],
	Cache:Cache_ID,
	//
	pOrigin,
	pSex,
	pAge,
	pLevel,
	pTut
};
new PlayerInfo[MAX_PLAYERS][pInfo];

new GUIExit[MAX_PLAYERS];
new RegistrationStep[MAX_PLAYERS];
new TutTime[MAX_PLAYERS];

SetupPlayerTable()
{
	new query[1024];
	strcat(query, "CREATE TABLE IF NOT EXISTS `players` (`id` int(11) NOT NULL AUTO_INCREMENT, `username` varchar(24) NOT NULL, `password` char(129) NOT NULL,");
	strcat(query, "`origin` int(5) NOT NULL, `sex` int(5) NOT NULL, `age` int(5) NOT NULL, `level` int(5) NOT NULL,");
	strcat(query, "PRIMARY KEY (`id`), UNIQUE KEY `username` (`username`))");

	mysql_tquery(ggg_SQL, query);
	return 1;
}

public OnGameModeInit()
{
	new MySQLOpt:option_id = mysql_init_options();

	mysql_set_option(option_id, AUTO_RECONNECT, true);

	ggg_SQL = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE, option_id);
	if(ggg_SQL == MYSQL_INVALID_HANDLE || mysql_errno(ggg_SQL) != 0)
	{
		print("MySQL Error!");
		SendRconCommand("exit");
		return 1;
	}
	else
	{
		print("MySQL Connect!");
	}

	SetupPlayerTable();

	SetTimer("OneSecondsTimer", 1000, true);

	return 1;
}

public OnGameModeExit()
{
	mysql_close(ggg_SQL);

	return 1;
}

public OnPlayerConnect(playerid)
{
	PlayerInfo[playerid][pLevel] = 0;
	PlayerInfo[playerid][pOrigin] = 0;
	PlayerInfo[playerid][pSex] = 0;
	PlayerInfo[playerid][pAge] = 0;
	PlayerInfo[playerid][pTut] = 0;

	RegistrationStep[playerid] = 0;
	GUIExit[playerid] = 0;
	TutTime[playerid] = 0;

	MySQL_raceCheck[playerid]++;

	static const empty_player[pInfo];
	PlayerInfo[playerid] = empty_player;

	GetPlayerName(playerid, PlayerInfo[playerid][Name], MAX_PLAYER_NAME);

	new query[103];
	mysql_format(ggg_SQL, query, sizeof(query), "SELECT * FROM `players` WHERE `username` = '%e' LIMIT 1", PlayerInfo[playerid][Name]);
	mysql_tquery(ggg_SQL, query, "OnPlayerDataLoaded", "dd", playerid, MySQL_raceCheck[playerid]);

	return 1;
}

forward OnPlayerDataLoaded(playerid, race_check);
public OnPlayerDataLoaded(playerid, race_check)
{
	if(race_check != MySQL_raceCheck[playerid]) return Kick(playerid);

	new string[115];
	if(cache_num_rows() > 0)
	{
		cache_get_value(0, "password", PlayerInfo[playerid][Password], 129);

		PlayerInfo[playerid][Cache_ID] = cache_save();

		format(string, sizeof string, "Account (%s) succes.", PlayerInfo[playerid][Name]);
		ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", string, "Login", "Exit");
	}
	else
	{
		format(string, sizeof string, "Hello %s, please register.", PlayerInfo[playerid][Name]);
		ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Register", string, "Register", "Exit");
	}
	return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	switch(dialogid)
	{
		case DIALOG_LOGIN:
		{
			if(!response) return Kick(playerid);

            new HashPass[129];
            WP_Hash(HashPass, sizeof(HashPass), inputtext);

			if(strcmp(HashPass, PlayerInfo[playerid][Password]) == 0)
			{
				cache_set_active(PlayerInfo[playerid][Cache_ID]);

				cache_delete(PlayerInfo[playerid][Cache_ID]);
				PlayerInfo[playerid][Cache_ID] = MYSQL_INVALID_CACHE;
			}
			else
			{
				ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "Wrong password!", "Login", "Exit");
			}
		}
		case DIALOG_REGISTER:
		{
			if(!response) return Kick(playerid);

			if(strlen(inputtext) >= 6 && strlen(inputtext) <= 64)
			{
				ShowPlayerDialog(playerid, 70, DIALOG_STYLE_LIST, "Choose gender", "Man\nWoman", "Next", "Back");

				/*
	            new HashPass[129];
	            WP_Hash(HashPass, sizeof(HashPass), inputtext);

				new query[300];
				mysql_format(g_SQL, query, sizeof(query), "INSERT INTO `players` (`username`, `password`) VALUES ('%e', '%s')", PlayerInfo[playerid][Name], HashPass);
				mysql_tquery(g_SQL, query, "OnPlayerRegister", "d", playerid);
				*/
			}
			else
			{
				ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Rejestracja", "Twoje hasło musi mieć od 6 do 64 znakуw!\nW polu poniżej wpisz swoje hasło:", "Zarejestruj", "Wyjdź");
			}
		}

		case 70:
		{
		    if(response)
		    {
		        ShowPlayerDialog(playerid, 71, DIALOG_STYLE_LIST, "Choose gender 2", "Man\nWoman", "Next", "Back");
		    }
		    if(!response)
		    {
		        ShowPlayerDialog(playerid, 71, DIALOG_STYLE_LIST, "Choose gender 2", "Man\nWoman", "Next", "Back");
		    }
		}
		case 71:
		{
		    if(response)
		    {
		        switch(listitem)
				{
				    case 0://men
				    {
				        ShowPlayerDialog(playerid, 72, DIALOG_STYLE_LIST, "Choose the origin", "USA\nEurope\nAsia", "Next", "Back");
	                    PlayerInfo[playerid][pSex] = 1;
	                    SendClientMessage(playerid, -1, "Your character is a man.");
					}
				    case 1://baba
				    {
				        ShowPlayerDialog(playerid, 72, DIALOG_STYLE_LIST, "Choose the origin", "USA\nEuropa\nAsia", "Next", "Back");
	                    PlayerInfo[playerid][pSex] = 2;
	                    SendClientMessage(playerid, -1, "Your character is a woman.");
					}
				}
			}
		    if(!response)
		    {
		        ShowPlayerDialog(playerid, 70, DIALOG_STYLE_MSGBOX, "Welcome RolePlay", "Welcome to the Role Play server.\nIf you're new here, we've prepared 2 guides for you.\nYou can see them for a while, but first you have to describe the character you will play\nWe wish you a nice game.", "Next", "");
		    }
		}
		case 72:
		{
		    if(response)
		    {
				switch(listitem)
				{
				    case 0://usa
				    {
				        PlayerInfo[playerid][pOrigin] = 1;
				        SendClientMessage(playerid, -1, "Your character is now a USA.");
				    }
				    case 1://europe
				    {
				        PlayerInfo[playerid][pOrigin] = 2;
				        SendClientMessage(playerid, -1, "Your character is now a EUROPE.");
				    }
				    case 2://azia
				    {
				        SendClientMessage(playerid, -1, "Your character is now a ASIA.");
				        PlayerInfo[playerid][pOrigin] = 3;
				    }
				}
				ShowPlayerDialog(playerid, 73, DIALOG_STYLE_INPUT, "Choose the age of the character", "Enter the age of your character (from 16 to 140 years)", "Next", "Back");
			}
			if(!response)
			{
			    ShowPlayerDialog(playerid, 71, DIALOG_STYLE_LIST, "Gender", "Man\nWoman", "Next", "Back");
			}
		}
		case 73:
		{
		    if(response)
		    {
		        if(strlen(inputtext) > 1 && strlen(inputtext) < 4)
	            {
	                if(strval(inputtext) >= 16 && strval(inputtext) <= 140)
	                {
	                    PlayerInfo[playerid][pAge] = strval(inputtext);
						ShowPlayerDialog(playerid, 74, DIALOG_STYLE_MSGBOX, "Tutorial", "This is all the data you had to provide. Now you have to go through the tutorial.\nTo start it, press 'Next'", "Next", "Back");
	                }
	                else
	                {
	                    ShowPlayerDialog(playerid, 73, DIALOG_STYLE_INPUT, "Character age", "Enter the age of your character (from 16 to 140 years)", "Next", "Back");
	                }
	            }
	            else
	            {
	                ShowPlayerDialog(playerid, 73, DIALOG_STYLE_INPUT, "Character age", "Enter the age of your character (from 16 to 140 years)", "Next", "Back");
	            }
		    }
		    if(!response)
		    {
		        ShowPlayerDialog(playerid, 72, DIALOG_STYLE_LIST, "Origin", "USA\nEurope\nAsia", "Next", "Back");
		    }
		}
		case 74:
		{
            if(PlayerInfo[playerid][pLevel] > 1) return 1;
		    if(response)
		    {
				TogglePlayerControllable(playerid, 0);
				SetPlayerVirtualWorld(playerid, 0);
				GUIExit[playerid] = 0;
		   		SendClientMessage(playerid, -1, "Welcome Role Play server.");
				SendClientMessage(playerid, -1, "Tutorial...");
				SendClientMessage(playerid, -1, "Tutorial...");
				SendClientMessage(playerid, -1, "Tutorial...");
				RegistrationStep[playerid] = 0;
	   			TutTime[playerid] = 1;
		    }
		    if(!response)
		    {
		        ShowPlayerDialog(playerid, 73, DIALOG_STYLE_INPUT, "Character age", "Enter the age of your character (from 16 to 140 years)", "Next", "Back");
		    }
		}

		default: return 0;
	}
	return 1;
}

forward OnPlayerRegister(playerid);
public OnPlayerRegister(playerid)
{
	PlayerInfo[playerid][ID] = cache_insert_id();
	return 1;
}

forward OneSecondsTimer();
public OneSecondsTimer()
{
    foreach(Player, i)
	{
        if(!IsPlayerConnected(i)) continue;

		if(TutTime[i] >= 1 && !IsPlayerNPC(i))
		{
			TutTime[i] += 1;
			if(TutTime[i] == 3)
			{
				SetPlayerPos(i, 849.62371826172, -989.92199707031, -5.0);
				SetPlayerCameraPos(i, 849.62371826172, -989.92199707031, 53.211112976074);
				SetPlayerCameraLookAt(i, 907.40313720703, -913.14117431641, 77.788856506348);
				SendClientMessage(i, -1, "|____ Tutorial: Tutorial 1 ____|");
				SendClientMessage(i, -1, "Tutorial 1...");
				SendClientMessage(i, -1, "Tutorial 1...");
			}
			else if(TutTime[i] == 14)
			{
				SetPlayerPos(i, 326.09194946289, -1521.3157958984, 20.0);
				SetPlayerCameraPos(i, 398.16021728516, -1511.9237060547, 78.641815185547);
				SetPlayerCameraLookAt(i, 326.09194946289, -1521.3157958984, 42.154850006104);
				SendClientMessage(i, -1, "|____ Tutorial: Tutorial 2 ____|");
			}
			else if(TutTime[i] == 16)
			{
				SendClientMessage(i, -1, "Tutorial 2...");
				SendClientMessage(i, -1, "Tutorial 2...");
			}
			else if(TutTime[i] == 30)
			{
				SetPlayerPos(i, 1016.9872436523, -1372.0234375, -5.0);
				SetPlayerCameraPos(i, 1053.3154296875, -1326.3295898438, 28.300031661987);
				SetPlayerCameraLookAt(i, 1016.9872436523, -1372.0234375, 15.836219787598);
				SendClientMessage(i, -1, "|____ Tutorial: Tutorial 3 ____|");
			}
			else if(TutTime[i] == 32)
			{
				SendClientMessage(i, -1, "Tutorial 3...");
				SendClientMessage(i, -1, "Tutorial 3...");
			}
			else if(TutTime[i] == 52)
			{
				SetPlayerPos(i, 1352.2797851563, -1757.189453125, -5.0);
				SetPlayerCameraPos(i, 1352.4576416016, -1725.1925048828, 23.291763305664);
				SetPlayerCameraLookAt(i, 1352.2797851563, -1757.189453125, 13.5078125);
				SendClientMessage(i, -1, "|____ Tutorial: Tutorial 4____|");
			}
			else if(TutTime[i] == 54)
			{
				SendClientMessage(i, -1, "Tutorial 4...");
				SendClientMessage(i, -1, "Tutorial 4...");
			}
			else if(TutTime[i] == 74)
			{
				SetPlayerPos(i, 370.02825927734, -2083.5886230469, -10.0);
				SetPlayerCameraPos(i, 340.61755371094, -2091.701171875, 22.800081253052);
				SetPlayerCameraLookAt(i, 370.02825927734, -2083.5886230469, 8.1386299133301);
				SendClientMessage(i, -1, "|____ Tutorial: Tutorial 5 ____|");
			}
			else if(TutTime[i] == 76)
			{
				SendClientMessage(i, -1, "Tutorial 5...");
				SendClientMessage(i, -1, "Tutorial 5...");
			}
			else if(TutTime[i] == 96)
			{
				SetPlayerPos(i, 1172.8602294922, -1331.978515625, -5.0);
				SetPlayerCameraPos(i, 1228.7977294922, -1345.1479492188, 21.532119750977);
				SetPlayerCameraLookAt(i, 1172.8602294922, -1331.978515625, 14.317019462585);
				SendClientMessage(i, -1, "|____ Tutorial: Tutorial 6 ____|");
			}
			else if(TutTime[i] == 98)
			{
				SendClientMessage(i, -1, "Tutorial 6...");
				SendClientMessage(i, -1, "Tutorial 6...");
			}
			else if(TutTime[i] == 112)
			{
				SetPlayerPos(i, 412.80743408203, -1312.4066162109, -5.0);
				SetPlayerCameraPos(i, 402.2776184082, -1351.4703369141, 43.704566955566);
				SetPlayerCameraLookAt(i, 412.80743408203, -1312.4066162109, 39.677307128906);
				SendClientMessage(i, -1, "|____ Tutorial: Tutorial 7 ____|");
			}
			else if(TutTime[i] == 114)
			{
				SendClientMessage(i, -1, "Tutorial 7...");
				SendClientMessage(i, -1, "Tutorial 7...");
			}
			else if(TutTime[i] == 125)
			{
				TutTime[i] = 0; PlayerInfo[i][pTut] = 1;

				TogglePlayerControllable(i, 1);

				//Spawn, selector...
			}
		}
	}
	return 1;
}
Reply
#2

New code. This is similar to GodFather, I just did the code differently. Please help!

Код:
#include <a_samp>
#include <a_mysql>
#include <whirlpool>
//
#include <foreach>

main(){}

#define		MYSQL_HOST 				"127.0.0.1"
#define		MYSQL_USER 				"root"
#define		MYSQL_PASSWORD 			"12345"
#define		MYSQL_DATABASE 			"mojabaza"

#define	DIALOG_LOGIN 1
#define	DIALOG_REGISTER 2

new MySQL:ggg_SQL;
new MySQL_raceCheck[MAX_PLAYERS];

enum pInfo
{
	ID,
	Name[MAX_PLAYER_NAME],
	Password[129],
	Cache:Cache_ID,
	//
	pOrigin,
	pSex,
	pAge,
	pLevel,
	pTut
};
new PlayerInfo[MAX_PLAYERS][pInfo];

new GUIExit[MAX_PLAYERS];
new RegistrationStep[MAX_PLAYERS];
new TutTime[MAX_PLAYERS];

SetupPlayerTable()
{
	new query[1024];
	strcat(query, "CREATE TABLE IF NOT EXISTS `players` (`id` int(11) NOT NULL AUTO_INCREMENT, `username` varchar(24) NOT NULL, `password` char(129) NOT NULL,");
	strcat(query, "`origin` int(5) NOT NULL, `sex` int(5) NOT NULL, `age` int(5) NOT NULL, `level` int(5) NOT NULL,");
	strcat(query, "PRIMARY KEY (`id`), UNIQUE KEY `username` (`username`))");

	mysql_tquery(ggg_SQL, query);
	return 1;
}

public OnGameModeInit()
{
	new MySQLOpt:option_id = mysql_init_options();

	mysql_set_option(option_id, AUTO_RECONNECT, true);

	ggg_SQL = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE, option_id);
	if(ggg_SQL == MYSQL_INVALID_HANDLE || mysql_errno(ggg_SQL) != 0)
	{
		print("MySQL Error!");
		SendRconCommand("exit");
		return 1;
	}
	else
	{
		print("MySQL Connect!");
	}

	SetupPlayerTable();

	NewSelector::Init();

	SetTimer("OneSecondsTimer", 1000, true);

	return 1;
}

public OnGameModeExit()
{
	mysql_close(ggg_SQL);

	return 1;
}

public OnPlayerConnect(playerid)
{
	PlayerInfo[playerid][pLevel] = 0;
	PlayerInfo[playerid][pOrigin] = 0;
	PlayerInfo[playerid][pSex] = 0;
	PlayerInfo[playerid][pAge] = 0;
	PlayerInfo[playerid][pTut] = 0;

	RegistrationStep[playerid] = 0;
	GUIExit[playerid] = 0;
	TutTime[playerid] = 0;

	MySQL_raceCheck[playerid]++;

	static const empty_player[pInfo];
	PlayerInfo[playerid] = empty_player;

	GetPlayerName(playerid, PlayerInfo[playerid][Name], MAX_PLAYER_NAME);

	new query[103];
	mysql_format(ggg_SQL, query, sizeof(query), "SELECT * FROM `players` WHERE `username` = '%e' LIMIT 1", PlayerInfo[playerid][Name]);
	mysql_tquery(ggg_SQL, query, "OnPlayerDataLoaded", "dd", playerid, MySQL_raceCheck[playerid]);

	return 1;
}

forward OnPlayerDataLoaded(playerid, race_check);
public OnPlayerDataLoaded(playerid, race_check)
{
	if(race_check != MySQL_raceCheck[playerid]) return Kick(playerid);

	new string[115];
	if(cache_num_rows() > 0)
	{
		cache_get_value(0, "password", PlayerInfo[playerid][Password], 129);

		PlayerInfo[playerid][Cache_ID] = cache_save();

		format(string, sizeof string, "Account (%s) succes.", PlayerInfo[playerid][Name]);
		ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", string, "Login", "Exit");
	}
	else
	{
		format(string, sizeof string, "Hello %s, please register.", PlayerInfo[playerid][Name]);
		ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Register", string, "Register", "Exit");
	}
	return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	switch(dialogid)
	{
		case DIALOG_LOGIN:
		{
			if(!response) return Kick(playerid);

            new HashPass[129];
            WP_Hash(HashPass, sizeof(HashPass), inputtext);

			if(strcmp(HashPass, PlayerInfo[playerid][Password]) == 0)
			{
				cache_set_active(PlayerInfo[playerid][Cache_ID]);

				cache_delete(PlayerInfo[playerid][Cache_ID]);
				PlayerInfo[playerid][Cache_ID] = MYSQL_INVALID_CACHE;

				GUIExit[playerid] = 0;
			}
			else
			{
				ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "Wrong password!", "Login", "Exit");
			}
		}
		case DIALOG_REGISTER:
		{
			if(!response) return Kick(playerid);

			if(strlen(inputtext) >= 6 && strlen(inputtext) <= 64)
			{
				/*
	            new HashPass[129];
	            WP_Hash(HashPass, sizeof(HashPass), inputtext);

				new query[300];
				mysql_format(g_SQL, query, sizeof(query), "INSERT INTO `players` (`username`, `password`) VALUES ('%e', '%s')", PlayerInfo[playerid][Name], HashPass);
				mysql_tquery(g_SQL, query, "OnPlayerRegister", "d", playerid);
				*/

				GUIExit[playerid] = 0;
				SetPlayerVirtualWorld(playerid, 0);

				ShowPlayerDialog(playerid, 71, DIALOG_STYLE_LIST, "Choose gender 2", "Man\nWoman", "Next", "Back");
			}
			else
			{
				ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Register", "Enter password", "Register", "Exit");
			}
		}

		case 70:
		{
		    if(response)
		    {
		        ShowPlayerDialog(playerid, 71, DIALOG_STYLE_LIST, "Choose gender 2", "Man\nWoman", "Next", "Back");
		    }
		    if(!response)
		    {
		        ShowPlayerDialog(playerid, 71, DIALOG_STYLE_LIST, "Choose gender 2", "Man\nWoman", "Next", "Back");
		    }
		}
		case 71:
		{
		    if(response)
		    {
		        switch(listitem)
				{
				    case 0://men
				    {
				        ShowPlayerDialog(playerid, 72, DIALOG_STYLE_LIST, "Choose the origin", "USA\nEurope\nAsia", "Next", "Back");
	                    PlayerInfo[playerid][pSex] = 1;
	                    SendClientMessage(playerid, -1, "Your character is a man.");
					}
				    case 1://baba
				    {
				        ShowPlayerDialog(playerid, 72, DIALOG_STYLE_LIST, "Choose the origin", "USA\nEuropa\nAsia", "Next", "Back");
	                    PlayerInfo[playerid][pSex] = 2;
	                    SendClientMessage(playerid, -1, "Your character is a woman.");
					}
				}
			}
		    if(!response)
		    {
		        ShowPlayerDialog(playerid, 70, DIALOG_STYLE_MSGBOX, "Welcome RolePlay", "Welcome to the Role Play server.\nIf you're new here, we've prepared 2 guides for you.\nYou can see them for a while, but first you have to describe the character you will play\nWe wish you a nice game.", "Next", "");
		    }
		}
		case 72:
		{
		    if(response)
		    {
				switch(listitem)
				{
				    case 0://usa
				    {
				        PlayerInfo[playerid][pOrigin] = 1;
				        SendClientMessage(playerid, -1, "Your character is now a USA.");
				    }
				    case 1://europe
				    {
				        PlayerInfo[playerid][pOrigin] = 2;
				        SendClientMessage(playerid, -1, "Your character is now a EUROPE.");
				    }
				    case 2://azia
				    {
				        SendClientMessage(playerid, -1, "Your character is now a ASIA.");
				        PlayerInfo[playerid][pOrigin] = 3;
				    }
				}
				ShowPlayerDialog(playerid, 73, DIALOG_STYLE_INPUT, "Choose the age of the character", "Enter the age of your character (from 16 to 140 years)", "Next", "Back");
			}
			if(!response)
			{
			    ShowPlayerDialog(playerid, 71, DIALOG_STYLE_LIST, "Gender", "Man\nWoman", "Next", "Back");
			}
		}
		case 73:
		{
		    if(response)
		    {
		        if(strlen(inputtext) > 1 && strlen(inputtext) < 4)
	            {
	                if(strval(inputtext) >= 16 && strval(inputtext) <= 140)
	                {
	                    PlayerInfo[playerid][pAge] = strval(inputtext);
						ShowPlayerDialog(playerid, 74, DIALOG_STYLE_MSGBOX, "Tutorial", "This is all the data you had to provide. Now you have to go through the tutorial.\nTo start it, press 'Next'", "Next", "Back");
	                }
	                else
	                {
	                    ShowPlayerDialog(playerid, 73, DIALOG_STYLE_INPUT, "Character age", "Enter the age of your character (from 16 to 140 years)", "Next", "Back");
	                }
	            }
	            else
	            {
	                ShowPlayerDialog(playerid, 73, DIALOG_STYLE_INPUT, "Character age", "Enter the age of your character (from 16 to 140 years)", "Next", "Back");
	            }
		    }
		    if(!response)
		    {
		        ShowPlayerDialog(playerid, 72, DIALOG_STYLE_LIST, "Origin", "USA\nEurope\nAsia", "Next", "Back");
		    }
		}
		case 74:
		{
            if(PlayerInfo[playerid][pLevel] > 1) return 1;
		    if(response)
		    {
				TogglePlayerControllable(playerid, 0);
				SetPlayerVirtualWorld(playerid, 0);
				GUIExit[playerid] = 0;
		   		SendClientMessage(playerid, -1, "Welcome Role Play server.");
				SendClientMessage(playerid, -1, "Tutorial...");
				SendClientMessage(playerid, -1, "Tutorial...");
				SendClientMessage(playerid, -1, "Tutorial...");
				RegistrationStep[playerid] = 0;
	   			TutTime[playerid] = 1;
		    }
		    if(!response)
		    {
		        ShowPlayerDialog(playerid, 73, DIALOG_STYLE_INPUT, "Character age", "Enter the age of your character (from 16 to 140 years)", "Next", "Back");
		    }
		}

		default: return 0;
	}
	return 1;
}

forward OnPlayerRegister(playerid);
public OnPlayerRegister(playerid)
{
	PlayerInfo[playerid][ID] = cache_insert_id();
	return 1;
}

forward OneSecondsTimer();
public OneSecondsTimer()
{
    foreach(Player, i)
	{
        if(!IsPlayerConnected(i)) continue;

		if(TutTime[i] >= 1 && !IsPlayerNPC(i))
		{
			TutTime[i] += 1;
			if(TutTime[i] == 3)
			{
				SetPlayerPos(i, 849.62371826172, -989.92199707031, -5.0);
				SetPlayerCameraPos(i, 849.62371826172, -989.92199707031, 53.211112976074);
				SetPlayerCameraLookAt(i, 907.40313720703, -913.14117431641, 77.788856506348);
				SendClientMessage(i, -1, "|____ Tutorial: Tutorial 1 ____|");
				SendClientMessage(i, -1, "Tutorial 1...");
				SendClientMessage(i, -1, "Tutorial 1...");
			}
			else if(TutTime[i] == 14)
			{
				SetPlayerPos(i, 326.09194946289, -1521.3157958984, 20.0);
				SetPlayerCameraPos(i, 398.16021728516, -1511.9237060547, 78.641815185547);
				SetPlayerCameraLookAt(i, 326.09194946289, -1521.3157958984, 42.154850006104);
				SendClientMessage(i, -1, "|____ Tutorial: Tutorial 2 ____|");
			}
			else if(TutTime[i] == 16)
			{
				SendClientMessage(i, -1, "Tutorial 2...");
				SendClientMessage(i, -1, "Tutorial 2...");
			}
			else if(TutTime[i] == 30)
			{
				SetPlayerPos(i, 1016.9872436523, -1372.0234375, -5.0);
				SetPlayerCameraPos(i, 1053.3154296875, -1326.3295898438, 28.300031661987);
				SetPlayerCameraLookAt(i, 1016.9872436523, -1372.0234375, 15.836219787598);
				SendClientMessage(i, -1, "|____ Tutorial: Tutorial 3 ____|");
			}
			else if(TutTime[i] == 32)
			{
				SendClientMessage(i, -1, "Tutorial 3...");
				SendClientMessage(i, -1, "Tutorial 3...");
			}
			else if(TutTime[i] == 52)
			{
				SetPlayerPos(i, 1352.2797851563, -1757.189453125, -5.0);
				SetPlayerCameraPos(i, 1352.4576416016, -1725.1925048828, 23.291763305664);
				SetPlayerCameraLookAt(i, 1352.2797851563, -1757.189453125, 13.5078125);
				SendClientMessage(i, -1, "|____ Tutorial: Tutorial 4____|");
			}
			else if(TutTime[i] == 54)
			{
				SendClientMessage(i, -1, "Tutorial 4...");
				SendClientMessage(i, -1, "Tutorial 4...");
			}
			else if(TutTime[i] == 74)
			{
				SetPlayerPos(i, 370.02825927734, -2083.5886230469, -10.0);
				SetPlayerCameraPos(i, 340.61755371094, -2091.701171875, 22.800081253052);
				SetPlayerCameraLookAt(i, 370.02825927734, -2083.5886230469, 8.1386299133301);
				SendClientMessage(i, -1, "|____ Tutorial: Tutorial 5 ____|");
			}
			else if(TutTime[i] == 76)
			{
				SendClientMessage(i, -1, "Tutorial 5...");
				SendClientMessage(i, -1, "Tutorial 5...");
			}
			else if(TutTime[i] == 96)
			{
				SetPlayerPos(i, 1172.8602294922, -1331.978515625, -5.0);
				SetPlayerCameraPos(i, 1228.7977294922, -1345.1479492188, 21.532119750977);
				SetPlayerCameraLookAt(i, 1172.8602294922, -1331.978515625, 14.317019462585);
				SendClientMessage(i, -1, "|____ Tutorial: Tutorial 6 ____|");
			}
			else if(TutTime[i] == 98)
			{
				SendClientMessage(i, -1, "Tutorial 6...");
				SendClientMessage(i, -1, "Tutorial 6...");
			}
			else if(TutTime[i] == 112)
			{
				SetPlayerPos(i, 412.80743408203, -1312.4066162109, -5.0);
				SetPlayerCameraPos(i, 402.2776184082, -1351.4703369141, 43.704566955566);
				SetPlayerCameraLookAt(i, 412.80743408203, -1312.4066162109, 39.677307128906);
				SendClientMessage(i, -1, "|____ Tutorial: Tutorial 7 ____|");
			}
			else if(TutTime[i] == 114)
			{
				SendClientMessage(i, -1, "Tutorial 7...");
				SendClientMessage(i, -1, "Tutorial 7...");
			}
			else if(TutTime[i] == 125)
			{
				TutTime[i] = 0; PlayerInfo[i][pTut] = 1;

				TogglePlayerControllable(i, 1);

				SetPlayerSpawn(i);

				SpawnPlayer(i);

				SetPVarInt(i, "Choosing_The_First_One", 1);

				SetPlayerCameraPos(i, 206.288314, -38.114028, 1002.229675);
				SetPlayerCameraLookAt(i, 208.775955, -34.981678, 1001.929687);

				NewSelector::Setup(i);

				SetPlayerCameraPos(i, 206.288314, -38.114028, 1002.229675);
				SetPlayerCameraLookAt(i, 208.775955, -34.981678, 1001.929687);
			}
		}
	}
	return 1;
}

SetPlayerSpawn(playerid)
{
	SetPlayerSpawnPos(playerid);
	return 1;
}

SetPlayerSpawnPos(playerid)
{
    //Tutorial:
    if(PlayerInfo[playerid][pTut] == 0)
    {
		TogglePlayerControllable(playerid, 0);
		RegistrationStep[playerid] = 1;
	    SetPlayerPos(playerid, 1275.0283203125, -1337.3585205078, -5.0);
	    SetPlayerCameraPos(playerid, 1275.0283203125, -1337.3585205078, 10.852507591248);
		SetPlayerCameraLookAt(playerid, 1235.1977539063, -1341.1885986328, 54.349945068359);
		SendClientMessage(playerid, -1, "Welcome Role Play!");
		SendClientMessage(playerid, -1, "To start the game you have to go through the registration procedure.");
		ShowPlayerDialog(playerid, 70, DIALOG_STYLE_MSGBOX, "Welcome to Role Play"," Welcome to Role Play server.\nIf you're new here, we've prepared a guide for you.\nYou can see it for a moment, but first you will have to describe the character you control\nTo go further, press the button 'Next'", "Next", "");
    }
	return 1;
}
Reply
#3

@REF
Reply
#4

you have two if responses opening the same dialog ID for dialog 70

Код:
if(response)
		    {
		        ShowPlayerDialog(playerid, 71, DIALOG_STYLE_LIST, "Choose gender 2", "Man\nWoman", "Next", "Back");
		    }
		    if(!response)
		    {
		        ShowPlayerDialog(playerid, 71, DIALOG_STYLE_LIST, "Choose gender 2", "Man\nWoman", "Next", "Back");
		    }
You also load on negative response for dialog ID 71 dialog 70

Код:
case 71:
		{
		    if(response)
		    {
		        switch(listitem)
				{
				    case 0://men
				    {
				        ShowPlayerDialog(playerid, 72, DIALOG_STYLE_LIST, "Choose the origin", "USA\nEurope\nAsia", "Next", "Back");
	                    PlayerInfo[playerid][pSex] = 1;
	                    SendClientMessage(playerid, -1, "Your character is a man.");
					}
				    case 1://baba
				    {
				        ShowPlayerDialog(playerid, 72, DIALOG_STYLE_LIST, "Choose the origin", "USA\nEuropa\nAsia", "Next", "Back");
	                    PlayerInfo[playerid][pSex] = 2;
	                    SendClientMessage(playerid, -1, "Your character is a woman.");
					}
				}
			}
		    if(!response)
		    {
		        ShowPlayerDialog(playerid, 70, DIALOG_STYLE_MSGBOX, "Welcome RolePlay", "Welcome to the Role Play server.\nIf you're new here, we've prepared 2 guides for you.\nYou can see them for a while, but first you have to describe the character you will play\nWe wish you a nice game.", "Next", ""); //change this 70 to 71
		    }
		}
Also in the first bit of code you are showing the dialog ID 70 which has the two responses so if he does next response as continue it loads ID 71 to select again same with the back button on dialog 70.

Код:
case DIALOG_REGISTER:
		{
			if(!response) return Kick(playerid);

			if(strlen(inputtext) >= 6 && strlen(inputtext) <= 64)
			{
				ShowPlayerDialog(playerid, 70, DIALOG_STYLE_LIST, "Choose gender", "Man\nWoman", "Next", "Back"); //change this 70 here to 71

				/*
	            new HashPass[129];
	            WP_Hash(HashPass, sizeof(HashPass), inputtext);

				new query[300];
				mysql_format(g_SQL, query, sizeof(query), "INSERT INTO `players` (`username`, `password`) VALUES ('%e', '%s')", PlayerInfo[playerid][Name], HashPass);
				mysql_tquery(g_SQL, query, "OnPlayerRegister", "d", playerid);
				*/
			}
			else
			{
				ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Rejestracja", "Twoje hasło musi mieć od 6 do 64 znakуw!\nW polu poniżej wpisz swoje hasło:", "Zarejestruj", "Wyjdź");
			}
		}
This is probably why its showing up twice.
Reply
#5

After completing the tutorial, I wanted him to move me to choose a skin but I do not know how to do it.

Код:
NewSelector::Init();
NewSelector::Setup(i);
Reply
#6

@REF
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)