Guten Abend.
Ich habe denn fehler zwar gefunden weswegen ein fehler kam und nun kommt keine mysql.log und bekomme die werte immer noch nicht gespeichert. Sobald ich mich registriere ist alles normal. Sobald ich auslogge und wieder einlogge dann steht bei Score-Level 0 und mein Geld ist auch bei 0 und es wird nicht abgespeichert so wie es eigentlich sollte. Ich weiss auch nicht wo ich den fehler gesetzt habe
Ich habe es genau so wie:
MrMonatHD
Aber es geht einfach nicht.
Hier der Code
PS: die X sind nur wegen abdecken der passwörter und so
//Includes
#include <a_samp>
#include <ocmd.inc>
#include <sscanf2.inc>
#include <a_mysql>
//definere mysql
#define db_host "178.254.29.25"
#define db_user "xxxx"
#define db_pass "xxxxx"
#define db_db "xxxx"
//definierte Farben
#define rot 0xFF3200FF
#define grün 0x05FF00FF
#define blau 0x0000FFFF
#define grau 0x505050FF
#define helbau 0x7DB3C3FF
#define helgruen 0xABD94EFF
#define Adminproduktion 1
//Adminlevels
//undef
#undef MAX_PLAYERS
#define MAX_PLAYER 15
//Globale Variablen
new dbhandle;
//Forwards
forward OnUserCheck(playerid);
forward OnPasswordResponse(playerid);
forward Admincarproduktion(playerid,c_x,c_y,c_z,vID);
enum
{
DIALOG_REGISTER,
DIALOG_LOGIN,
};
//enum einstellen:
enum pEnum
{
NAME[MAX_PLAYER_NAME],
level,
eingeloggt,
geld,
Adminlevel,
id
};
new sInfo[MAX_PLAYER][pEnum];
main()
{
print("\n----------------------------------");
print(" Learn");
print("----------------------------------\n");
}
public OnGameModeInit()
{
SendRconCommand("mapname <lernen>");
SetGameModeText("Learn");
AddPlayerClass(0,796.7672,-1338.4739,-0.5078,225.4672,0,0,0,0,0,0); // spawn
print("Server wurde gestartet");
//-------MYSQL-CONNECT------
//MYSQL //HostIP der DB,Username.DBname,passwort
dbhandle = mysql_connect(db_host,db_user,db_db,db_pass);
print("MYSQL verbindung aufgebaut!");
return 1;
}
public OnGameModeExit()
{
print("Der Server wurde beendet");
//MYSQL Verbindung trennen!
mysql_close(dbhandle);
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
SetPlayerPos(playerid, 796.7672,-1338.4739,-0.5078);
SetPlayerCameraPos(playerid, 796.7672,-1338.4739,-0.5078);
SetPlayerCameraLookAt(playerid, 796.7672,-1338.4739,-0.5078);
return 1;
}
public OnPlayerConnect(playerid)
{
SendClientMessage(playerid,0x0000FFFF,"Willkommen auf BETA");
new name[MAX_PLAYER_NAME],query[256];
GetPlayerName(playerid,name,sizeof(name));
format(query,sizeof(query),"SELECT id FROM user WHERE username='%s'",name);
mysql_function_query(dbhandle,query,true,"OnUserCheck","d",playerid);
return 1;
}
public OnUserCheck(playerid)
{
new num_rows,num_fields;
cache_get_data(num_rows,num_fields,dbhandle);
if(num_rows==0)
{
ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Registrierung","Bitte registrieren sie sich um auf dem Server zu spielen.","Registrieren","Abrechen");
}
else
{
new name[MAX_PLAYER_NAME],string[128],stringend[128];
GetPlayerName(playerid,name,sizeof(name));
format(string,sizeof(string),"{FFFFFF}Der Accountname {37CD00}%s {FFFFFF}wurde gefunden.\nUm mit den Spielen zu beginnen, musst du dich einloggen.\nDu hast die ID: {37CD00}%i\n",name,playerid);
strcat(stringend,string);
format(string,sizeof(string),"{FFFFFF}Bitte gebe unten dein Passwort ein.");
strcat(stringend,string);
ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"{37CD00}Login System: {FFFFFF}Einloggen",stringend,"Login","Abbruch");
strdel(stringend,0,sizeof(stringend));
strdel(string,0,sizeof(string));
}
return 1;
}
savePlayer(playerid)
{
if(sInfo[playerid][eingeloggt]==0) return 1;
//speichern level,adminlevel,geld,id
new query[256];
format(query,sizeof(query),"UPDATE user SET Adminlevel='%i' ,money='%i' ,level='%i',id='%i' WHERE id='%i'",sInfo[playerid][Adminlevel],GetPlayerMoney(playerid),sInfo[playerid][level],sInfo[playerid][id]);
return 1;
}
restPlayer(playerid)
{
sInfo[playerid][id]=0;
sInfo[playerid][Adminlevel]=0;
sInfo[playerid][eingeloggt]=0;
sInfo[playerid][level]=0;
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
savePlayer(playerid);
restPlayer(playerid);
return 1;
}
public OnPlayerSpawn(playerid)
{
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
return 1;
}
public OnVehicleSpawn(vehicleid)
{
return 1;
}
public OnVehicleDeath(vehicleid, killerid)
{
return 1;
}
public OnPlayerText(playerid, text[])
{
return 1;
}
//--------OCMD Befehle-----/
ocmd:hilfe(playerid,parms[])
{
SendClientMessage(playerid, 0xFF00FF00, "es gibt folgendes:\n /Hilfe");
SendClientMessage(playerid,0xFF00FF00, "/stats");
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
return 1;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
return 1;
}
public OnPlayerEnterCheckpoint(playerid)
{
return 1;
}
public OnPlayerLeaveCheckpoint(playerid)
{
return 1;
}
public OnPlayerEnterRaceCheckpoint(playerid)
{
return 1;
}
public OnPlayerLeaveRaceCheckpoint(playerid)
{
return 1;
}
public OnRconCommand(cmd[])
{
}
public OnPlayerRequestSpawn(playerid)
{
return 1;
}
public OnObjectMoved(objectid)
{
return 1;
}
public OnPlayerObjectMoved(playerid, objectid)
{
return 1;
}
public OnPlayerPickUpPickup(playerid, pickupid)
{
return 1;
}
public OnVehicleMod(playerid, vehicleid, componentid)
{
return 1;
}
public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
return 1;
}
public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
return 1;
}
public OnPlayerSelectedMenuRow(playerid, row)
{
return 1;
}
public OnPlayerExitedMenu(playerid)
{
return 1;
}
public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
return 1;
}
public OnRconLoginAttempt(ip[], password[], success)
{
return 1;
}
public OnPlayerUpdate(playerid)
{
return 1;
}
public OnPlayerStreamIn(playerid, forplayerid)
{
return 1;
}
public OnPlayerStreamOut(playerid, forplayerid)
{
return 1;
}
public OnVehicleStreamIn(vehicleid, forplayerid)
{
return 1;
}
public OnVehicleStreamOut(vehicleid, forplayerid)
{
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
//Login Register System
if(dialogid == DIALOG_REGISTER)
{
{
if(!response){
ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Registrierung","Registrierung war nicht erfolgreich\nBitte registrieren sie sich um auf dem Server zu spielen.","Absenden","Abbrechen");
return 1;
}
{
//eingegebenes Passwort
new name[MAX_PLAYER_NAME],passwort[35],query[256];
GetPlayerName(playerid,name,sizeof(name));
if(strlen(inputtext)>3)
{
//registrierungsfunktion
SetPlayerScore(playerid,1);
sInfo[playerid][level] = 1;
GivePlayerMoney(playerid,15000);
sInfo[playerid][geld] = 15000;
sInfo[playerid][eingeloggt] = 1;
//
mysql_escape_string(inputtext,passwort,dbhandle);
format(query,sizeof(query),"INSERT INTO user (username,passwort) VALUES ('%s','%s')",name,inputtext);
printf(query);
mysql_function_query(dbhandle,query,false,"","");
return 1;
}
else
{
return 1;
}
}
}
}
if(dialogid == DIALOG_LOGIN)
{
if(!response)
{
new name[MAX_PLAYER_NAME],string[128],stringend[128];
GetPlayerName(playerid,name,sizeof(name));
format(string,sizeof(string),"{FFFFFF}Der Accountname {37CD00}%s {FFFFFF}wurde gefunden.\nUm mit den Spielen zu beginnen, musst du dich einloggen.\nDu hast die ID: {37CD00}%i\n",name,playerid);
strcat(stringend,string);
format(string,sizeof(string),"{FFFFFF}Bitte gebe unten dein Passwort ein.");
strcat(stringend,string);
ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"{37CD00}Login System: {FFFFFF}Einloggen",stringend,"Login","Abbruch");
strdel(stringend,0,sizeof(stringend));
strdel(string,0,sizeof(string));
return 1;
}
{
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='%s'",name,passwort);
mysql_function_query(dbhandle,query,true,"OnPasswordResponse","i",playerid);
}
return 1;
}
}
return 1;
}
SetPlayerMoney(playerid,money)
{
ResetPlayerMoney(playerid);
GivePlayerMoney(playerid,money);
return 1;
}
public OnPasswordResponse(playerid)
{
new num_fields,num_rows;
cache_get_data(num_rows,num_fields,dbhandle);
if(num_rows==1) //Passwort richtig
{
sInfo[playerid][eingeloggt] = 1;
SendClientMessage(playerid,helbau,"Du hast dich erfolgreich eingeloggt!");
sInfo[playerid][level] = cache_get_field_content_int(0,"level",dbhandle);
SetPlayerScore(playerid,sInfo[playerid][level]);
sInfo[playerid][Adminlevel] = cache_get_field_content_int(0,"adminlevel",dbhandle);
SetPlayerMoney(playerid,cache_get_field_content_int(0,"money",dbhandle));
sInfo[playerid] [id] = cache_get_field_content_int(0,"id",dbhandle);
}
else //Passwort falsch
{
}
return 1;
}
ocmd:Setzeadminlevel(playerid,params[])
{
new pID,a_level,string[128];
new name[MAX_PLAYER_NAME],PName[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
GetPlayerName(playerid,PName,sizeof(PName));
//seteadminlevel [PartnerID|PartnerName] [Das gewünschte Adminlevel]
if(sscanf(params,"ui",pID,a_level)) return SendClientMessage(playerid,rot,"Diese Funktion ist nur für Administratoren ab Level X möglich!");
sInfo[pID][Adminlevel] = a_level;
format(string,sizeof(string),"Der %s %s hat sie auf den Rang %i befördert!",GetPlayerAdminName(playerid),name,a_level);
SendClientMessage(pID,blau,string);
format(string,sizeof(string),"Du hast den Rang von %s ID %i auf %i geändert",PName,pID,a_level);
return 1;
}
stock GetPlayerAdminName(playerid)
{
new aName[]="Beschwerdenmoderatorleiter";
switch(sInfo[playerid][Adminlevel])
{
case 0: aName="User";
case 1: aName="Supporter";
case 2: aName="Super Supporter";
case 3: aName="Moderator";
case 4: aName="Supermoderator";
case 5: aName="Moderratorenleiter";
case 6: aName="Probe Administator";
case 7: aName="Administator";
case 8: aName="Administatorleiter";
case 9: aName="Scripter";
case 10:aName="Mapper";
case 11:aName="Beschwerdenmoderator";
case 12:aName="Beschwerdenmoderatorleiter";
case 13:aName="Zweiter Projektleiter";
case 14:aName="Projektleiter";
default: aName="ERROR";
}
return aName;
}