Jump to content
  • 0

pomoc Registrace


Paulee

Dotaz

Zdravím,

Chtěl jsem si už konečně udělat Registraci. A tak jsem to dělal podle jednoho tutorialu (Už nevím kde). Píše mi to, že mám vše dobře, ale když se chci připojit na server, tak mě to tam prostě nepřipojí a ani tabulku nezobrazí.

Zde je celý kod:

OnDialogResponse:

 

 

if(dialogid == DIALOG_REGISTER)
	{
	    if(!response) Kick(playerid);
		if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,"Vítejte, prosím registrujte se!","{FFFFFF}Zde napište své {00FF22}heslo {FFFFFF}pro registraci","Registrovat","");
		if(response)
		{
		    new file[64];
			GetPlayerName(playerid,file,sizeof(file));
			format(file,sizeof(file),DOF2_File(file));
		    DOF2_CreateFile(file, inputtext);
			SaveData(playerid);
			SpawnPlayer(playerid);
		}
	}
	if(dialogid == DIALOG_LOGIN)
	{
	    if(!response) Kick(playerid);
	    if(response)
		{
      		new file[64];
			GetPlayerName(playerid,file,sizeof(file));
			format(file,sizeof(file),DOF2_File(file));
			if(DOF2_FileExists(file)) 
			{
				if(DOF2_CheckLogin(file,inputtext))
				{
		    		LoadData(playerid);
		    		SendClientMessage(playerid, -1, "Byl jsi přihlášen!");
		    		SpawnPlayer(playerid);
		    		return 1;
				}
				else
				{
				ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Špatné heslo!", "Napsal jsi špatné heslo!\nNapište své heslo znovu", "Přihlásit", "");
				}
			}
		}
	}

 

 

 

Stocky na ukládání a načítání dat.

 

 

stock LoadData(playerid)
{
	new file[64];
	GetPlayerName(playerid,file,sizeof(file));
	format(file,sizeof(file),DOF2_File(file));
	PlayerData[playerid][AdminLevel] = DOF2_GetInt(file,"AdminLevel");
	return 1;
}

stock SaveData(playerid)
{
	new file[64];
	GetPlayerName(playerid,file,sizeof(file));
	format(file,sizeof(file),DOF2_File(file));
	DOF2_SetInt(file, "AdminLevel", PlayerData[playerid][AdminLevel]);
	DOF2_SaveFile();
}

 

 

 

Na hoře:

 

 

enum pData
{
	AdminLevel
};
new PlayerData[MAX_PLAYERS][pData];

 

 

 

Connect a disconnect:

 

 

public OnPlayerConnect(playerid)
{
    new file[50+1];
	GetPlayerName(playerid,file,sizeof(file));
 	format(file,sizeof(file),DOF2_File(file));
	if(!DOF2_FileExists(file))
	{
	    ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Registrace", "Zaregistruj te se", "Registrovat", "Zavřít");
	}
	else
	{
		ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "Přihlate se", "Přihlásit", "Zavřít");
	}
	return (true);
}

public OnPlayerDisconnect(playerid, reason)
{
	SaveData(playerid);
	return (true);
}

 

 

 

Budu rád za každou radu, co mám opravit :).

Přeji pěkný den,

S pozdravem Petr.

Link to comment
Share on other sites

2 odpovědí na tuto otázku

Recommended Posts

  • 0

Mě přijde divný toto:

new file[50+1];
	GetPlayerName(playerid,file,sizeof(file));
 	format(file,sizeof(file),DOF2_File(file));

Sám jsem si to dal do nového pawn kódu a voila, nic se nenačte. Zkus to nějak obejít. Sice to DOF2_File všude používají, co se koukám na návody, ale to ještě neznamená, že to půjde :d

//hore:
#define CESTA "/Hraci/%s.ini" //klidne můžeš i bez toho jestli to chceš pouze do scriptfiles

//u formátování:
new file[50+1];
 format(file,sizeof(file),CESTA, PlayerName(playerid);
//a pak kontrla existence, prostě to jak už to máš. 

//stock na PlayerName
stock PlayerName(playerid)
{
    new Name[24+1];
    GetPlayerName(playerid, Name, sizeof(Name));
    return Name;
}
Edited by GaRGoyLeS
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...