OnPlayerRequestClass:
public OnPlayerRequestClass(playerid, classid)
{
SetSpawnInfo(playerid, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0);
TogglePlayerSpectating(playerid, true);
SetTimerEx("ShowLoginDialog", 100, 0, "i", playerid);
return 1;
}
ShowLoginDialog:
public ShowLoginDialog(playerid)
{
new string[500];
SetPlayerCameraPos(playerid,1093.000000,-2036.000000,90.000000);
SetPlayerCameraLookAt(playerid,-0.825859,0.557950,-0.081537,CAMERA_CUT);
ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login","Bitte tippe dein Passwort ein:","Okay","Abbrechen");
ClearChat(playerid);
return 1;
}
Alles anzeigen
DIALOG_LOGIN:
if(dialogid==DIALOG_LOGIN)
{
if(response)
{
new name[MAX_PLAYER_NAME],query[128],passwort[35];
GetPlayerName(playerid,name,sizeof(name));
if(strlen(inputtext)>0)
{
mysql_escape_string(inputtext,passwort,dbhandle);
format(query,sizeof(query),"SELECT * FROM user WHERE username='%s' AND password=MD5('%s')",name,passwort);
mysql_function_query(dbhandle,query,true,"OnPasswordResponse","i",playerid);
}
else
{
//Keine Eingabe
SendClientMessage(playerid,COLOR_RED,"Gibt bitte dein Passwort ein.");
ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login","Gibt bitte dein Passwort ein:","Okay","Abbrechen");
}
}
else
{
Kick(playerid);
}
return 1;
}
Alles anzeigen
OnPasswordResponse:
public OnPasswordResponse(playerid)
{
new num_fields,num_rows;
cache_get_data(num_rows,num_fields,dbhandle);
if(num_rows==1)
{
new money_string[128];
//Passwort richtig //Spieler laden
SpawnPlayer(playerid);
SetPlayerPos(playerid,ZiviSpawn);
SendClientMessage(playerid,C_Blau,"Erfolgreich eingeloggt.");
sInfo[playerid][eingeloggt] = 1;
sInfo[playerid][level] = cache_get_field_content_int(0,"level",dbhandle);
SetPlayerScore(playerid,sInfo[playerid][level]);
sInfo[playerid][db_id] = cache_get_field_content_int(0,"id",dbhandle);
sInfo[playerid][geld] = cache_get_field_content_int(0,"money",dbhandle);
sInfo[playerid][alevel] = cache_get_field_content_int(0,"alevel",dbhandle);
sInfo[playerid][fraktion] = cache_get_field_content_int(0,"fraktion",dbhandle);
sInfo[playerid][rang] = cache_get_field_content_int(0,"rang",dbhandle);
sInfo[playerid][bank] = cache_get_field_content_int(0,"bank",dbhandle);
//usw.
}
else
{
//Passwort falsch
ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login","Bitte gebe dein Passwort ein:","Okay","Abbrechen");
}
return 1;
}
Alles anzeigen