Nabend zusammen
Ich habe ein kleines Porblem zu meinen Blitzern
wenn ich den Server starte, dann bekommen die Blitzer eine falsche id und der updatet die Objekt id nicht
hier mal der zum load
stock LoadBlitzer()
{
new Data[1024],idx,query[50],i=0;
mysql_query("SELECT * FROM `Blitzer`");
mysql_store_result();
while(mysql_fetch_row(Data))
{
sscanf(Data, "p<|>iffffd",idx,Blitzer[i][BlitzerX],Blitzer[i][BlitzerY],Blitzer[i][BlitzerZ],Blitzer[i][BlitzerR],Blitzer[i][Geschwindigkeit]);
Blitzer[i][ID] = CreateDynamicObject(18880, Blitzer[i][BlitzerX],Blitzer[i][BlitzerY],Blitzer[i][BlitzerZ], 0.0, 0.0, Blitzer[i][BlitzerR]);
format(query,50,"UPDATE `Blitzer` SET `id` = '%d' WHERE `id` = '%d'",Blitzer[i][ID],idx);
mysql_query(query);
print(query);
i++;
}
mysql_free_result();
printf("\tEs wurden %d Blitzer geladen",i);
return 1;
}
laden tut er nur er hat ein Problem mit der IP zu updaten
Tabellenaufbau:
mysql_query("CREATE TABLE IF NOT EXISTS `Blitzer` (`id` int(11), `X` float(20), `Y` float(20), `Z` float(20), `A` float(20), `Speed` int(11), PRIMARY KEY (`id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
der Debug gibt das aus:
[22:37:55] CMySQLHandler::FetchRow() - Return: 709|-2011.25|473.948|32.9719|1.62654|100
[22:37:55] >> mysql_query( Connection handle: 1 )
[22:37:56] CMySQLHandler::Query(UPDATE `Blitzer` SET `id` = '1' WHERE `id` = '709) - An error has occured. (Error ID: 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 ''709' at line 1)
[22:37:56] >> mysql_fetch_row_format( Connection handle: 1 )
[22:37:56] CMySQLHandler::FetchRow() - Return: 710|-1566.06|701.528|4.9875|358.291|120
[22:37:56] >> mysql_query( Connection handle: 1 )
[22:37:56] CMySQLHandler::Query(UPDATE `Blitzer` SET `id` = '2' WHERE `id` = '710) - An error has occured. (Error ID: 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 ''710' at line 1)
[22:37:56] >> mysql_fetch_row_format( Connection handle: 1 )
[22:37:56] CMySQLHandler::FetchRow() - Return: 711|-1792.72|-103.767|3.69155|184.734|120
[22:37:56] >> mysql_query( Connection handle: 1 )
[22:37:56] CMySQLHandler::Query(UPDATE `Blitzer` SET `id` = '3' WHERE `id` = '711) - An error has occured. (Error ID: 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 ''711' at line 1)
[22:37:56] >> mysql_fetch_row_format( Connection handle: 1 )
[22:37:56] CMySQLHandler::FetchRow() - An error has occured. (Error ID: 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 ''711' at line 1)
[22:37:56] >> mysql_free_result( Connection handle: 1 )
[22:37:56] CMySQLHandler::FreeResult() - Result was successfully free'd.
Alles anzeigen
Ich kann mir den fehler nicht erklären, da die ATM´s/Bäume etc auch so geladen werden
ich hoffe, das einer eine idee dazu hat.
erstellen tu ich die so:
stock AddBlitzer(playerid,speed)
{
new Float:x, Float:y, Float:z, Float:a, query[128];
GetPlayerPos(playerid,x,y,z);
GetPlayerFacingAngle(playerid,a);
for(new i = 0; i < sizeof(Blitzer); i++)
{
if(Blitzer[i][Erstellt] == 0)
{
Blitzer[i][BlitzerX] = x + 1.0;
Blitzer[i][BlitzerY] = y + 1.0;
Blitzer[i][BlitzerZ] = z - 2.2;
Blitzer[i][BlitzerR] = a;
Blitzer[i][Geschwindigkeit] = speed;
Blitzer[i][Radius] = 20;
Blitzer[i][Erstellt] = 1;
Blitzer[i][ID] = CreateDynamicObject(18880, x, y, z - 2.2, 0.0, 0.0, a-180.0);
SendClientMessage(playerid, 0xffffffff, "Blitzer erstellt");
format(query, sizeof(query), "INSERT INTO Blitzer (id, X, Y, Z, A, Speed) VALUES ('%d', '%f', '%f', '%f', '%f', '%d')", Blitzer[i][ID],Blitzer[i][BlitzerX],Blitzer[i][BlitzerY],Blitzer[i][BlitzerZ],Blitzer[i][BlitzerR],Blitzer[i][Geschwindigkeit]);
mysql_query(query);
mysql_free_result();
return 1;
}
}
return 0;
}
Ahja bevor ich es vergesse, die Objekte stehen zwar da aber die Blitzer funktionieren nicht