diff --git a/API b/API index 4c80744..0a7a2a2 100755 Binary files a/API and b/API differ diff --git a/source/main.cpp b/source/main.cpp index ca3cd42..df93939 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -179,16 +179,27 @@ void *db_write_thread(void *arg) { if (packet.message_type == ACSP_LAP_COMPLETED) { printf("[+] Lap completed by (%d).\n", packet.cars_colided[0]); - const char *get_rank_query = "UPDATE users SET user_rank = user_rank + 20 WHERE driver_guid = $1;"; + const char *get_rank_query = "UPDATE users SET user_rank = user_rank + $1 WHERE driver_guid = $2;"; const char *driver_guid = packet.cars[packet.cars_colided[0]].driver_GUID; - const char *get_rank_paramValues[1] = {driver_guid}; + + char rank_buf[32]; - PGresult *rank_res = PQexecParams(conn, get_rank_query, 1, nullptr, get_rank_paramValues, nullptr, nullptr, 0); +// snprintf(rank_buf, sizeof(rank_buf), "%d", +// (packet.cars[packet.cars_colided[0]].total_laps_completed + 1) +// / (packet.cars[packet.cars_colided[0]].cuts + 1) * 10 +// ); + + const char *get_rank_paramValues[2]; + get_rank_paramValues[0] = "10"; + get_rank_paramValues[1] = driver_guid; + + + PGresult *rank_res = PQexecParams(conn, get_rank_query, 2, nullptr, get_rank_paramValues, nullptr, nullptr, 0); if (PQresultStatus(rank_res) != PGRES_TUPLES_OK) { printf("[!] Failed to UPDATE driver Rank for GUID %s: %s", driver_guid, PQerrorMessage(conn)); } else { - printf("[+] Increase driver rank +20\n"); + printf("[+] Increase driver rank\n"); } }