#include <a_samp>
#include <dini>
#define DIALOG_LOGIN 3
#define DIALOG_REG 4
enum spieler_daten
{
wanted,
skin,
Float:lastx,Float:lasty,Float:lastz,
eingeloggt
}
new Spieler[MAX_PLAYERS][spieler_daten];
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Blank Filterscript by your name here");
print("--------------------------------------\n");
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
return 1;
}
public OnPlayerConnect(playerid)
{
new pname[MAX_PLAYERS],accFormat[128];
GetPlayerName(playerid,pname,sizeof pname);
format(accFormat,sizeof accFormat,"%s.datei",pname);
if(fexist(accFormat))
{
ShowPlayerDialog(playerid,DIALOG_LOGIN,1,"Login","Bitte logge dich ein","Abbrechen","Weiter");
}
else
{
ShowPlayerDialog(playerid,DIALOG_REG,1,"Registrieren","Bitte Registriere dich","Abbrechen","Weiter");
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
new pname[MAX_PLAYERS],accFormat[128];
GetPlayerName(playerid,pname,sizeof pname);
format(accFormat,sizeof accFormat,"%s.datei",pname);
if(fexist(accFormat) && Spieler[playerid][eingeloggt])
{
dini_IntSet(accFormat,"wanted",Spieler[playerid][wanted]);
dini_IntSet(accFormat,"skin",Spieler[playerid][skin]);
dini_FloatSet(accFormat,"lastx",Spieler[playerid][lastx]);
dini_FloatSet(accFormat,"lasty",Spieler[playerid][lasty]);
dini_FloatSet(accFormat,"lastz",Spieler[playerid][lastz]);
dini_IntSet(accFormat,"Geld",GetPlayerMoney(playerid));
dini_IntSet(accFormat,"Score",GetPlayerScore(playerid));
}
Spieler[playerid][eingeloggt] = 0;
Spieler[playerid][wanted] = 0;
Spieler[playerid][skin] = 0;
Spieler[playerid][lastx] = (0.0);
Spieler[playerid][lasty] = (0.0);
Spieler[playerid][lastz] = (0.0);
return 1;
}
public OnPlayerSpawn(playerid)
{
new pname[MAX_PLAYERS],accFormat[128];
GetPlayerName(playerid,pname,sizeof pname);
format(accFormat,sizeof accFormat,"%s.datei",pname);
if(dini_Isset(accFormat,"lastx"))
{
SetPlayerPos(playerid,Spieler[playerid][lastx],Spieler[playerid][lasty],Spieler[playerid][lastz]);
}
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
new pname[MAX_PLAYERS],accFormat[128];
GetPlayerName(playerid,pname,sizeof pname);
format(accFormat,sizeof accFormat,"%s.datei",pname);
if(response)
{
switch(dialogid) // dialogid auswählen
{
case DIALOG_LOGIN: // ID Login
{
if(!strlen(inputtext))
{
ShowPlayerDialog(playerid,DIALOG_LOGIN,1,"Login","Bitte logge dich ein","Abbrechen","Weiter");
return SendClientMessage(playerid,0xFFFFFFFF,"Kein Passwort angegeben!");
}
if(strcmp(inputtext,dini_Get(accFormat,"Passwort")) == 0) // Passwort Direkt aus der Datei Laden
{
Spieler[playerid][wanted] = dini_Int(accFormat,"wanted");
Spieler[playerid][skin] = dini_Int(accFormat,"skin");
Spieler[playerid][lastx] = dini_Float(accFormat,"lastx");
Spieler[playerid][lasty] = dini_Float(accFormat,"lasty");
Spieler[playerid][lastz] = dini_Float(accFormat,"lastz");
GivePlayerMoney(playerid,dini_Int(accFormat,"Geld"));
SetPlayerScore(playerid,dini_Int(accFormat,"Score"));
Spieler[playerid][eingeloggt] = 1; // Spieler ist nun erfolgreich eingeloggt
SendClientMessage(playerid,0xFFFFFFFF,"Du wurdest erfolgreich eingeloggt.");
}
else
{
ShowPlayerDialog(playerid,DIALOG_LOGIN,1,"Login","Bitte logge dich ein","Abbrechen","Weiter");
SendClientMessage(playerid,0xFFFFFFFF,"Das Passwort war Falsch!");
}
}
case DIALOG_REG: // ID Registrieren
{
if(!strlen(inputtext)) // Text darf nicht = Null sein Null im Sinne von nichts
{
ShowPlayerDialog(playerid,DIALOG_REG,1,"Registrieren","Bitte Registriere dich","Abbrechen","Weiter");
return SendClientMessage(playerid,0xFFFFFFFF,"Das Passwort ist zu kurz!");
}
dini_Create(accFormat);
dini_Set(accFormat,"Passwort",inputtext);
Spieler[playerid][eingeloggt] = 1;
SendClientMessage(playerid,0xFFFFFFFF,"Account wurde angelegt und du wurdest eingeloggt.");
}
}
}
else
{
switch(dialogid)
{
case DIALOG_LOGIN:ShowPlayerDialog(playerid,DIALOG_LOGIN,1,"Login","Bitte logge dich ein","Abbrechen","Weiter");
case DIALOG_REG:ShowPlayerDialog(playerid,DIALOG_REG,1,"Registrieren","Bitte Registriere dich","Abbrechen","Weiter");
}
}
return 1;
}
Credits by Black_Fox_UD