danke MiX(eP)
Beiträge von Killerorcmapps
-
-
Guten Abend
Bei mein Adminsystem bekomm ich warningcodes:
PWN-Code:
}isAdmin(playerid,a_level)
{
if(sInfo[playerid] [a_level]>=Adminlevel)return 1;
return 0;
}ocmd:restart(playerid,params[])
{
if(!isAdmin(playerid,8)) return SendClientMessage(playerid,helbau,"Du hast nicht die passende Rechte dafür!");
SendRconCommand("gmx");
return 1;
}Fehler Codes:
Bitte um hilfe
-
Vielen dank soweit geht es nun
-
es geht immer noch nicht
SQL
Alles anzeigen[21:11:10] [DEBUG] mysql_connect - host: "localhost", user: "root", database: "samp", password: "****", port: 3306, autoreconnect: true, pool_size: 2 [21:11:10] [DEBUG] CMySQLHandle::Create - creating new connection.. [21:11:10] [DEBUG] CMySQLHandle::CMySQLHandle - constructor called [21:11:10] [DEBUG] CMySQLHandle::Create - connection created (id: 1) [21:11:10] [DEBUG] CMySQLConnection::Connect - establishing connection to database... [21:11:10] [DEBUG] CMySQLConnection::Connect - connection was successful [21:11:10] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled [21:11:10] [DEBUG] CMySQLConnection::Connect - establishing connection to database... [21:11:10] [DEBUG] CMySQLConnection::Connect - establishing connection to database... [21:11:10] [DEBUG] CMySQLConnection::Connect - establishing connection to database... [21:11:10] [DEBUG] CMySQLConnection::Connect - connection was successful [21:11:10] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled [21:11:10] [DEBUG] CMySQLConnection::Connect - connection was successful [21:11:10] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled [21:11:10] [DEBUG] CMySQLConnection::Connect - connection was successful [21:11:10] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled [21:11:31] [DEBUG] mysql_tquery - connection: 1, query: "SELECT id FROM user WHERE username='Test1234'", callback: "OnUserCheck", format: "d" [21:11:31] [DEBUG] CMySQLQuery::Execute[OnUserCheck] - starting query execution [21:11:31] [DEBUG] CMySQLQuery::Execute[OnUserCheck] - query was successfully executed within 0.396 milliseconds [21:11:31] [DEBUG] CMySQLResult::CMySQLResult() - constructor called [21:11:31] [DEBUG] Calling callback "OnUserCheck".. [21:11:31] [DEBUG] cache_get_data - connection: 1 [21:11:31] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called [21:11:37] [DEBUG] mysql_escape_string - source: "test1234", connection: 1, max_len: 35 [21:11:37] [DEBUG] mysql_tquery - connection: 1, query: "SELECT * FROM user WHERE username='Test1234' AND passwort='test1", callback: "OnPasswordResponse", format: "i" [21:11:37] [DEBUG] CMySQLQuery::Execute[OnPasswordResponse] - starting query execution [21:11:37] [DEBUG] CMySQLQuery::Execute[OnPasswordResponse] - query was successfully executed within 0.368 milliseconds [21:11:37] [DEBUG] CMySQLResult::CMySQLResult() - constructor called [21:11:37] [DEBUG] Calling callback "OnPasswordResponse".. [21:11:37] [DEBUG] cache_get_data - connection: 1 [21:11:37] [DEBUG] cache_get_field_content_int - row: 0, field_name: "level", connection: 1 [21:11:37] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "level", data: "0" [21:11:37] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Adminlevel", connection: 1 [21:11:37] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "Adminlevel", data: "0" [21:11:37] [DEBUG] cache_get_field_content_int - row: 0, field_name: "money", connection: 1 [21:11:37] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "money", data: "0" [21:11:37] [DEBUG] cache_get_field_content_int - row: 0, field_name: "id", connection: 1 [21:11:37] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "id", data: "10" [21:11:37] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called [21:11:41] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE user SET Adminlevel='0' ,money='0' ,level='0',id='10' WHE", callback: "(null)", format: "(null)" [21:11:41] [DEBUG] CMySQLQuery::Execute[] - starting query execution [21:11:41] [DEBUG] CMySQLQuery::Execute[] - query was successfully executed within 0.329 milliseconds [21:11:41] [DEBUG] CMySQLQuery::Execute[] - no callback specified, skipping result saving [21:12:12] [DEBUG] mysql_tquery - connection: 1, query: "SELECT id FROM user WHERE username='hallo123'", callback: "OnUserCheck", format: "d" [21:12:12] [DEBUG] CMySQLQuery::Execute[OnUserCheck] - starting query execution [21:12:12] [DEBUG] CMySQLQuery::Execute[OnUserCheck] - query was successfully executed within 0.371 milliseconds [21:12:12] [DEBUG] CMySQLResult::CMySQLResult() - constructor called [21:12:12] [DEBUG] Calling callback "OnUserCheck".. [21:12:12] [DEBUG] cache_get_data - connection: 1 [21:12:12] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called [21:12:16] [DEBUG] mysql_escape_string - source: "test123", connection: 1, max_len: 35 [21:12:16] [DEBUG] mysql_tquery - connection: 1, query: "INSERT INTO user (username,passwort) VALUES ('hallo123','test123", callback: "OnPlayerRegister", format: "d" [21:12:16] [DEBUG] CMySQLQuery::Execute[OnPlayerRegister] - starting query execution [21:12:16] [DEBUG] CMySQLQuery::Execute[OnPlayerRegister] - query was successfully executed within 66.482 milliseconds [21:12:16] [DEBUG] CMySQLResult::CMySQLResult() - constructor called [21:12:16] [DEBUG] Calling callback "OnPlayerRegister".. [21:12:16] [DEBUG] cache_insert_id - connection: 1 [21:12:16] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE user SET Adminlevel='0' ,money='15000' ,level='1',id='11'", callback: "(null)", format: "(null)" [21:12:16] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called [21:12:16] [DEBUG] CMySQLQuery::Execute[] - starting query execution [21:12:16] [DEBUG] CMySQLQuery::Execute[] - query was successfully executed within 0.322 milliseconds [21:12:16] [DEBUG] CMySQLQuery::Execute[] - no callback specified, skipping result saving [21:12:20] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE user SET Adminlevel='0' ,money='15000' ,level='1',id='11'", callback: "(null)", format: "(null)" [21:12:20] [DEBUG] CMySQLQuery::Execute[] - starting query execution [21:12:20] [DEBUG] CMySQLQuery::Execute[] - query was successfully executed within 0.324 milliseconds [21:12:20] [DEBUG] CMySQLQuery::Execute[] - no callback specified, skipping result saving [21:12:48] [DEBUG] mysql_tquery - connection: 1, query: "SELECT id FROM user WHERE username='hallo123'", callback: "OnUserCheck", format: "d" [21:12:48] [DEBUG] CMySQLQuery::Execute[OnUserCheck] - starting query execution [21:12:48] [DEBUG] CMySQLQuery::Execute[OnUserCheck] - query was successfully executed within 0.357 milliseconds [21:12:48] [DEBUG] CMySQLResult::CMySQLResult() - constructor called [21:12:48] [DEBUG] Calling callback "OnUserCheck".. [21:12:48] [DEBUG] cache_get_data - connection: 1 [21:12:48] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called [21:12:52] [DEBUG] mysql_escape_string - source: "test123", connection: 1, max_len: 35 [21:12:52] [DEBUG] mysql_tquery - connection: 1, query: "SELECT * FROM user WHERE username='hallo123' AND passwort='test1", callback: "OnPasswordResponse", format: "i" [21:12:52] [DEBUG] CMySQLQuery::Execute[OnPasswordResponse] - starting query execution [21:12:52] [DEBUG] CMySQLQuery::Execute[OnPasswordResponse] - query was successfully executed within 0.418 milliseconds [21:12:52] [DEBUG] CMySQLResult::CMySQLResult() - constructor called [21:12:52] [DEBUG] Calling callback "OnPasswordResponse".. [21:12:52] [DEBUG] cache_get_data - connection: 1 [21:12:52] [DEBUG] cache_get_field_content_int - row: 0, field_name: "level", connection: 1 [21:12:52] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "level", data: "0" [21:12:52] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Adminlevel", connection: 1 [21:12:52] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "Adminlevel", data: "0" [21:12:52] [DEBUG] cache_get_field_content_int - row: 0, field_name: "money", connection: 1 [21:12:52] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "money", data: "0" [21:12:52] [DEBUG] cache_get_field_content_int - row: 0, field_name: "id", connection: 1 [21:12:52] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "id", data: "11" [21:12:52] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called [21:13:20] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE user SET Adminlevel='0' ,money='0' ,level='0',id='11' WHE", callback: "(null)", format: "(null)" [21:13:20] [DEBUG] CMySQLQuery::Execute[] - starting query execution [21:13:20] [DEBUG] CMySQLQuery::Execute[] - query was successfully executed within 0.323 milliseconds [21:13:20] [DEBUG] CMySQLQuery::Execute[] - no callback specified, skipping result saving [21:13:22] [DEBUG] mysql_close - connection: 1 [21:13:22] [DEBUG] CMySQLConnection::Disconnect - connection was closed [21:13:22] [DEBUG] CMySQLConnection::Disconnect - connection was closed [21:13:22] [DEBUG] CMySQLConnection::Disconnect - connection was closed [21:13:22] [DEBUG] CMySQLHandle::~CMySQLHandle - deconstructor called
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,"OnPlayerRegister","d",playerid);
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;
}
forward OnPlayerRegister(playerid);
public OnPlayerRegister(playerid)
{
sInfo[playerid][id] = cache_insert_id();
savePlayer(playerid);
return 1;
} -
Hier beweise das es selbst mit neuen account nicht geht.
SQL
Alles anzeigen[20:53:12] [DEBUG] mysql_connect - host: "localhost", user: "root", database: "samp", password: "****", port: 3306, autoreconnect: true, pool_size: 2 [20:53:12] [DEBUG] CMySQLHandle::Create - creating new connection.. [20:53:12] [DEBUG] CMySQLHandle::CMySQLHandle - constructor called [20:53:12] [DEBUG] CMySQLHandle::Create - connection created (id: 1) [20:53:12] [DEBUG] CMySQLConnection::Connect - establishing connection to database... [20:53:12] [DEBUG] CMySQLConnection::Connect - connection was successful [20:53:12] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled [20:53:12] [DEBUG] CMySQLConnection::Connect - establishing connection to database... [20:53:12] [DEBUG] CMySQLConnection::Connect - connection was successful [20:53:12] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled [20:53:12] [DEBUG] CMySQLConnection::Connect - connection was successful [20:53:12] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled [20:53:12] [DEBUG] CMySQLConnection::Connect - connection was successful [20:53:12] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled [20:53:32] [DEBUG] mysql_tquery - connection: 1, query: "SELECT id FROM user WHERE username='Test1234'", callback: "OnUserCheck", format: "d" [20:53:32] [DEBUG] CMySQLQuery::Execute[OnUserCheck] - starting query execution [20:53:32] [DEBUG] CMySQLQuery::Execute[OnUserCheck] - query was successfully executed within 0.418 milliseconds [20:53:32] [DEBUG] CMySQLResult::CMySQLResult() - constructor called [20:53:32] [DEBUG] Calling callback "OnUserCheck".. [20:53:32] [DEBUG] cache_get_data - connection: 1 [20:53:32] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called [20:53:37] [DEBUG] mysql_escape_string - source: "test1234", connection: 1, max_len: 35 [20:53:37] [DEBUG] mysql_tquery - connection: 1, query: "INSERT INTO user (username,passwort) VALUES ('Test1234','test123", callback: "(null)", format: "(null)" [20:53:37] [DEBUG] CMySQLQuery::Execute[] - starting query execution [20:53:37] [DEBUG] CMySQLQuery::Execute[] - query was successfully executed within 28.787 milliseconds [20:53:37] [DEBUG] CMySQLQuery::Execute[] - no callback specified, skipping result saving [20:53:47] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE user SET Adminlevel='0' ,money='15000' ,level='1',id='0' ", callback: "(null)", format: "(null)" [20:53:47] [DEBUG] CMySQLQuery::Execute[] - starting query execution [20:53:47] [DEBUG] CMySQLQuery::Execute[] - query was successfully executed within 0.341 milliseconds [20:53:47] [DEBUG] CMySQLQuery::Execute[] - no callback specified, skipping result saving [20:54:12] [DEBUG] mysql_tquery - connection: 1, query: "SELECT id FROM user WHERE username='Test1234'", callback: "OnUserCheck", format: "d" [20:54:13] [DEBUG] CMySQLQuery::Execute[OnUserCheck] - starting query execution [20:54:13] [DEBUG] CMySQLQuery::Execute[OnUserCheck] - query was successfully executed within 0.378 milliseconds [20:54:13] [DEBUG] CMySQLResult::CMySQLResult() - constructor called [20:54:13] [DEBUG] Calling callback "OnUserCheck".. [20:54:13] [DEBUG] cache_get_data - connection: 1 [20:54:13] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called [20:54:19] [DEBUG] mysql_escape_string - source: "test1234", connection: 1, max_len: 35 [20:54:19] [DEBUG] mysql_tquery - connection: 1, query: "SELECT * FROM user WHERE username='Test1234' AND passwort='test1", callback: "OnPasswordResponse", format: "i" [20:54:19] [DEBUG] CMySQLQuery::Execute[OnPasswordResponse] - starting query execution [20:54:19] [DEBUG] CMySQLQuery::Execute[OnPasswordResponse] - query was successfully executed within 0.350 milliseconds [20:54:19] [DEBUG] CMySQLResult::CMySQLResult() - constructor called [20:54:19] [DEBUG] Calling callback "OnPasswordResponse".. [20:54:19] [DEBUG] cache_get_data - connection: 1 [20:54:19] [DEBUG] cache_get_field_content_int - row: 0, field_name: "level", connection: 1 [20:54:19] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "level", data: "0" [20:54:19] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Adminlevel", connection: 1 [20:54:19] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "Adminlevel", data: "0" [20:54:19] [DEBUG] cache_get_field_content_int - row: 0, field_name: "money", connection: 1 [20:54:19] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "money", data: "0" [20:54:19] [DEBUG] cache_get_field_content_int - row: 0, field_name: "id", connection: 1 [20:54:19] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "id", data: "10" [20:54:19] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called [20:54:26] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE user SET Adminlevel='0' ,money='0' ,level='0',id='10' WHE", callback: "(null)", format: "(null)" [20:54:26] [DEBUG] CMySQLQuery::Execute[] - starting query execution [20:54:26] [DEBUG] CMySQLQuery::Execute[] - query was successfully executed within 0.369 milliseconds [20:54:26] [DEBUG] CMySQLQuery::Execute[] - no callback specified, skipping result saving [20:54:34] [DEBUG] mysql_close - connection: 1 [20:54:34] [DEBUG] CMySQLConnection::Disconnect - connection was closed [20:54:34] [DEBUG] CMySQLConnection::Disconnect - connection was closed [20:54:34] [DEBUG] CMySQLHandle::~CMySQLHandle - deconstructor called
-
habe ich ja
-
Ich habe das so wie du gemacht aber jetzt kommt folgendes in der Mysql.log datei:
Code
Alles anzeigen[19:38:46] [DEBUG] mysql_connect - host: "localhost", user: "root", database: "samp", password: "****", port: 3306, autoreconnect: true, pool_size: 2 [19:38:46] [DEBUG] CMySQLHandle::Create - creating new connection.. [19:38:46] [DEBUG] CMySQLHandle::CMySQLHandle - constructor called [19:38:46] [DEBUG] CMySQLHandle::Create - connection created (id: 1) [19:38:46] [DEBUG] CMySQLConnection::Connect - establishing connection to database... [19:38:46] [DEBUG] CMySQLConnection::Connect - connection was successful [19:38:46] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled [19:38:46] [DEBUG] CMySQLConnection::Connect - establishing connection to database... [19:38:46] [DEBUG] CMySQLConnection::Connect - establishing connection to database... [19:38:46] [DEBUG] CMySQLConnection::Connect - establishing connection to database... [19:38:46] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled [19:38:46] [DEBUG] CMySQLConnection::Connect - connection was successful [19:38:46] [DEBUG] CMySQLConnection::Connect - connection was successful [19:38:46] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled [19:38:46] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled [19:39:07] [DEBUG] mysql_tquery - connection: 1, query: "SELECT id FROM user WHERE username='Killerorc'", callback: "OnUserCheck", format: "d" [19:39:07] [DEBUG] CMySQLQuery::Execute[OnUserCheck] - starting query execution [19:39:07] [DEBUG] CMySQLQuery::Execute[OnUserCheck] - query was successfully executed within 0.379 milliseconds [19:39:07] [DEBUG] CMySQLResult::CMySQLResult() - constructor called [19:39:07] [DEBUG] Calling callback "OnUserCheck".. [19:39:07] [DEBUG] cache_get_data - connection: 1 [19:39:07] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called [19:39:11] [DEBUG] mysql_escape_string - source: "test1234", connection: 1, max_len: 35 [19:39:11] [DEBUG] mysql_tquery - connection: 1, query: "SELECT * FROM user WHERE username='Killerorc' AND passwort='test", callback: "OnPasswordResponse", format: "i" [19:39:11] [DEBUG] CMySQLQuery::Execute[OnPasswordResponse] - starting query execution [19:39:11] [DEBUG] CMySQLQuery::Execute[OnPasswordResponse] - query was successfully executed within 0.343 milliseconds [19:39:11] [DEBUG] CMySQLResult::CMySQLResult() - constructor called [19:39:11] [DEBUG] Calling callback "OnPasswordResponse".. [19:39:11] [DEBUG] cache_get_data - connection: 1 [19:39:11] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called [19:39:22] [DEBUG] mysql_close - connection: 1 [19:39:22] [DEBUG] CMySQLConnection::Disconnect - connection was closed [19:39:22] [DEBUG] CMySQLConnection::Disconnect - connection was closed [19:39:22] [DEBUG] CMySQLHandle::~CMySQLHandle - deconstructor called
-
fehler meldung:
Codelernen.p(378) : warning 225: unreachable code lernen.p(378) : warning 217: loose indentation lernen.p(387) : error 017: undefined symbol "passwort" lernen.p(388) : error 017: undefined symbol "query" lernen.p(388) : error 017: undefined symbol "query" lernen.p(388) : error 029: invalid expression, assumed zero lernen.p(388) : fatal error 107: too many error messages on one line
-
ich habe es jetzt so gemacht
//Includes
#include <a_samp>
#include <ocmd.inc>
#include <sscanf2.inc>
#include <a_mysql>
//definere mysql
#define db_host "localhost"
#define db_user "root"
#define db_pass ""
#define db_db "samp"
//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
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,"","");
savePlayer(playerid); //Hinzugefügt
return 1;
}
//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];Fehler
-
ka wo 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,"","");
savePlayer(playerid); //Hinzugefügt
return 1;
} das hingehört -
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;
} -
SQL
Alles anzeigen[16:58:57] [DEBUG] mysql_connect - host: "localhost", user: "root", database: "samp", password: "****", port: 3306, autoreconnect: true, pool_size: 2 [16:58:57] [DEBUG] CMySQLHandle::Create - creating new connection.. [16:58:57] [DEBUG] CMySQLHandle::CMySQLHandle - constructor called [16:58:57] [DEBUG] CMySQLHandle::Create - connection created (id: 1) [16:58:57] [DEBUG] CMySQLConnection::Connect - establishing connection to database... [16:58:57] [DEBUG] CMySQLConnection::Connect - connection was successful [16:58:57] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled [16:58:57] [DEBUG] CMySQLConnection::Connect - establishing connection to database... [16:58:57] [DEBUG] CMySQLConnection::Connect - establishing connection to database... [16:58:57] [DEBUG] CMySQLConnection::Connect - connection was successful [16:58:57] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled [16:58:57] [DEBUG] CMySQLConnection::Connect - connection was successful [16:58:57] [DEBUG] CMySQLConnection::Connect - establishing connection to database... [16:58:57] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled [16:58:57] [DEBUG] CMySQLConnection::Connect - connection was successful [16:58:57] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled [16:59:16] [DEBUG] mysql_tquery - connection: 1, query: "SELECT id FROM user WHERE username='Killerorc'", callback: "OnUserCheck", format: "d" [16:59:16] [DEBUG] CMySQLQuery::Execute[OnUserCheck] - starting query execution [16:59:16] [DEBUG] CMySQLQuery::Execute[OnUserCheck] - query was successfully executed within 0.379 milliseconds [16:59:16] [DEBUG] CMySQLResult::CMySQLResult() - constructor called [16:59:16] [DEBUG] Calling callback "OnUserCheck".. [16:59:16] [DEBUG] cache_get_data - connection: 1 [16:59:16] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called [16:59:22] [DEBUG] mysql_escape_string - source: "test12345", connection: 1, max_len: 35 [16:59:22] [DEBUG] mysql_tquery - connection: 1, query: "SELECT * FROM user WHERE username='Killerorc' AND passwort='test", callback: "OnPasswordResponse", format: "i" [16:59:22] [DEBUG] CMySQLQuery::Execute[OnPasswordResponse] - starting query execution [16:59:22] [DEBUG] CMySQLQuery::Execute[OnPasswordResponse] - query was successfully executed within 0.647 milliseconds [16:59:22] [DEBUG] CMySQLResult::CMySQLResult() - constructor called [16:59:22] [DEBUG] Calling callback "OnPasswordResponse".. [16:59:22] [DEBUG] cache_get_data - connection: 1 [16:59:22] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called [16:59:32] [DEBUG] mysql_close - connection: 1 [16:59:32] [DEBUG] CMySQLConnection::Disconnect - connection was closed [16:59:32] [DEBUG] CMySQLHandle::~CMySQLHandle - deconstructor called
Ich hoffe ihr könnt damit was anfangen
-
Jeffry das ist ja keine Gang Zone was ich laden lasse. Es geht einfach darum das er die Accounts nach dem ersten Login nicht speichert wo die Spieler Level= 1 + Geld= 1500 bekommen nicht abspeichert. Erst wenn man sich was gekauft hat wird ein Spieler abgespeichert und das darf normal nicht so sein.
-
guten Tag.
Ich habe zwar jetzt das save-system für die accounts aber ich habe ein anderes problem.
Das neue Problem ist:
Wenn ich mich Registriere ist alles da sobald ich mich auslogge und wieder einlogge dann steht Level= 0 Geld= 0
Aber wenn ich was kaufe bekomme ich den wert nach dem Kaufen. Das will ich zwar auch aber ich will auch wenn Spieler sich neu Registrieren und einloggen und direkt wieder raus gehen auch gespeichert werdern.
Ich poste mal das Save-System wo nur die Spieler gespeichert werden wenn die etwas verkauft haben. Ich will auch das die wenn die Geld bekommen haben und sich dann ausloggen auch abgespeichert werden.
PWN-Code:
savePlayer(playerid)
{
if(sInfo[playerid][eingeloggt]==0) return 1;
//speichern level,adminlevel,geld,id
new query[128];
format(query,sizeof(query),"UPDATE user SET Adminlevel='%i' ,money='%i' ,level='%i',id='%i' WHERE id='%i'",sInfo[playerid][Adminlevel],GetPlayerMoney(playerid),GetPlayerScore(playerid),sInfo[playerid][id]);
mysql_function_query(dbhandle,query,false,"","");
return 1;
}Ich hoffe man kann mir helfen
-
Danke dreamer5655 für deine hilfe. Auch an die anderen vielen dank für eure hilfe. Es geht jetzt alles.
-
Da pikatchu den code haben will schreibe ich denn doch gleich noch mal:
PWN-Code:
//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 "db_349"
#define db_pass "klom19pom"
#define db_db "db_349"
//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[128];
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;
} -
mein script lässt nun wegen den ganzen kram mein Register/Login-System nicht mehr zugreiffen.
-
das hilft mir überhaupt nicht weiter da ich mit der funktion:
restPlayer(playerid) und savePlayer(playerid) arbeite und somit in kein enum gepackt habe.
-
wenn ich das benutze dann kommt immer folgender warningcode:
Problem mit einem Tag'einer Variable gefunden:
resetPlayer(playerid)
{
for(new i=0; i<sizeof(sInfo[]); i++)
{
sInfo[playerid][playerInfo:i]=0;
}
return 1;German_ScripterHD wegen dir musste ich mein script wieder zurück setzen weil wegen dir mein Register/Login-system nicht ging
-
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
Externer Inhalt www.youtube.comInhalte von externen Seiten werden ohne Ihre Zustimmung nicht automatisch geladen und angezeigt.Durch die Aktivierung der externen Inhalte erklären Sie sich damit einverstanden, dass personenbezogene Daten an Drittplattformen übermittelt werden. Mehr Informationen dazu haben wir in unserer Datenschutzerklärung zur Verfügung gestellt.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;
}