01.09.2018, 09:20
Quote:
|
When passing a string in a SQL query without apostrophes around, it will result in syntax error.
The important question however is why do you execute a DELETE query every time you want to insert a new achievement for a player and save all achievements at once. When a player connects, you know what achievements they have and when a new achievement is rewarded to them, you know its AchID too. One INSERT query is more than enough. There are two more things I want to mention. You only select based on player's name when they connect to find out if they are registered. From this point on, you should have stored the account ID (from auto increment when they registered) and use THIS as reference to the player. The last thing is duplicates. You know AccountID therefore you know the name of the player too. Is there a specific reason you store both account ID and user name at the achievements table? What if a player wants to change their in-game name? Will you update every single table that happens to store the username for not apparent reason? More work for you, honestly. |
Код:
SaveAchievements(playerid)
{
new _query[74];
for(new i; i<sizeof(AchievementInfo); i++)
{
if(pAch[playerid][E_PlayerAchievements:i])
{
mysql_format(handle, _query, sizeof(_query), "INSERT INTO `Achievements` (`AchID`) VALUES (%d)", i);
mysql_tquery(handle, _query);
}
}
return 1;
}


