Hey,
Also ich hab ein Problem, das wenn man sich das erstemal Registriert das z.b Level unso i.wie nicht gespeichert wird. Oder da steht man ist nicht eingeloggt wenn man ein Befehl eingibt!
Ich habe das Mysql System von MrMonat!
Plugin R34
public OnPasswordResponse(playerid)
{
new num_fields,num_rows;
cache_get_data(num_rows,num_fields,dbhandle);
if(num_rows==1)
{
//Passwort richtig
sInfo[playerid][pEingeloggt] = 1;
sInfo[playerid][pLevel] = cache_get_field_content_int(0,"level",dbhandle);
sInfo[playerid][pAdmin] = cache_get_field_content_int(0,"adminlevel",dbhandle);
sInfo[playerid][pKills] = cache_get_field_content_int(0,"kills",dbhandle);
sInfo[playerid][pTod] = cache_get_field_content_int(0,"tode",dbhandle);
SetPlayerScore(playerid,sInfo[playerid][pLevel]);
sInfo[playerid][PlayerID] = cache_get_field_content_int(0,"id",dbhandle);
GivePlayerMoney(playerid,cache_get_field_content_int(0,"money",dbhandle));
}
else
{
//Passwort falsch
SendClientMessage(playerid,ROT,"Das eingegebene Passwort ist falsch.");
ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login","Gibt bitte dein Passwort ein:","Okay","Abbrechen");
}
return 1;
}
public OnPlayerConnect(playerid)
{
//Login/Register
new name[MAX_PLAYER_NAME],query[128];
GetPlayerName(playerid,name,sizeof(name));
format(query,sizeof(query),"SELECT id FROM user WHERE username='%s'",name);
mysql_function_query(dbhandle,query,true,"OnUserCheck","i",playerid);
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid)
{
case 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='%s'",name,passwort);
mysql_function_query(dbhandle,query,true,"OnPasswordResponse","i",playerid);
}else{
//Keine Eingabe
SendClientMessage(playerid,ROT,"Gibt bitte dein Passwort ein.");
ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login","Gibt bitte dein Passwort ein:","Okay","Abbrechen");
}
}else{
Kick(playerid);
}
}
case DIALOG_REGISTER:
{
if(response)
{
new name[MAX_PLAYER_NAME],query[128],passwort[35];
GetPlayerName(playerid,name,sizeof(name));
if(strlen(inputtext)>3)
{
//Registrierungsfunktion
mysql_escape_string(inputtext,passwort,dbhandle);
format(query,sizeof(query),"INSERT INTO user (username,password) VALUES ('%s','%s') ",name,passwort);
mysql_function_query(dbhandle,query,false,"","");
}else{
SendClientMessage(playerid,ROT,"Dein Passwort muss mindestens 4 Zeichen lang sein.");
ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Registrierung","Gib bitte dein gewünschtes Passwort an:","Okay","Abbrechen");
}
}else{
Kick(playerid);
}
}
}
return 1;
}
stock savePlayer(playerid)
{
if(sInfo[playerid][pEingeloggt]==0)return 1;
//Speichern level,money
new query[256];
format(query,sizeof(query),"UPDATE user SET level='%i',money='%i',kills = '%d',tode = '%d',adminlevel='%i' WHERE id='%i'",sInfo[playerid][pLevel],GetPlayerMoney(playerid),sInfo[playerid][pKills],sInfo[playerid][pTod],sInfo[playerid][pAdmin],sInfo[playerid][PlayerID]);
mysql_function_query(dbhandle,query,false,"","");
return 1;
}