SA-MP Forums Archive
Car remont. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Car remont. (/showthread.php?tid=302946)



Car remont. - budelis - 11.12.2011

Hi visitors,i have on question,with that code:

Код:
stock IsRemont(playerid)
{
new Query [ 100 ];
format( Query,sizeof( Query ),"SELECT * FROM `RemontCars` WHERE `Owner` = '%s'",PlayerName(playerid));
mysql_query( Query );
mysql_store_result( );
if( mysql_num_rows( )==0 )
{
PlayerData[ playerid ][ Remont] = 0;
}
else if(mysql_num_rows( ) !=0 )
{
PlayerData[ playerid ][ Remont] = 1;
}
mysql_free_result( );
}
And then after onplayerdisconnect:

Код:
IsRemont(playerid);
format(Query, sizeof(Query),"UPDATE `playerdata` SET `Remont` = '%d' WHERE `Name` = '%s'",PlayerData[playerid][Remont],PlayerName(playerid));
mysql_query(Query);
What i want to do here?I want to do,if player car need remont,then it will save 1 other 0. All is good,all save,but when i load it:

Код:
mysql_fetch_field_row( savingstring, "Remont"); PlayerData[ playerid ][ Remont] = strval(savingstring);
And it no load.I check log,and i see that:

Код:
[10:19:52] >> mysql_fetch_field_row( Connection handle: 1 )

[10:19:52] CMySQLHandler::FetchField("Remont") -
How you see,here is no number...


Re: Car remont. - Lorenc_ - 11.12.2011

If "`Remont` = '%d'" is not meant to be a string then make it "`Remont` = %d"


Re: Car remont. - budelis - 11.12.2011

Fixed. Anyway thanks for try helping.Now other problem with mysql formating:

format(QueryS, sizeof(QueryS),"SELECT * FROM RemontCars WHERE Owner= '%s'",PlayerName(playerid));

And i get error in log:

Код:
[11:30:11] CMySQLHandler::Query(SELECT * FROM RemontCars WHERE Owner` = 'Nestea') - 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 '` = 'Nestea'' at line 1)



Re: Car remont. - Dark_Kostas - 11.12.2011

Quote:
Originally Posted by budelis
Посмотреть сообщение
Fixed. Anyway thanks for try helping.Now other problem with mysql formating:

format(QueryS, sizeof(QueryS),"SELECT * FROM RemontCars WHERE Owner= '%s'",PlayerName(playerid));

And i get error in log:

Код:
[11:30:11] CMySQLHandler::Query(SELECT * FROM RemontCars WHERE Owner` = 'Nestea') - 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 '` = 'Nestea'' at line 1)
Shouldn't the RemontCars be between ' and ' as its string? I don't know much about sql but i guess this is the mistake.

format(QueryS, sizeof(QueryS),"SELECT * FROM 'RemontCars' WHERE Owner= '%s'",PlayerName(playerid));