29.09.2012, 14:01
your insert looks ok, does it work for new players?
your update needs to know where, i usually use id field but can do with name i suppose. here...
your update needs to know where, i usually use id field but can do with name i suppose. here...
Код:
new query[130 + MAX_PLAYER_NAME]; format(query, sizeof(query), "SELECT * FROM aliases WHERE username = '%s'", PlayerName(playerid)); new result = mysql_query(query); if(mysql_num_rows(result) == 0) { new aquery[130 + MAX_PLAYER_NAME]; format(aquery, sizeof(aquery), "INSERT INTO aliases (id, username, ip) VALUES ('0', '%s', '%s')", PlayerName(playerid), PlayerIP(playerid)); mysql_query(aquery); } else { new aquery[130 + MAX_PLAYER_NAME]; format(aquery, sizeof(aquery), "UPDATE aliases SET username = '%s', ip = '%s' WHERE username = '%s'", PlayerName(playerid), PlayerIP(playerid), PlayerName(playerid)); mysql_query(aquery); }