Hallo,
ich habe gerade angefangen Skinshops zu erstellen, allerdings stimmt da irgendwas mit den Script nicht.
Momentan wird der stock "Connect_To_Database();" einfach nicht beim starten des Servers ausgeführt,
im allgemeinen wird nichts von dem was im Script steht ausgeführt.
Ich weiß nicht wo ich einen Fehler eingebaut habe und finde auch keinen Fehler..
Der Serverlog:
Code
[22:37:00] [22:37:00] Server Plugins[22:37:00] --------------[22:37:00] Loading plugin: mysql[22:37:00] > MySQL plugin R5 successfully loaded.[22:37:00] Loaded.[22:37:00] Loading plugin: sscanf[22:37:00] [22:37:00] ===============================[22:37:00] sscanf plugin loaded. [22:37:00] (c) 2009 Alex "Y_Less" Cole[22:37:00] 0.3d-R2 500 Players "dnee"[22:37:00] ===============================[22:37:00] Loaded.[22:37:00] Loaded 2 plugins.[22:37:00] [22:37:00] Filterscripts[22:37:00] ---------------[22:37:00] Loading filterscript 'Spawn.amx'...[22:37:00] <-| [MYSQL] Verbindung zur Datenbank wurde erfolgreich hergestellt![22:37:00] Loading filterscript 'LSSkinshop.amx'...[22:37:00] Loading filterscript 'vspawner.amx'...[22:37:00] Loaded 3 filterscripts.[22:37:00] ----------------------------------[22:37:00] Blank Gamemode by Syneroz[22:37:00] ----------------------------------
Hier das Filterscript:
#include <a_samp>
#include <a_mysql>
#include <ocmd>
#include <sscanf2>
#include <streamer>
#include <a_mysql>
#include <ocmd>
#include <sscanf2>
#include <streamer>
#define SQL_HOST "localhost"
#define SQL_USER "root"
#define SQL_PASS ""
#define SQL_DATA "gta_db"
#define SQL_USER "root"
#define SQL_PASS ""
#define SQL_DATA "gta_db"
#define COLOR_GREY 0xBFBFBFFF
#define COLOR_YELLOW 0xFFFF00FF
#define COLOR_YELLOW 0xFFFF00FF
#define MAX_LSbizSkinShop 10
enum LSbizSkinShopDaten
{
bLSbizSkinShop_ID,
bLSbizSkinShop_Name[24],
bLSbizSkinShop_Preis,
bLSbizSkinShop_Besitzer[24],
bLSbizSkinShop_Interior,
bLSbizSkinShop_World,
Float:bLSbizSkinShop_EnterX,
Float:bLSbizSkinShop_EnterY,
Float:bLSbizSkinShop_EnterZ,
Float:bLSbizSkinShop_ExitX,
Float:bLSbizSkinShop_ExitY,
Float:bLSbizSkinShop_ExitZ,
bLSbizSkinShop_Pickup,
Text3D:bLSbizSkinShop_Label
}
{
bLSbizSkinShop_ID,
bLSbizSkinShop_Name[24],
bLSbizSkinShop_Preis,
bLSbizSkinShop_Besitzer[24],
bLSbizSkinShop_Interior,
bLSbizSkinShop_World,
Float:bLSbizSkinShop_EnterX,
Float:bLSbizSkinShop_EnterY,
Float:bLSbizSkinShop_EnterZ,
Float:bLSbizSkinShop_ExitX,
Float:bLSbizSkinShop_ExitY,
Float:bLSbizSkinShop_ExitZ,
bLSbizSkinShop_Pickup,
Text3D:bLSbizSkinShop_Label
}
new LSbizSkinShopInfo[MAX_LSbizSkinShop][LSbizSkinShopDaten];
public OnFilterScriptInit()
{
print("<-| [Es wird geladen!!");
LoadLSbizSkinShop();
Connect_To_Database();
return 1;
}
{
print("<-| [Es wird geladen!!");
LoadLSbizSkinShop();
Connect_To_Database();
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
{
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/mycommand", cmdtext, true, 10) == 0)
{
// Do something here
return 1;
}
return 0;
}
{
if (strcmp("/mycommand", cmdtext, true, 10) == 0)
{
// Do something here
return 1;
}
return 0;
}
stock mysql_GetString(Table[], Field[], Where[], Is[])
{
new query[128], Get[512];
mysql_real_escape_string(Table, Table);
mysql_real_escape_string(Field, Field);
mysql_real_escape_string(Where, Where);
mysql_real_escape_string(Is, Is);
format(query, 128, "SELECT `%s` FROM `%s` WHERE `%s` = '%s'", Field, Table, Where, Is);
mysql_query(query);
mysql_store_result();
mysql_fetch_row(Get);
mysql_free_result();
return Get;
}
{
new query[128], Get[512];
mysql_real_escape_string(Table, Table);
mysql_real_escape_string(Field, Field);
mysql_real_escape_string(Where, Where);
mysql_real_escape_string(Is, Is);
format(query, 128, "SELECT `%s` FROM `%s` WHERE `%s` = '%s'", Field, Table, Where, Is);
mysql_query(query);
mysql_store_result();
mysql_fetch_row(Get);
mysql_free_result();
return Get;
}
stock LoadLSbizSkinShop()
{
for(new i = 0; i < MAX_LSbizSkinShop; i++)
{
new query[600], savingstring[24], string[128];
{
for(new i = 0; i < MAX_LSbizSkinShop; i++)
{
new query[600], savingstring[24], string[128];
format(query, sizeof(query), "SELECT * FROM LSbizSkinShop WHERE LSbizSkinShop_ID = %i", i);
mysql_query(query);
while(mysql_fetch_row_format(query,"|"))
{
mysql_fetch_field_row(savingstring, "LSbizSkinShop_ID"); LSbizSkinShopInfo[i][bLSbizSkinShop_ID] = strval(savingstring);
mysql_fetch_field_row(savingstring, "LSbizSkinShop_Name"); LSbizSkinShopInfo[i][bLSbizSkinShop_Name] = strval(savingstring);
mysql_fetch_field_row(savingstring, "LSbizSkinShop_Preis"); LSbizSkinShopInfo[i][bLSbizSkinShop_Preis] = strval(savingstring);
mysql_fetch_field_row(savingstring, "LSbizSkinShop_Besitzer"); LSbizSkinShopInfo[i][bLSbizSkinShop_Besitzer] = strval(savingstring);
mysql_fetch_field_row(savingstring, "LSbizSkinShop_Interior"); LSbizSkinShopInfo[i][bLSbizSkinShop_Interior] = strval(savingstring);
mysql_fetch_field_row(savingstring, "LSbizSkinShop_Wolrd"); LSbizSkinShopInfo[i][bLSbizSkinShop_World] = strval(savingstring);
mysql_fetch_field_row(savingstring, "LSbizSkinShop_EnterX"); LSbizSkinShopInfo[i][bLSbizSkinShop_EnterX] = floatstr(savingstring);
mysql_fetch_field_row(savingstring, "LSbizSkinShop_EnterY"); LSbizSkinShopInfo[i][bLSbizSkinShop_EnterY] = floatstr(savingstring);
mysql_fetch_field_row(savingstring, "LSbizSkinShop_EnterZ"); LSbizSkinShopInfo[i][bLSbizSkinShop_EnterZ] = floatstr(savingstring);
mysql_fetch_field_row(savingstring, "LSbizSkinShop_ExitX"); LSbizSkinShopInfo[i][bLSbizSkinShop_ExitX] = floatstr(savingstring);
mysql_fetch_field_row(savingstring, "LSbizSkinShop_ExitY"); LSbizSkinShopInfo[i][bLSbizSkinShop_ExitY] = floatstr(savingstring);
mysql_fetch_field_row(savingstring, "LSbizSkinShop_ExitZ"); LSbizSkinShopInfo[i][bLSbizSkinShop_ExitZ] = floatstr(savingstring);
}
new BizName[24]; format(BizName, 24, "%s", LSbizSkinShopInfo[i][bLSbizSkinShop_Name]);
strreplace(BizName, '_', ' ');
if(!strcmp(LSbizSkinShopInfo[i][bLSbizSkinShop_Besitzer], "Niemand", false)) format(string, sizeof(string), "%s\n[Zu Verkaufen!]\nPreis: %i\nBenutze '/enter' oder drücke 'F' zum das Gebäude zu betreten!", BizName, LSbizSkinShopInfo[i][bLSbizSkinShop_Preis]);
else format(string, sizeof(string), "%s\nBesitzer: %s\nBenutze '/enter' oder drücke 'F' zum das Gebäude zu betreten!", LSbizSkinShopInfo[i][bLSbizSkinShop_Name], LSbizSkinShopInfo[i][bLSbizSkinShop_Besitzer]);
LSbizSkinShopInfo[i][bLSbizSkinShop_Label] = CreateDynamic3DTextLabel(string, COLOR_YELLOW, LSbizSkinShopInfo[i][bLSbizSkinShop_EnterX], LSbizSkinShopInfo[i][bLSbizSkinShop_EnterY], LSbizSkinShopInfo[i][bLSbizSkinShop_EnterZ], 12, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, -1, -1, -1);
LSbizSkinShopInfo[i][bLSbizSkinShop_Pickup] = CreateDynamicPickup(1272, 1, LSbizSkinShopInfo[i][bLSbizSkinShop_EnterX], LSbizSkinShopInfo[i][bLSbizSkinShop_EnterY], LSbizSkinShopInfo[i][bLSbizSkinShop_EnterZ], 0);
if(IsBusinessOwned(i)) printf("LSbizSkinShop %i wurde geladen; Name: %s", i, LSbizSkinShopInfo[i][bLSbizSkinShop_Name]);
}
return 1;
}
mysql_query(query);
while(mysql_fetch_row_format(query,"|"))
{
mysql_fetch_field_row(savingstring, "LSbizSkinShop_ID"); LSbizSkinShopInfo[i][bLSbizSkinShop_ID] = strval(savingstring);
mysql_fetch_field_row(savingstring, "LSbizSkinShop_Name"); LSbizSkinShopInfo[i][bLSbizSkinShop_Name] = strval(savingstring);
mysql_fetch_field_row(savingstring, "LSbizSkinShop_Preis"); LSbizSkinShopInfo[i][bLSbizSkinShop_Preis] = strval(savingstring);
mysql_fetch_field_row(savingstring, "LSbizSkinShop_Besitzer"); LSbizSkinShopInfo[i][bLSbizSkinShop_Besitzer] = strval(savingstring);
mysql_fetch_field_row(savingstring, "LSbizSkinShop_Interior"); LSbizSkinShopInfo[i][bLSbizSkinShop_Interior] = strval(savingstring);
mysql_fetch_field_row(savingstring, "LSbizSkinShop_Wolrd"); LSbizSkinShopInfo[i][bLSbizSkinShop_World] = strval(savingstring);
mysql_fetch_field_row(savingstring, "LSbizSkinShop_EnterX"); LSbizSkinShopInfo[i][bLSbizSkinShop_EnterX] = floatstr(savingstring);
mysql_fetch_field_row(savingstring, "LSbizSkinShop_EnterY"); LSbizSkinShopInfo[i][bLSbizSkinShop_EnterY] = floatstr(savingstring);
mysql_fetch_field_row(savingstring, "LSbizSkinShop_EnterZ"); LSbizSkinShopInfo[i][bLSbizSkinShop_EnterZ] = floatstr(savingstring);
mysql_fetch_field_row(savingstring, "LSbizSkinShop_ExitX"); LSbizSkinShopInfo[i][bLSbizSkinShop_ExitX] = floatstr(savingstring);
mysql_fetch_field_row(savingstring, "LSbizSkinShop_ExitY"); LSbizSkinShopInfo[i][bLSbizSkinShop_ExitY] = floatstr(savingstring);
mysql_fetch_field_row(savingstring, "LSbizSkinShop_ExitZ"); LSbizSkinShopInfo[i][bLSbizSkinShop_ExitZ] = floatstr(savingstring);
}
new BizName[24]; format(BizName, 24, "%s", LSbizSkinShopInfo[i][bLSbizSkinShop_Name]);
strreplace(BizName, '_', ' ');
if(!strcmp(LSbizSkinShopInfo[i][bLSbizSkinShop_Besitzer], "Niemand", false)) format(string, sizeof(string), "%s\n[Zu Verkaufen!]\nPreis: %i\nBenutze '/enter' oder drücke 'F' zum das Gebäude zu betreten!", BizName, LSbizSkinShopInfo[i][bLSbizSkinShop_Preis]);
else format(string, sizeof(string), "%s\nBesitzer: %s\nBenutze '/enter' oder drücke 'F' zum das Gebäude zu betreten!", LSbizSkinShopInfo[i][bLSbizSkinShop_Name], LSbizSkinShopInfo[i][bLSbizSkinShop_Besitzer]);
LSbizSkinShopInfo[i][bLSbizSkinShop_Label] = CreateDynamic3DTextLabel(string, COLOR_YELLOW, LSbizSkinShopInfo[i][bLSbizSkinShop_EnterX], LSbizSkinShopInfo[i][bLSbizSkinShop_EnterY], LSbizSkinShopInfo[i][bLSbizSkinShop_EnterZ], 12, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, -1, -1, -1);
LSbizSkinShopInfo[i][bLSbizSkinShop_Pickup] = CreateDynamicPickup(1272, 1, LSbizSkinShopInfo[i][bLSbizSkinShop_EnterX], LSbizSkinShopInfo[i][bLSbizSkinShop_EnterY], LSbizSkinShopInfo[i][bLSbizSkinShop_EnterZ], 0);
if(IsBusinessOwned(i)) printf("LSbizSkinShop %i wurde geladen; Name: %s", i, LSbizSkinShopInfo[i][bLSbizSkinShop_Name]);
}
return 1;
}
stock Float:mysql_GetFloat(Table[], Field[], Where[], Is[])
{
new query[128], Float:sqlfloat;
mysql_real_escape_string(Table, Table);
mysql_real_escape_string(Field, Field);
mysql_real_escape_string(Where, Where);
mysql_real_escape_string(Is, Is);
format(query, 128, "SELECT `%s` FROM `%s` WHERE `%s` = '%s'", Field, Table, Where, Is);
mysql_query(query);
mysql_store_result();
mysql_fetch_float(sqlfloat);
mysql_free_result();
return sqlfloat;
}
{
new query[128], Float:sqlfloat;
mysql_real_escape_string(Table, Table);
mysql_real_escape_string(Field, Field);
mysql_real_escape_string(Where, Where);
mysql_real_escape_string(Is, Is);
format(query, 128, "SELECT `%s` FROM `%s` WHERE `%s` = '%s'", Field, Table, Where, Is);
mysql_query(query);
mysql_store_result();
mysql_fetch_float(sqlfloat);
mysql_free_result();
return sqlfloat;
}
stock mysql_GetInt(Table[], Field[], Where[], Is[])
{
new query[128];
mysql_real_escape_string(Table, Table);
mysql_real_escape_string(Field, Field);
mysql_real_escape_string(Where, Where);
mysql_real_escape_string(Is, Is);
format(query, 128, "SELECT `%s` FROM `%s` WHERE `%s` = '%s'", Field, Table, Where, Is);
mysql_query(query);
mysql_store_result();
new sqlint = mysql_fetch_int();
mysql_free_result();
return sqlint;
}
{
new query[128];
mysql_real_escape_string(Table, Table);
mysql_real_escape_string(Field, Field);
mysql_real_escape_string(Where, Where);
mysql_real_escape_string(Is, Is);
format(query, 128, "SELECT `%s` FROM `%s` WHERE `%s` = '%s'", Field, Table, Where, Is);
mysql_query(query);
mysql_store_result();
new sqlint = mysql_fetch_int();
mysql_free_result();
return sqlint;
}
stock mysql_ReturnPasswort(Name[])
{
new query[130], Get[130];
mysql_real_escape_string(Name, Name);
format(query, 128, "SELECT `passwort` FROM `accounts` WHERE `Name` = '%s'", Name);
mysql_query(query);
mysql_store_result();
mysql_fetch_row(Get);
mysql_free_result();
return Get;
}
{
new query[130], Get[130];
mysql_real_escape_string(Name, Name);
format(query, 128, "SELECT `passwort` FROM `accounts` WHERE `Name` = '%s'", Name);
mysql_query(query);
mysql_store_result();
mysql_fetch_row(Get);
mysql_free_result();
return Get;
}
stock mysql_ReturnSecAntwort(Name[])
{
new query[130], Get[130];
mysql_real_escape_string(Name, Name);
format(query, 128, "SELECT `SecAntwort` FROM `accounts` WHERE `Name` = '%s'", Name);
mysql_query(query);
mysql_store_result();
mysql_fetch_row(Get);
mysql_free_result();
return Get;
}
{
new query[130], Get[130];
mysql_real_escape_string(Name, Name);
format(query, 128, "SELECT `SecAntwort` FROM `accounts` WHERE `Name` = '%s'", Name);
mysql_query(query);
mysql_store_result();
mysql_fetch_row(Get);
mysql_free_result();
return Get;
}
stock mysql_SetInt(Table[], Field[], To, Where[], Where2[])
{
new query[128];
mysql_real_escape_string(Table, Table);
mysql_real_escape_string(Field, Field);
mysql_real_escape_string(Where, Where);
mysql_real_escape_string(Where2, Where2);
format(query, 128, "UPDATE `%s` SET `%s` = '%d' WHERE `%s` = '%s'", Table, Field, To, Where, Where2);
mysql_query(query);
return true;
}
stock mysql_SetString(Table[], Field[], To[], Where[], Where2[])
{
new query[128];
mysql_real_escape_string(Table, Table);
mysql_real_escape_string(Field, Field);
mysql_real_escape_string(To, To);
mysql_real_escape_string(Where, Where);
mysql_real_escape_string(Where2, Where2);
format(query, 128, "UPDATE `%s` SET `%s` = '%s' WHERE `%s` = '%s'", Table, Field, To, Where, Where2);
mysql_query(query);
return true;
}
stock mysql_SetFloat(Table[], Field[], Float:To, Where[], Where2[])
{
new query[128];
mysql_real_escape_string(Table, Table);
mysql_real_escape_string(Field, Field);
mysql_real_escape_string(Where, Where);
mysql_real_escape_string(Where2, Where2);
format(query, 128, "UPDATE `%s` SET `%s` = '%f' WHERE `%s` = '%s'", Table, Field, To, Where, Where2);
mysql_query(query);
return true;
}
{
new query[128];
mysql_real_escape_string(Table, Table);
mysql_real_escape_string(Field, Field);
mysql_real_escape_string(Where, Where);
mysql_real_escape_string(Where2, Where2);
format(query, 128, "UPDATE `%s` SET `%s` = '%d' WHERE `%s` = '%s'", Table, Field, To, Where, Where2);
mysql_query(query);
return true;
}
stock mysql_SetString(Table[], Field[], To[], Where[], Where2[])
{
new query[128];
mysql_real_escape_string(Table, Table);
mysql_real_escape_string(Field, Field);
mysql_real_escape_string(To, To);
mysql_real_escape_string(Where, Where);
mysql_real_escape_string(Where2, Where2);
format(query, 128, "UPDATE `%s` SET `%s` = '%s' WHERE `%s` = '%s'", Table, Field, To, Where, Where2);
mysql_query(query);
return true;
}
stock mysql_SetFloat(Table[], Field[], Float:To, Where[], Where2[])
{
new query[128];
mysql_real_escape_string(Table, Table);
mysql_real_escape_string(Field, Field);
mysql_real_escape_string(Where, Where);
mysql_real_escape_string(Where2, Where2);
format(query, 128, "UPDATE `%s` SET `%s` = '%f' WHERE `%s` = '%s'", Table, Field, To, Where, Where2);
mysql_query(query);
return true;
}
stock IsBusinessOwned(businessid)
{
new query[200];
format(query, sizeof(query), "SELECT Owner FROM 'LSbizSkinShop' WHERE LSbizSkinShop_ID = %i", businessid);
mysql_query(query);
mysql_store_result();
new rows = mysql_num_rows();
mysql_free_result();
if(!rows) return false;
else return true;
}
{
new query[200];
format(query, sizeof(query), "SELECT Owner FROM 'LSbizSkinShop' WHERE LSbizSkinShop_ID = %i", businessid);
mysql_query(query);
mysql_store_result();
new rows = mysql_num_rows();
mysql_free_result();
if(!rows) return false;
else return true;
}
stock strreplace(string[], oldchar, newchar)
{
for(new i = 0; i < strlen(string); i++)
{
if(string[i] == oldchar)
{
string[i] = newchar;
}
}
}
{
for(new i = 0; i < strlen(string); i++)
{
if(string[i] == oldchar)
{
string[i] = newchar;
}
}
}
stock Connect_To_Database()
{
mysql_connect(SQL_HOST, SQL_USER, SQL_DATA, SQL_PASS); //Wir versuchen mit den Angaben die wir oben im Script gemacht haben uns mit dem MySQL Server zu verbinden.
if(mysql_ping() == 1) //Es wird überprüft ob die Verbindung steht.
{
//Falls ja wird das in die Console geschrieben und die Funktion wird beendet.
print("<-| [MYSQL] Verbindung zur Datenbank wurde erfolgreich hergestellt!");
return true;
}
else
{
//Falls nicht wird erneut versucht eine Verbindung aufzubauen.
print("<-| [MYSQL] Es konnte keine Verbindung zur Datenbank hergestellt werden!");
print("<-| [MYSQL] Es wird erneut versucht eine Verbindung zur Datenbank herzustellen!");
mysql_connect(SQL_HOST, SQL_USER, SQL_DATA, SQL_PASS);
if(mysql_ping() == 1)
{
print("<-| [MYSQL] Es konnte im 2 Versuch eine Verbindung hergestellt werden!");
return true;
}
else
{
//Falls das auch nicht Funktioniert wird der Server zur Sicherheit wieder heruntergefahren.
print("<-| [MYSQL] Es konnte keine Verbindung zur Datenbank hergestellt werden!");
print("<-| [MYSQL] Der Server wird nun beendet!");
SendRconCommand("exit");
return true;
}
}
}
{
mysql_connect(SQL_HOST, SQL_USER, SQL_DATA, SQL_PASS); //Wir versuchen mit den Angaben die wir oben im Script gemacht haben uns mit dem MySQL Server zu verbinden.
if(mysql_ping() == 1) //Es wird überprüft ob die Verbindung steht.
{
//Falls ja wird das in die Console geschrieben und die Funktion wird beendet.
print("<-| [MYSQL] Verbindung zur Datenbank wurde erfolgreich hergestellt!");
return true;
}
else
{
//Falls nicht wird erneut versucht eine Verbindung aufzubauen.
print("<-| [MYSQL] Es konnte keine Verbindung zur Datenbank hergestellt werden!");
print("<-| [MYSQL] Es wird erneut versucht eine Verbindung zur Datenbank herzustellen!");
mysql_connect(SQL_HOST, SQL_USER, SQL_DATA, SQL_PASS);
if(mysql_ping() == 1)
{
print("<-| [MYSQL] Es konnte im 2 Versuch eine Verbindung hergestellt werden!");
return true;
}
else
{
//Falls das auch nicht Funktioniert wird der Server zur Sicherheit wieder heruntergefahren.
print("<-| [MYSQL] Es konnte keine Verbindung zur Datenbank hergestellt werden!");
print("<-| [MYSQL] Der Server wird nun beendet!");
SendRconCommand("exit");
return true;
}
}
}