Zeig mal deinen INSERT-Query, mit welchem du versuchst den Benutzer zu erstellen. Außerdem fehlt die Spalte 'RegisterIP' in deiner Tabelle.
Die Tabllen spalte hab ich schon hinzugefügt.
Ich werde gleich wenn ich zuhause bin das Register und Login System hier hinzufügen
/e Text
Ich habe jetzt nochmal ein neues Register/Login System geschrieben, es funkt fast alles.
Wenn ich mich jetzt Registere steht dort Account erfolgtreich angelegt und der Spieler spawnt.
Loge ich mich nun ein müsste dort stehen [Account] eingeloggt. und dies passiert leider nicht, dazu wird der Spieler auch nicht gespawnt.
ich finde denn Gamemode unten mit ein.
#include <a_samp>
#include <a_mysql>
#define MySQL_HOST "127.0.0.1"
#define MySQL_USER "root"
#define MySQL_PASS ""
#define MySQL_DATA "samp"
new MySQL:handle;
forward REGISTER_SPIELER(playerid);
forward REGISTER_SPIELER_2(playerid);
forward LOGIN_SPIELER(playerid);
enum
{
DIALOG_REGISTER,
DIALOG_LOGIN
}
enum SpielerData
{
p_id,
bool:pLoggedIn,
pName[MAX_PLAYER_NAME],
pLevel,
pMoney,
pKills,
pDeaths
}
new oInfo[MAX_PLAYERS][SpielerData];
main()
{
print("\n----------------------------------");
print(" Blank Gamemode by your name here");
print("----------------------------------\n");
}
public OnGameModeInit()
{
MySQL_SetupConnection();
mysql_log();
SetGameModeText("Blank Script");
AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
return 1;
}
public OnGameModeExit()
{
mysql_close(handle);
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
if(!oInfo[playerid][pLoggedIn])
{
new query[256];
mysql_format(handle, query, sizeof(query),"SELECT id FROM server_accounts1 WHERE Name = '%e'", oInfo[playerid][pName]);
mysql_pquery(handle, query, "REGISTER_SPIELER", "d", playerid);
}
SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
return 1;
}
public OnPlayerConnect(playerid)
{
oInfo[playerid][p_id] = 0;
oInfo[playerid][pLoggedIn] = false;
oInfo[playerid][pLevel] = 0;
oInfo[playerid][pMoney] = 0;
oInfo[playerid][pKills] = 0;
oInfo[playerid][pDeaths] = 0;
//oInfo[playerid][] = 0;
GetPlayerName(playerid, oInfo[playerid][pName], MAX_PLAYER_NAME);
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
Save_Spieler(playerid);
return 1;
}
public OnPlayerSpawn(playerid)
{
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
if(killerid != INVALID_PLAYER_ID)
{
oInfo[killerid][pKills]++;
GivePlayerMoney(killerid, 10);
oInfo[killerid][pMoney] += 10;
if(oInfo[killerid][pKills] > 3)
{
oInfo[killerid][pLevel] = 1;
}
}
oInfo[playerid][pDeaths]++;
return 1;
}
public OnVehicleSpawn(vehicleid)
{
return 1;
}
public OnVehicleDeath(vehicleid, killerid)
{
return 1;
}
public OnPlayerText(playerid, text[])
{
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/mycommand", cmdtext, true, 10) == 0)
{
// Do something here
return 1;
}
return 0;
}
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[])
{
return 1;
}
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[])
{
switch(dialogid)
{
case DIALOG_REGISTER:
{
if(!response) return Kick(playerid);
if(strlen(inputtext) < 3) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Registration", "Register text\n Mid. 3 Zeichen lang.","Register","Abbrechen");
new query[256];
mysql_format(handle, query, sizeof(query), "INSERT INTO server_accounts1(Name, Password, RegisterIP) VALUES ('%e', MD5('%e'), '%s')", oInfo[playerid][pName], inputtext, GetPlayerIP(playerid));
mysql_pquery(handle, query, "REGISTER_SPIELER_2", "d", playerid);
return 1;
}
case DIALOG_LOGIN:
{
if(!response) return Kick(playerid);
if(strlen(inputtext) < 3) return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Anmeldung", "Login Text\n Mid. 3 Zeichen!", "Anmeldung", "Abbrechen");
new query[256];
mysql_format(handle, query, sizeof(query), "SELECT * FROM server_accounts1 WHERE Name = '%e' AND Password = MD5 ('%e')", oInfo[playerid][pName], inputtext);
mysql_pquery(handle, query, "LOGIN_SPIELER", "d", playerid);
return 1;
}
}
}
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}
public REGISTER_SPIELER(playerid)
{
new rows;
cache_get_row_count(rows);
if(rows == 0)
{
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,"Registration","Register Text folgt", "Regi","Abbrechen");
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,"Anmeldung", "Login Text","Login","Abbrechen");
}
return 1;
}
public REGISTER_SPIELER_2(playerid)
{
oInfo[playerid][p_id] = cache_insert_id();
oInfo[playerid][pLoggedIn] = true;
SendClientMessage(playerid, 0x00FF00,"[Account] Registration erfolgreich.");
SpawnPlayer(playerid);
return 1;
}
public LOGIN_SPIELER(playerid)
{
new rows;
cache_get_row_count(rows);
if(rows == 0)
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Anmeldung", "LOGIN TEXT\n Falsches Password eingeben!", "Login","Abbrechen");
}
else
{
cache_get_value_name_int(0, "ID", oInfo[playerid][p_id]);
cache_get_value_name_int(0, "Level", oInfo[playerid][pLevel]);
cache_get_value_name_int(0, "Money", oInfo[playerid][pMoney]);
cache_get_value_name_int(0, "Kills", oInfo[playerid][pKills]);
cache_get_value_name_int(0, "Deaths", oInfo[playerid][pDeaths]);
oInfo[playerid][pLoggedIn] = true;
SendClientMessage(playerid, 0x00FF00FF,"[Account] Eingeloggt.");
GivePlayerMoney(playerid, oInfo[playerid][pMoney]);
}
return 1;
}
stock MySQL_SetupConnection(ttl = 3)
{
print("[MySQL] Ein Verbindungsaufbau wird versucht.");
handle = mysql_connect(MySQL_HOST, MySQL_USER, MySQL_PASS, MySQL_DATA);
if(mysql_errno(handle) != 0)
{
if(ttl > 1)
{
print("[MySQL] Es konnte keine Verbindung zur Datenbank hergestellt werden.");
printf("[MySQL] Starte neuen Verbindungsversuch (TTL: %d).", ttl -1);
return MySQL_SetupConnection(ttl-1);
}
else
{
print("[MySQL] Es konnte keine Verbindung zur Database hergestellt werden.");
print("[MySQL] Bitte überprüfen sie die Verbindungsdaten.");
print("[MySQL] Der Server wird heruntergefahren.");
return SendRconCommand("exit");
}
}
printf("[MySQL] Die Verbindung zur Database wurde erfolgreich hergestellt! Handle: %d", _:handle);
return 1;
}
stock Save_Spieler(playerid)
{
if(!oInfo[playerid][pLoggedIn]) return 1;
new query[256];
mysql_format(handle, query, sizeof(query), "UPDATE users SET Level = '%d', Money = '%d', Kills = '%d', Deaths = '%d' WHERE ID = '%d'",
oInfo[playerid][pLevel], oInfo[playerid][pMoney], oInfo[playerid][pKills], oInfo[playerid][pDeaths], oInfo[playerid][p_id]);
mysql_pquery(handle, query);
return 1;
}
stock GetPlayerIP(playerid)
{
new IP[25];
GetPlayerIp(playerid, IP, sizeof(IP));
return IP;
}