Guten Morgen
Habe das Tutorial von @Jeffry genommen mit dem MYSQL Script mit dem Register und Login.
Das Script an sich funktioniert ja ohne Probleme aber das Problem ist der will mich nicht auf die Datenbank lassen.
Bash
----------
Loaded log file: "server_log.txt".
----------
SA-MP Dedicated Server
----------------------
v0.3.7-R2, (C)2005-2015 SA-MP Team
[12:07:20] filterscripts = "" (string)
[12:07:20]
[12:07:20] Server Plugins
[12:07:20] --------------
[12:07:20] Loading plugin: mysql
[12:07:20] >> plugin.mysql: R39-4 successfully loaded.
[12:07:20] Loaded.
[12:07:20] Loaded 1 plugins.
[12:07:20]
[12:07:20] Filterscripts
[12:07:20] ---------------
[12:07:20] Loaded 0 filterscripts.
[12:07:20] [MYSQL] Verbindungsaufbau..........
[12:07:20] [MYSQL] Es konnte keine Verbindung zur Datenbank hergestellt werden.
[12:07:20] [MYSQL] Starte neuen Verbindungsversuch (TTL: 2).
[12:07:20] [MYSQL] Verbindungsaufbau..........
[12:07:20] [MYSQL] Es konnte keine Verbindung zur Datenbank hergestellt werden.
[12:07:20] [MYSQL] Starte neuen Verbindungsversuch (TTL: 1).
[12:07:20] [MYSQL] Verbindungsaufbau..........
[12:07:20] [MYSQL] Es konnte keine Verbindung zur Datenbank hergestellt werden.
[12:07:20] [MYSQL] Bitte überprüfen Sie die Verbindungsdaten
[12:07:20] [MYSQL] Der Server wird automatisch Heruntergefahren
[12:07:20]
----------------------------------
[12:07:20] Life of Real Version 0.1
[12:07:20] ----------------------------------
[12:07:20] Number of vehicle models: 0
[12:07:20] --- Server Shutting Down.
[12:07:20] plugin.mysql: Unloading plugin...
[12:07:20] plugin.mysql: Plugin unloaded.
Alles anzeigen
Ich teste es ja auf mein Homepc und da geht mein Script nicht.
Habe es auch so Defininiert:
Bash
/* ---------------Credits----------------------------------------------------------
Die Inhalte die in diesem Script vorkommen sind eigentum von und dürfen
ohne Seine Zustimmung nicht benutzt werder oder weiter gegeben werden.
Sollte das veröffentlicht werden dürfen die Credits nicht geändert werden.
Jegliche Art der veränderungen an den Credits wird mit einer Anzeige gefandet.
Dieses Script wird ein Reallife-Script[Selfmade]
Mysql wird verwendet.
----------------------------------------------------------------------------------------*/
//--------------------------------------Includes------------------------------------------
#include <a_samp>
#include<a_mysql>
#include<ocmd.inc>
//-------------------------------------------------------------------------------------------
//--------------------------Farben---------------------------------
#define rot 0xFF0000FF
#define blau 0x0000DDFF
#define grün 0x09C500FF
#define gelb 0xFFFF00FF
//---------------------------------------------------------------------
//----------------------------------MYSQL--------------------------
#define MYSQL_HOST "127.0.0.1"
#define MYSQL_USER "root"
#define MYSQL_PASS ""
#define MYSQL_DB "samp"
new handle;
//-----------------------------------------------------------------------
//-------------------------------Forwards---------------------------
forward OnUserCheck(playerid);
forward OnUserLogin(playerid);
forward OnUserRegister(playerid);
//-----------------------------------------------------------------------
//----------------------------Enums----------------------------------
enum pDataEnum
{
p_id,
bool:pLoggedIn,
pName[MAX_PLAYER_NAME],
pLevel,
pAlevel,
pMoney
}
new PlayerInfo[MAX_PLAYER_NAME][pDataEnum];
//------------------------------------------------------------------------
//----------------------------DIALOGE-------------------------------
#define DIALOG_REGISTER 1
#define DIALOG_LOGIN 2
//------------------------------------------------------------------------
main()
{
print("\n----------------------------------");
print(" Life of Real Version 0.1");
print("----------------------------------\n");
}
public OnGameModeInit()
{
// Don't use these lines if it's a filterscript
SetGameModeText("Life of Real Version 0.1");
AddPlayerClass(115, 2400.9517,-2688.3296,13.6494,178.2475,0,0,0,0,0,0);
AddPlayerClass(93, 2400.9517,-2688.3296,13.6494,178.2475,0,0,0,0,0,0);
MySQL_SetupConnection();
return 1;
}
public OnGameModeExit()
{
mysql_close(handle);
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
new query[128];
mysql_format(handle,query,sizeof(query), "SELECT id FROM Accounts WHERE name = '%e' ",PlayerInfo[playerid][pName]);
mysql_pquery(handle,query,"OnUserCheck","d",playerid);
SetPlayerPos(playerid, 2401.0645,-2691.9045,13.6451);
SetPlayerCameraPos(playerid, 2401.0645,-2691.9045,13.6451);
SetPlayerCameraLookAt(playerid, 2401.0645,-2691.9045,13.6451);
return 1;
}
public OnPlayerConnect(playerid)
{
SendClientMessage(playerid,rot,"Willkommen auf Life of Real. Wir hoffen euch ein angenehmen aufenhalt zu bieten. Wenn ihr Hilfe braucht sprecht uns an!");
PlayerInfo[playerid][p_id] =0;
PlayerInfo[playerid][pLoggedIn] =false;
PlayerInfo[playerid][pLevel] =0;
PlayerInfo[playerid][pAlevel] =0;
PlayerInfo[playerid][pMoney] =0;
GetPlayerName(playerid,PlayerInfo[playerid][pName],MAX_PLAYER_NAME);
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
SaveUserStats(playerid);
return 1;
}
public OnPlayerSpawn(playerid)
{
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
if(killerid != INVALID_PLAYER_ID)
{
PlayerInfo[playerid][pMoney] += 10;
if(PlayerInfo[playerid][pMoney] >3)
{
PlayerInfo[playerid][pLevel] = 1;
}
}
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[])
{
if(dialogid == DIALOG_REGISTER)
{
if(!response) return Kick(playerid);
if(strlen(inputtext) <3)return ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_PASSWORD,"Account Erstellung","Bitte Erstelle dir ein Account\n{0x00A598FF}Mindestens 6 Zeichen!","Erstellen","Verlassen");
new query[256];
mysql_format(handle,query,sizeof(query), "INSERT INTO Accounts (name,password) VALUES ('%e',MD5('%e'))",PlayerInfo[playerid][pName],inputtext);
mysql_pquery(handle,query,"OnUserRegister","d",playerid);
return 1;
}
if(dialogid == DIALOG_LOGIN)
{
if(!response) return Kick(playerid);
if(strlen(inputtext) <3)return ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Anmeldung","Bitte Logge dich mit dein Password ein.\n{0x00A598FF}Mindestens 6 Zeichen!","Anmelden","Verlassen");
new query[256];
mysql_format(handle,query,sizeof(query), "SELECT * FROM Accounts WHERE name = '%e' AND password = MD5('%e')",PlayerInfo[playerid][pName],inputtext);
mysql_pquery(handle,query,"OnUserLogin","d",playerid);
return 1;
}
return 0;
}
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}
stock MySQL_SetupConnection(ttl =3)
{
print("[MYSQL] Verbindungsaufbau..........");
handle = mysql_connect(MYSQL_HOST,MYSQL_USER,MYSQL_PASS,MYSQL_DB);
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
{
//Abbrechen und Server ausschalten:
print("[MYSQL] Es konnte keine Verbindung zur Datenbank hergestellt werden.");
print("[MYSQL] Bitte überprüfen Sie die Verbindungsdaten");
print("[MYSQL] Der Server wird automatisch Heruntergefahren");
return SendRconCommand("exit");
}
}
printf("[MYSQL] Die Verbindung zur Datenbank wurde erfolgreich hergestellt! Handle: %d",handle);
return 1;
}
public OnUserCheck(playerid)
{
if(cache_get_row_count() ==0)
{
ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_PASSWORD,"Account Erstellung","Bitte Erstelle dir ein Account","Erstellen","Verlassen");
}
{
ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Anmeldung","Bitte Logge dich mit dein Password ein","Einloggen","Verlassen");
}
return 1;
}
public OnUserRegister(playerid)
{
PlayerInfo[playerid][p_id] = cache_insert_id();
SendClientMessage(playerid,grün,"[Konto] Account Erstellung erfolgreich");
return 1;
}
public OnUserLogin(playerid)
{
if(cache_get_row_count() == 0)
{
ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Anmeldung","Bitte Logge dich mit dein Password ein.\n{0x0000DDFF}Passwort falsch eingetippt.","Anmelden","Verlassen");
}
else
{
PlayerInfo[playerid][p_id] = cache_get_field_content_int(0,"id",handle);
PlayerInfo[playerid][pLevel] = cache_get_field_content_int(0,"level",handle);
PlayerInfo[playerid][pAlevel] = cache_get_field_content_int(0,"alevel",handle);
PlayerInfo[playerid][pMoney] = cache_get_field_content_int(0,"money",handle);
PlayerInfo[playerid][pLoggedIn] =true;
SendClientMessage(playerid,blau, "[Konto] Eingeloggt.");
GivePlayerMoney(playerid,PlayerInfo[playerid][pMoney]);
}
return 1;
}
stock SaveUserStats(playerid)
{
if(!PlayerInfo[playerid][pLoggedIn])return 1;
new query[256];
mysql_format(handle,query,sizeof(query), "UPDATE Accounts SET level = '%d', alevel ='%d', money'%d' WHERE id = '%d' ",PlayerInfo[playerid][pLevel],PlayerInfo[playerid][pAlevel],PlayerInfo[playerid][pMoney]);
mysql_pquery(handle,query);
return 1;
}
Alles anzeigen