Huhu,
also das Problem war ich hatte ein '%d' für die ID vergessen.
Ich kann jetzt aber irgendwie nur ein Haus erstellen, die anderen werden nicht eingetragen.
Noch dazu wird es denke ich nicht geladen, da kein Pickup erstellt wird.
Die Log:
Inhalt anzeigen
[13:32:48] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE House SET Besitzer = '', Level = '0', PosX = '0.000000', PosY = '0.000000', PosZ = '0.000000', IntX = '0.000000', IntY = '0.000000',IntZ = '0.000000',IntID = '0', VID = '0', `Locked` = '0', Mietpreis = '0', Kaufpreis = '0', Gekauft = '0' WHERE ID =", callback: "(null)", format: "(null)"[13:32:48] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE House SET Besitzer = '', Level = '0', PosX = '0.000000', PosY = '0.000000', PosZ = '0.000000', IntX = '0.000000', IntY = '0.000000',IntZ = '0.000000',IntID = '0', VID = '0', `Locked` = '0', Mietpreis = '0', Kaufpreis = '0', Gekauft = '0' WHERE ID =", callback: "(null)", format: "(null)"[13:32:48] [DEBUG] CMySQLQuery::Execute[] - starting query executionSET Besitzer = '', Level = '0', PosX = '0.000000', PosY = '0.000000', PosZ = '0.000000', IntX = '0.000000', IntY = '0.000000',IntZ = '0.000000',IntID = '0', VID = '0', `Locked` = '0', Mietpreis = '0', Kaufpreis = '0', Gekauft = '0' WHERE ID =", callback: "(null)", format: "(null)"[13:32:48] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE House SET Besitzer = '', Level = '0', PosX = '0.000000', PosY = '0.000000', PosZ = '0.000000', IntX = '0.000000', IntY = '0.000000',IntZ = '0.000000',IntID = '0', VID = '0', `Locked` = '0', Mietpreis = '0', Kaufpreis = '0', Gekauft = '0' WHERE ID =", callback: "(null)", format: "(null)"[13:32:48] [ERROR] CMySQLQuery::Execute[] - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1[13:32:48] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE House SET Besitzer = '', Level = '0', PosX = '0.000000', PosY = '0.000000', PosZ = '0.000000', IntX = '0.000000', IntY = '0.000000',IntZ = '0.000000',IntID = '0', VID = '0', `Locked` = '0', Mietpreis = '0', Kaufpreis = '0', Gekauft = '0' WHERE ID =", callback: "(null)", format: "(null)"[13:32:48] [DEBUG] CMySQLQuery::Execute[] - error will be triggered in OnQueryError[13:32:48] [DEBUG] Calling callback "OnQueryError"..uery execution[13:32:48] [ERROR] CMySQLQuery::Execute[] - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1[13:32:48] [DEBUG] CMySQLQuery::Execute[] - error will be triggered in OnQueryError[13:32:48] [DEBUG] CMySQLQuery::Execute[] - starting query execution[13:32:48] [DEBUG] Calling callback "OnQueryError"..[13:32:48] [ERROR] CMySQLQuery::Execute[] - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1[13:32:48] [DEBUG] CMySQLQuery::Execute[] - error will be triggered in OnQueryError[13:32:48] [DEBUG] CMySQLQuery::Execute[] - starting query execution[13:32:48] [DEBUG] Calling callback "OnQueryError"..[13:32:48] [ERROR] CMySQLQuery::Execute[] - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1[13:32:48] [DEBUG] CMySQLQuery::Execute[] - error will be triggered in OnQueryError[13:32:48] [DEBUG] CMySQLQuery::Execute[] - starting query execution[13:32:48] [DEBUG] Calling callback "OnQueryError"..[13:32:48] [ERROR] CMySQLQuery::Execute[] - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1[13:32:48] [DEBUG] CMySQLQuery::Execute[] - error will be triggered in OnQueryError[13:32:48] [DEBUG] Calling callback "OnQueryError"..[13:33:25] [DEBUG] mysql_tquery - connection: 1, query: "INSERT INTO House (ID, Besitzer, Level, PosX, PosY, PosZ, IntX,IntY,IntZ, IntID, VID, `Locked`, Mietpreis, Kaufpreis, Gekauft) VALUES ('0','Besitzer: Niemand', '1', '-1975.987670', '149.568283', '36.962287', '1267.663208', '-781.323242', '1091.906250', '5', '1', '0', '0', '1', '0')", callback: "(null)", format: "(null)"[13:33:26] [DEBUG] CMySQLQuery::Execute[] - starting query execution[13:33:26] [ERROR] CMySQLQuery::Execute[] - (error #1062) Duplicate entry '0' for key 'PRIMARY'[13:33:26] [DEBUG] CMySQLQuery::Execute[] - error will be triggered in OnQueryError[13:33:26] [DEBUG] Calling callback "OnQueryError"..[13:33:54] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE House SET Besitzer = 'Besitzer: Niemand', Level = '1', PosX = '-1975.987670', PosY = '149.568283', PosZ = '36.962287', IntX = '1267.663208', IntY = '-781.323242',IntZ = '1091.906250',IntID = '5', VID = '1', `Locked` = '0', Mietpreis = '0', Kaufprei", callback: "(null)", format: "(null)"[13:33:54] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE House SET Besitzer = '', Level = '0', PosX = '0.000000', PosY = '0.000000', PosZ = '0.000000', IntX = '0.000000', IntY = '0.000000',IntZ = '0.000000',IntID = '0', VID = '0', `Locked` = '0', Mietpreis = '0', Kaufpreis = '0', Gekauft = '0' WHERE ID =", callback: "(null)", format: "(null)"[13:33:54] [DEBUG] CMySQLQuery::Execute[] - starting query execution[13:33:54] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE House SET Besitzer = '', Level = '0', PosX = '0.000000', PosY = '0.000000', PosZ = '0.000000', IntX = '0.000000', IntY = '0.000000',IntZ = '0.000000',IntID = '0', VID = '0', `Locked` = '0', Mietpreis = '0', Kaufpreis = '0', Gekauft = '0' WHERE ID =", callback: "(null)", format: "(null)"[13:33:54] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE House SET Besitzer = '', Level = '0', PosX = '0.000000', PosY = '0.000000', PosZ = '0.000000', IntX = '0.000000', IntY = '0.000000',IntZ = '0.000000',IntID = '0', VID = '0', `Locked` = '0', Mietpreis = '0', Kaufpreis = '0', Gekauft = '0' WHERE ID =", callback: "(null)", format: "(null)"[13:33:54] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE House SET Besitzer = '', Level = '0', PosX = '0.000000', PosY = '0.000000', PosZ = '0.000000', IntX = '0.000000', IntY = '0.000000',IntZ = '0.000000',IntID = '0', VID = '0', `Locked` = '0', Mietpreis = '0', Kaufpreis = '0', Gekauft = '0' WHERE ID =", callback: "(null)", format: "(null)"[13:33:54] [DEBUG] CMySQLQuery::Execute[] - starting query execution[13:33:54] [DEBUG] Calling callback "OnQueryError"..[13:33:54] [ERROR] CMySQLQuery::Execute[] - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1[13:33:54] [DEBUG] CMySQLQuery::Execute[] - error will be triggered in OnQueryError[13:33:54] [DEBUG] CMySQLQuery::Execute[] - starting query execution[13:33:54] [DEBUG] Calling callback "OnQueryError"..[13:33:54] [ERROR] CMySQLQuery::Execute[] - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1[13:33:54] [DEBUG] CMySQLQuery::Execute[] - error will be triggered in OnQueryError[13:33:54] [DEBUG] CMySQLQuery::Execute[] - starting query execution[13:33:54] [DEBUG] Calling callback "OnQueryError"..[13:33:54] [ERROR] CMySQLQuery::Execute[] - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1[13:33:54] [DEBUG] CMySQLQuery::Execute[] - error will be triggered in OnQueryError[13:33:54] [DEBUG] CMySQLQuery::Execute[] - starting query execution[13:33:54] [DEBUG] Calling callback "OnQueryError"..[13:33:54] [ERROR] CMySQLQuery::Execute[] - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1[13:33:54] [DEBUG] CMySQLQuery::Execute[] - error will be triggered in OnQueryError[13:33:54] [DEBUG] Calling callback "OnQueryError"..[13:33:55] [DEBUG] mysql_tquery - connection: 1, query: "INSERT INTO House (ID, Besitzer, Level, PosX, PosY, PosZ, IntX,IntY,IntZ, IntID, VID, `Locked`, Mietpreis, Kaufpreis, Gekauft) VALUES ('0','Besitzer: Niemand', '3', '-1972.968627', '150.254165', '36.962287', '1267.663208', '-781.323242', '1091.906250', '5', '2', '0', '0', '4', '0')", callback: "(null)", format: "(null)"[13:33:55] [DEBUG] CMySQLQuery::Execute[] - starting query execution[13:33:55] [ERROR] CMySQLQuery::Execute[] - (error #1062) Duplicate entry '0' for key 'PRIMARY'[13:33:55] [DEBUG] CMySQLQuery::Execute[] - error will be triggered in OnQueryError[13:33:55] [DEBUG] Calling callback "OnQueryError"..
Inhalt anzeigen
Command:
Inhalt anzeigen
ocmd:createhouse(playerid, params[])
{
// if(MAX_HOUSE-1) != 0) return SendClientMessage(playerid, error, "Es können keine weiteren Häuser erstellt werden.");
new Inte, V, hLv, hPreis,text [128];
if(sscanf(params,"dddd",Inte, V, hLv, hPreis))return SendClientMessage(playerid,info,"/Createhouse [IntID] [Virtuelle Welt] [Level] [Preis]");
if(SpielerInfo[playerid][pAdmin] < 5) return SendClientMessage(playerid, error, "Du bist kein Admin!");
for(new i=0; i<MAX_HOUSE; i++)
{
new Float:Pos[3];
GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
hInfo[i][PosX] = Pos[0];
hInfo[i][PosY] = Pos[1];
hInfo[i][PosZ] = Pos[2];
hInfo[i][IntID] = Inte;
hInfo[i][VID] = V;
hInfo[i][Level] = hLv;
hInfo[i][Kaufpreis] = hPreis;
hInfo[i][Mietpreis] = 0;
hInfo[i][Gekauft] = 0;
hInfo[i][Lock] = 0;
switch(Inte)
{
case 5:
{
hInfo[i][IntX] =1267.663208;
hInfo[i][IntY] =-781.323242;
hInfo[i][IntZ] =1091.906250;
}
/*case 1:
{
hInfo[i][IntX] = ;
hInfo[i][IntY] = ;
hInfo[i][IntZ] = ;
}*/
}
format(hInfo[i][Besitzer], 34, "Besitzer: Niemand");
new query[1024];
format(query, sizeof(query), "INSERT INTO House (ID, Besitzer, Level, PosX, PosY, PosZ, IntX,IntY,IntZ, IntID, VID, `Locked`, Mietpreis, Kaufpreis, Gekauft) VALUES ('%d','%s', '%d', '%f', '%f', '%f', '%f', '%f', '%f', '%d', '%d', '%d', '%d', '%d', '%d')",
i, hInfo[i][Besitzer], hInfo[i][Level], hInfo[i][PosX], hInfo[i][PosY], hInfo[i][PosZ], hInfo[i][IntX], hInfo[i][IntY], hInfo[i][IntZ], hInfo[i][IntID], hInfo[i][VID], hInfo[i][Lock], hInfo[i][Mietpreis], hInfo[i][Kaufpreis], hInfo[i][Gekauft], i);
mysql_tquery(handle, query);
CreatePickup(1273,1,Pos[0],Pos[1],Pos[2],0);
format(text, sizeof(text), "Besitzer: Niemand\nPreis: %d\nLevel: %d",hInfo[i][Kaufpreis],hInfo[i][Level]);
Create3DTextLabel(text,0x0FFF00FF,Pos[0],Pos[1],Pos[2],20.0,0,1);
return SendClientMessage(playerid, 0x00FF00FF, "Haus wurde erfolgreich gespeichert.");
}
return 1;
}
Und Save&Load
Inhalt anzeigen
LoadHouse()
{
CreateHouseTable();
mysql_tquery(handle, "SELECT * FROM Hausdaten ORDER BY ID ASC", "LoadHouse_Data");
return 1;
}
forward LoadHouse_Data();
public LoadHouse_Data()
{
new rows;
rows = cache_num_rows();
for(new i=0; i<rows; i++)
{
cache_get_field_content(0, "Besitzer", hInfo[i][Besitzer],handle,34);
hInfo[i][Level] = cache_get_field_content_int(i, "Level");
hInfo[i][PosX] = cache_get_field_content_float(i, "PosX");
hInfo[i][PosY] = cache_get_field_content_float(i, "PosY");
hInfo[i][PosZ] = cache_get_field_content_float(i, "PosZ");
hInfo[i][IntX] = cache_get_field_content_float(i, "IntX");
hInfo[i][IntY] = cache_get_field_content_float(i, "IntY");
hInfo[i][IntZ] = cache_get_field_content_float(i, "IntZ");
hInfo[i][IntID] = cache_get_field_content_int(i, "IntID");
hInfo[i][VID] = cache_get_field_content_int(i, "VID");
hInfo[i][Lock] = cache_get_field_content_int(i, "Locked");
hInfo[i][Mietpreis] = cache_get_field_content_int(i, "Mietpreis");
hInfo[i][Kaufpreis] = cache_get_field_content_int(i, "Kaufpreis");
hInfo[i][Gekauft] = cache_get_field_content_int(i, "Gekauft");
if(i == MAX_HOUSE-1) return print("Es können keine weiteren Häuser geladen werden, Limit wurde erreicht.");
}
return 1;
}
forward SaveAllHouses();
public SaveAllHouses()
{
new query[256];
for(new i=0; i<MAX_HOUSE; i++)
{
format(query, sizeof(query), "UPDATE House SET Besitzer = '%s', Level = '%d', PosX = '%f', PosY = '%f', PosZ = '%f', IntX = '%f', IntY = '%f',IntZ = '%f',IntID = '%d', VID = '%d', `Locked` = '%d', Mietpreis = '%d', Kaufpreis = '%d', Gekauft = '%d' WHERE ID = '%d'",
hInfo[i][Besitzer], hInfo[i][Level], hInfo[i][PosX], hInfo[i][PosY], hInfo[i][PosZ], hInfo[i][IntX], hInfo[i][IntY], hInfo[i][IntZ], hInfo[i][IntID], hInfo[i][VID], hInfo[i][Lock], hInfo[i][Mietpreis], hInfo[i][Kaufpreis], hInfo[i][Gekauft], i);
mysql_tquery(handle, query);
}
return 1;
}
Unter Ongaemodeinit hab ich das mit dem Pickup:
//________________ Haus ______________________
for(new i=0; i<MAX_HOUSE; i++)
{
if(hInfo[i][Gekauft] == 0)
{
new text[128];
format(text, sizeof(text), "Besitzer: Niemand\nPreis: %d\nLevel: %d",hInfo[i][Kaufpreis],hInfo[i][Level]);
Create3DTextLabel(text,0x0FFF00FF,hInfo[i][PosX],hInfo[i][PosY],hInfo[i][PosZ],20.0,0,1);
CreatePickup(1273,1,hInfo[i][PosX],hInfo[i][PosY],hInfo[i][PosZ],1);
}
else if(hInfo[i][Gekauft] == 1)
{
new text[128];
format(text, sizeof(text), "Besitzer: %s\nMiete: %d\nLevel: %d",hInfo[i][Besitzer],hInfo[i][Mietpreis],hInfo[i][Level]);
Create3DTextLabel(text,0xB90000FF,hInfo[i][PosX],hInfo[i][PosY],hInfo[i][PosZ],20.0,0,1);
CreatePickup(1273,1,hInfo[i][PosX],hInfo[i][PosY],hInfo[i][PosZ],1);
}
}
Sorry für die vielen Edits und den Code.
Jeffry: