Guten Abend
Habe folgendes Problem seit 3-4Monaten:
Wenn man sich auf mein Server verbindet und Registriert geht alles wunderbar mit level 1 setzen.
So bald man ausloggt und wieder einloggt hat man einfach kein Level 1mehr.
Bei mir wird auch das alte Geld was man vorher hatte immer wieder gegeben und kein plan warum.
Hier mein Code:
enum playerInfo{
eingeloggt,
level,
db_id,
alevel,
fraktion,
rang,
spawnchange
}
eingeloggt,
level,
db_id,
alevel,
fraktion,
rang,
spawnchange
}
enum frakteEnum{
f_name[300],
Float:f_x,
Float:f_y,
Float:f_z,
Float:f_r,
f_inter,
f_world,
f_color
}
Float:f_x,
Float:f_y,
Float:f_z,
Float:f_r,
f_inter,
f_world,
f_color
}
new sInfo[MAX_PLAYERS][playerInfo];
new fInfo[][frakteEnum] ={
{"Zivilist",329.0244,-1513.3033,36.0391,225.8344,0,0,weiß},//Zivilist 0
{"SAPD",213.4162,162.7460,1003.0234,274.4569,3,1,blau},//SAPD 1
{"SWAT",2731.5903,-2450.0164,17.5937,272.4424,0,0,helblau},//SWAT2
{"FBI",2286.9651,2431.6011,10.8203,176.4887,0,0,duneklhelblau},//FBI3
{"ARMY",214.2768,1822.5925,6.4141,265.0869,0,0,hellgrün},//ARMY4
{"Medic/Feuerwehr",302.9467,-1505.8025,24.6007,231.6743,0,0,rot},//MEDIC5
{"Fahrschule",2124.3032,-2273.0491,20.6719,221.7338,0,0,orange},//Fahrschule6
{"Aztecas",2788.4141,-1944.7075,13.5469,87.2128,0,0,türkis},//AZTECAS7
{"Vagos",204.6566,39.7421,2.5781,260.2514,0,0,gelb},//Vagos8
{"Ballas",1084.8976,-1226.7927,15.8203,269.7700,0,0,pink},//Ballas9
{"Yakuza",-2188.6282,-2265.0452,30.6250,71.4091,0,0,grau}//Yakuza10
};
new fInfo[][frakteEnum] ={
{"Zivilist",329.0244,-1513.3033,36.0391,225.8344,0,0,weiß},//Zivilist 0
{"SAPD",213.4162,162.7460,1003.0234,274.4569,3,1,blau},//SAPD 1
{"SWAT",2731.5903,-2450.0164,17.5937,272.4424,0,0,helblau},//SWAT2
{"FBI",2286.9651,2431.6011,10.8203,176.4887,0,0,duneklhelblau},//FBI3
{"ARMY",214.2768,1822.5925,6.4141,265.0869,0,0,hellgrün},//ARMY4
{"Medic/Feuerwehr",302.9467,-1505.8025,24.6007,231.6743,0,0,rot},//MEDIC5
{"Fahrschule",2124.3032,-2273.0491,20.6719,221.7338,0,0,orange},//Fahrschule6
{"Aztecas",2788.4141,-1944.7075,13.5469,87.2128,0,0,türkis},//AZTECAS7
{"Vagos",204.6566,39.7421,2.5781,260.2514,0,0,gelb},//Vagos8
{"Ballas",1084.8976,-1226.7927,15.8203,269.7700,0,0,pink},//Ballas9
{"Yakuza",-2188.6282,-2265.0452,30.6250,71.4091,0,0,grau}//Yakuza10
};
Das waren erst mal die enums die wichtig sind für den Account:
Weiter gehts:
OnUserCheck:
new num_rows,num_fields;
cache_get_data(num_rows,num_fields,dbhandle);
if(num_rows==0)
{
//Register
ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Account Erstellung","Gebe bitte nun dein gewünschtes Passwort ein!","Registrieren","Abbrechen");
}
else
{
//Login
ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Anmelden","Gebe bitte dein Passwort ein.","Anmleden","Abbrechen");
}
cache_get_data(num_rows,num_fields,dbhandle);
if(num_rows==0)
{
//Register
ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Account Erstellung","Gebe bitte nun dein gewünschtes Passwort ein!","Registrieren","Abbrechen");
}
else
{
//Login
ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Anmelden","Gebe bitte dein Passwort ein.","Anmleden","Abbrechen");
}
OnPlayerConnect:
//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);
SendClientMessage(playerid,grün,"Willkommen auf Reallife Version 0.1.4! Wir wünschen euch ein angenehmen Spiel spaß bei uns!");
//textdraws anzeigen:
TextDrawShowForPlayer(playerid,Text:uhrzeitLabel);
TextDrawShowForAll(Jahr);
SetPlayerColor(playerid,weiß);
sInfo[playerid][level]=1;
SetPlayerScore(playerid,sInfo[playerid][level]);
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);
SendClientMessage(playerid,grün,"Willkommen auf Reallife Version 0.1.4! Wir wünschen euch ein angenehmen Spiel spaß bei uns!");
//textdraws anzeigen:
TextDrawShowForPlayer(playerid,Text:uhrzeitLabel);
TextDrawShowForAll(Jahr);
SetPlayerColor(playerid,weiß);
sInfo[playerid][level]=1;
SetPlayerScore(playerid,sInfo[playerid][level]);
Speichern und Laden:
savePlayer(playerid)
{
if(sInfo[playerid][eingeloggt]==0)return 1;
//Speichern level,money
new query[256];
format(query,sizeof(query),"UPDATE user SET level='%i',money='%i',alevel='%i',fraktion='%i',rang='%i',spawnchange='%i' WHERE id='%i'",sInfo[playerid][level],GetPlayerMoney(playerid),sInfo[playerid][alevel],sInfo[playerid][fraktion],sInfo[playerid][rang],sInfo[playerid][spawnchange],sInfo[playerid][db_id]);
mysql_function_query(dbhandle,query,false,"","");
return 1;
}
resetPlayer(playerid)
{
for(new i=0; i<sizeof(sInfo[]); i++)
{
sInfo[playerid][playerInfo:i]=0;
}
return 1;
}
{
if(sInfo[playerid][eingeloggt]==0)return 1;
//Speichern level,money
new query[256];
format(query,sizeof(query),"UPDATE user SET level='%i',money='%i',alevel='%i',fraktion='%i',rang='%i',spawnchange='%i' WHERE id='%i'",sInfo[playerid][level],GetPlayerMoney(playerid),sInfo[playerid][alevel],sInfo[playerid][fraktion],sInfo[playerid][rang],sInfo[playerid][spawnchange],sInfo[playerid][db_id]);
mysql_function_query(dbhandle,query,false,"","");
return 1;
}
resetPlayer(playerid)
{
for(new i=0; i<sizeof(sInfo[]); i++)
{
sInfo[playerid][playerInfo:i]=0;
}
return 1;
}
OnPlayerDisconnect:
for(new i=0; i<sizeof(aInfo); i++)
{
if(aInfo[i][id_x]==0)continue;
if(aInfo[i][besitzer]!=sInfo[playerid][db_id])continue;
GetVehiclePos(aInfo[i][id_x],aInfo[i][c_x],aInfo[i][c_y],aInfo[i][c_z]);
GetVehicleZAngle(aInfo[i][id_x],aInfo[i][c_r]);
new query[156];
format(query,sizeof(query),"UPDATE user SET level='%i',money='%i',alevel='%i',fraktion='%i',rang='%i' WHERE id='%i'",sInfo[playerid][level],
GetPlayerMoney(playerid),sInfo[playerid][alevel],sInfo[playerid][fraktion],sInfo[playerid][rang],sInfo,sInfo[playerid][db_id]);
mysql_function_query(dbhandle,query,false,"","");
DestroyVehicle(aInfo[i][id_x]);
aInfo[i][id_x]=0;
break;
}
savePlayer(playerid);
resetPlayer(playerid);
loadPlayerCars(playerid);
return 1;
{
if(aInfo[i][id_x]==0)continue;
if(aInfo[i][besitzer]!=sInfo[playerid][db_id])continue;
GetVehiclePos(aInfo[i][id_x],aInfo[i][c_x],aInfo[i][c_y],aInfo[i][c_z]);
GetVehicleZAngle(aInfo[i][id_x],aInfo[i][c_r]);
new query[156];
format(query,sizeof(query),"UPDATE user SET level='%i',money='%i',alevel='%i',fraktion='%i',rang='%i' WHERE id='%i'",sInfo[playerid][level],
GetPlayerMoney(playerid),sInfo[playerid][alevel],sInfo[playerid][fraktion],sInfo[playerid][rang],sInfo,sInfo[playerid][db_id]);
mysql_function_query(dbhandle,query,false,"","");
DestroyVehicle(aInfo[i][id_x]);
aInfo[i][id_x]=0;
break;
}
savePlayer(playerid);
resetPlayer(playerid);
loadPlayerCars(playerid);
return 1;
getPlayerName(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
return name;
}
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
return name;
}
OnPasswordResponse:
public OnPasswordResponse(playerid)
{
new num_rows,num_fields;
cache_get_data(num_rows,num_fields,dbhandle);
if(num_rows==1)
{
//passwort Richtig
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);
SetPlayerMoney(playerid,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][spawnchange] = cache_get_field_content_int(0,"spawnchange",dbhandle);
SetPlayerScore(playerid,sInfo[playerid][level]);
loadPlayerCars(playerid);
{
new num_rows,num_fields;
cache_get_data(num_rows,num_fields,dbhandle);
if(num_rows==1)
{
//passwort Richtig
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);
SetPlayerMoney(playerid,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][spawnchange] = cache_get_field_content_int(0,"spawnchange",dbhandle);
SetPlayerScore(playerid,sInfo[playerid][level]);
loadPlayerCars(playerid);
}
else
{
//Passwort Falsch
SendClientMessage(playerid,grün,"Du hast dein Passwort falsch eingetippt. Versuche es nochmal!");
ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login","Gibt bitte dein Passwort ein:","Anmelden","Abbrechen");
}
return 1;
}
else
{
//Passwort Falsch
SendClientMessage(playerid,grün,"Du hast dein Passwort falsch eingetippt. Versuche es nochmal!");
ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login","Gibt bitte dein Passwort ein:","Anmelden","Abbrechen");
}
return 1;
}
Dialoge: Login/Register:
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 passwort=MD5('%s')",name,passwort);
mysql_function_query(dbhandle,query,true,"OnPasswordResponse","i",playerid);
}
else
{
//Keine Eingabe
SendClientMessage(playerid,grün,"Gibt bitte dein Passwort ein.");
ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login","Gibt bitte dein Passwort ein:","Anmelden","Abbrechen");
}
}
else
{
Kick(playerid);
}
}
if(dialogid==DIALOG_REGISTER)
{
if(response)
{
new name[MAX_PLAYER_NAME],query[128],passwort[35];
GetPlayerName(playerid,name,sizeof(name));
if(strlen(inputtext)>5)
{
//Registrierungsfunktion
mysql_escape_string(inputtext,passwort,dbhandle);
format(query,sizeof(query),"INSERT INTO user username = '%s', passwort = '%s', level = '1' ",name,passwort);
mysql_function_query(dbhandle,query,false,"","");
sInfo[playerid][level]=1;
SetPlayerScore(playerid,sInfo[playerid][level]);
}
else
{
//Kleiner als 4 Zeichen
SendClientMessage(playerid,helblau,"Dein Passwort muss mindestens 6 Zeichen lang sein.");
ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Account Erstellung","Gebe bitte nun dein gewünschtes Passwort ein!","Erstellen","Abbrechen");
}
}
else
{
Kick(playerid);
}
}
{
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 passwort=MD5('%s')",name,passwort);
mysql_function_query(dbhandle,query,true,"OnPasswordResponse","i",playerid);
}
else
{
//Keine Eingabe
SendClientMessage(playerid,grün,"Gibt bitte dein Passwort ein.");
ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login","Gibt bitte dein Passwort ein:","Anmelden","Abbrechen");
}
}
else
{
Kick(playerid);
}
}
if(dialogid==DIALOG_REGISTER)
{
if(response)
{
new name[MAX_PLAYER_NAME],query[128],passwort[35];
GetPlayerName(playerid,name,sizeof(name));
if(strlen(inputtext)>5)
{
//Registrierungsfunktion
mysql_escape_string(inputtext,passwort,dbhandle);
format(query,sizeof(query),"INSERT INTO user username = '%s', passwort = '%s', level = '1' ",name,passwort);
mysql_function_query(dbhandle,query,false,"","");
sInfo[playerid][level]=1;
SetPlayerScore(playerid,sInfo[playerid][level]);
}
else
{
//Kleiner als 4 Zeichen
SendClientMessage(playerid,helblau,"Dein Passwort muss mindestens 6 Zeichen lang sein.");
ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Account Erstellung","Gebe bitte nun dein gewünschtes Passwort ein!","Erstellen","Abbrechen");
}
}
else
{
Kick(playerid);
}
}
Stock:
stock SpielerName(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,MAX_PLAYER_NAME);
return name;
}
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,MAX_PLAYER_NAME);
return name;
}
Ich habe es in Expander gepackt damit es nicht zu viel wird.