Hallo Leute,
habe aktuell ein Problem beim auslesen und speichern der Userdaten in den PVars. Das Problem ist, dass die Daten nach dem Query komischerweise total ungeordnet sind?! Aber am besten zeig ich euch das an meinem Beispiel.
Datenbankansicht:
OnDialogResponse:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid)
{
case 1: // Login
{
new name[32], Query[256];
mysql_real_escape_string(inputtext, inputtext);
GetPVarString(playerid, "Name", name, 32);
format(Query, sizeof(Query), "SELECT * FROM `users` WHERE `name` = '%s' AND `password` = md5('%s');", name, inputtext);
mysql_function_query(dbHandle, Query, true, "OnPlayerLogin", "i", playerid);
}
}
return 1;
}
Public OnPlayerLogin:
public OnPlayerLogin(playerid)
{
new rows, fields, name[32];
GetPVarString(playerid, "Name", name, 32);
cache_get_data(rows, fields);
if(!rows)
{
new info[256];
format(info, 256, "{FFFFFF}Willkommen zurück {FF7700}%s{FFFFFF}!\nBitte gib dein Passwort ein!", name);
return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Log-In", info, "Login", "Abbrechen");
}
else
{
new temp[32];
cache_get_row(0, 0, temp), SetPVarInt(playerid, "id", strval(temp));
cache_get_row(0, 3, temp), SetPVarInt(playerid, "Adminlevel", strval(temp));
cache_get_row(0, 4, temp), SetPVarInt(playerid, "Level", strval(temp));
cache_get_row(0, 5, temp), SetPVarInt(playerid, "Levelpoints", strval(temp));
cache_get_row(0, 6, temp), SetPVarInt(playerid, "Money", strval(temp));
cache_get_row(0, 7, temp), SetPVarInt(playerid, "Fraktion", strval(temp));
cache_get_row(0, 8, temp), SetPVarInt(playerid, "FRank", strval(temp));
cache_get_row(0, 9, temp), SetPVarInt(playerid, "Leader", strval(temp));
cache_get_row(0, 10, temp), SetPVarInt(playerid, "Skin", strval(temp));
cache_get_row(0, 11, temp), SetPVarInt(playerid, "DSkin", strval(temp));
SetPVarInt(playerid, "logged_in", 1);
printf("ID: %i; ALevel: %i; Level: %i; LevelP: %i; Money: %i; Fraktion: %i; FRank: %i; Leader: %i; Skin: %i; DSkin: %i",
GetPVarInt(playerid, "Adminlevel"), GetPVarInt(playerid, "ALevel"), GetPVarInt(playerid, "Levelpoints"), GetPVarInt(playerid, "Money"), GetPVarInt(playerid, "Fraktion"),
GetPVarInt(playerid, "FRank"), GetPVarInt(playerid, "Leader"), GetPVarInt(playerid, "Skin"), GetPVarInt(playerid, "DSkin"));
}
return 1;
}
Das printen gibt dann folgendes aus:
ID: 1337; ALevel: 0; Level: 12; LevelP: 5000; Money: 2; Fraktion: 10; FRank: 1; Leader: 50; Skin: 136; DSkin:
Kann mir irgendwer meinen Fehler erklären?