#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(" Login-System");
print("--------------------------------------\n");
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
SpawnPlayer(playerid);
SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
SpawnPlayer(playerid);
return 1;
}
public OnPlayerConnect(playerid)
{
SpawnPlayer(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","LogIn","Abbrechen");
SpawnPlayer(playerid);
}
else
{
ShowPlayerDialog(playerid,DIALOG_REG,1,"Registrieren","Bitte Registriere dich","Registrieren","Abbrechen");
SpawnPlayer(playerid);
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
new pname[MAX_PLAYERS],accFormat[128];
GetPlayerPos(playerid,Spieler[playerid][lastx],Spieler[playerid][lasty],Spieler[playerid][lastz]);
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_FloatSet(accFormat,"skin",Spieler[playerid][skin]);
dini_FloatSet(accFormat,"skin",GetPlayerSkin(playerid));
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]);
SetPlayerSkin(playerid,Spieler[playerid][skin]);
}
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
SpawnPlayer(playerid);
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","LogIn","Abbrechen");
return SendClientMessage(playerid,0xFF6347AA,"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"));
SetPlayerSkin(playerid,dini_Int(accFormat,"skin"));
Spieler[playerid][eingeloggt] = 1;
SpawnPlayer(playerid); // Spieler ist nun erfolgreich eingeloggt
SendClientMessage(playerid,0x33AA33AA,"Du wurdest erfolgreich eingeloggt.");
SpawnPlayer(playerid);
}
else
{
ShowPlayerDialog(playerid,DIALOG_LOGIN,1,"Login","Bitte logge dich ein","LogIn","Abbrechen");
SendClientMessage(playerid,0xFF6347AA,"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","Registrieren","Abbrechen");
return SendClientMessage(playerid,840510,"Das Passwort ist zu kurz!");
}
dini_Create(accFormat);
dini_Set(accFormat,"Passwort",inputtext);
Spieler[playerid][eingeloggt] = 1;
SendClientMessage(playerid,0x33AA33AA,"Account wurde angelegt und du wurdest eingeloggt.");
SpawnPlayer(playerid);
}
}
}
else
{
switch(dialogid)
{
case DIALOG_LOGIN:ShowPlayerDialog(playerid,DIALOG_LOGIN,1,"Login","Bitte logge dich ein","LogIn","Abbrechen");
case DIALOG_REG:ShowPlayerDialog(playerid,DIALOG_REG,1,"Registrieren","Bitte Registriere dich","Registrieren","Abbrechen");
}
}
return 1;
}
Mein Problem ist das keine Player.datei erstellt wird wie es eigentlich sein müsste.
Hoffe ihr könnt mir helfen.
Dr_Ned