08.08.2017, 21:21
(
Последний раз редактировалось vdraco; 08.08.2017 в 23:43.
)
I have been converting an old script to R33, and will from there upgrade to R40 later on. Currently I am planning to use R33 (in regards to BlueG's MySQL plugin).
I now want to convert my script, exactly as described here: https://sampforum.blast.hk/showthread.php?tid=544437 - I don't know how to convert this part of the code. I am now having the same solution as the dude has, but I am not sure if it is correct.
I have the exact same question, there is nothing to add, however no one replied ever to this dude. If anyone have a solution on that, it would be awesome
EDIT:
That is the old code, I converted it to:
I am calling it in the command cmd
fine by using:
mysql_tquery(g_MySQLConnections, query, "OnQueryFinish", "ii", THREAD_OFFLINE_FINE, playerid);
It was apparently actually different, looked at the wrong script. Updated the main thread as well. It was actually different than the question I linked to.
I now want to convert my script, exactly as described here: https://sampforum.blast.hk/showthread.php?tid=544437 - I don't know how to convert this part of the code. I am now having the same solution as the dude has, but I am not sure if it is correct.
I have the exact same question, there is nothing to add, however no one replied ever to this dude. If anyone have a solution on that, it would be awesome

EDIT:
Код:
public OnQueryFinish(query[], resultid, extraid, connectionHandle) { // a lot of threads and stuff. // ..... case THREAD_OFFLINE_FINE: { mysql_store_result(g_MySQLConnections); new szMessage[128], szPlayerIP[20], iPlayerAdminLevel, iPlayerBanned, szReason[128], iPlayerPermabanned, iCash, iBankAccount, iFinedAmount, szPlayerName[MAX_PLAYER_NAME], szResult[256], iTotalCashAfterFine; if(mysql_fetch_row_format(szResult, "|", g_MySQLConnections)) { sscanf(szResult, "p<|>dddssdd", iPlayerPermabanned, iPlayerBanned, iPlayerAdminLevel, szPlayerName, szPlayerIP, iBankAccount, iCash); if(iPlayerPermabanned > 0) return SendClientMessage(extraid, COLOR_GREY, "The specified player is permanently banned."); if(iPlayerAdminLevel > 0) return SendClientMessage(extraid, COLOR_GREY, "You can't fine other administrators."); GetPVarString(extraid, "ofinereason", szReason, sizeof(szReason)); mysql_real_escape_string(szReason, szReason, g_MySQLConnections); iFinedAmount = GetPVarInt(extraid, "ofineamount"); iTotalCashAfterFine = iCash - iFinedAmount; format(szQuery, sizeof(szQuery), "UPDATE players SET Cash = %d WHERE Username = '%s'", iTotalCashAfterFine, szPlayerName); mysql_query(szQuery, THREAD_NO_RESULT, extraid, g_MySQLConnections); format(szMessage, sizeof(szMessage), "AdmCmd: %s was offline fined $%d by %s, reason: %s", szPlayerName, iFinedAmount, GetPlayerNameEx(extraid), szReason); Log("logs/admin.log", szMessage); format(szMessage, sizeof(szMessage), "AdmCmd: %s was offline fined $%d by %s, reason: %s", szPlayerName, iFinedAmount, GetPlayerNameEx(extraid), szReason); ABroadCast(COLOR_LIGHTRED,szMessage,1); } else SendClientMessage(extraid, COLOR_GREY, "The player specified does not exist."); mysql_free_result(g_MySQLConnections); } }
Код:
// under OnQueryFinish method case THREAD_OFFLINE_FINE: { new szMessage[128], szPlayerIP[20], iPlayerAdminLevel, iPlayerBanned, szReason[128], iPlayerPermabanned, iCash, iBankAccount, iFinedAmount, szPlayerName[MAX_PLAYER_NAME], szResult[256], iTotalCashAfterFine, rows, fields; cache_get_data(rows, fields); if(rows) { cache_get_field_content(0, "PermaBanned", iPlayerPermaBanned); cache_get_field_content(0, "Banned", iPlayerBanned); cache_get_field_content(0, "AdminLevel", iPlayerAdminLevel); cache_get_field_content(0, "Username", szPlayerName); cache_get_field_content(0, "LastIP", szPlayerIP); cache_get_field_Content(0, "Bank", iBankAccount); cache_get_field_content(0, "Cash", iCash); if(iPlayerPermabanned > 0) return SendClientMessage(extraid, COLOR_GREY, "The specified player is permanently banned."); if(iPlayerAdminLevel > 0) return SendClientMessage(extraid, COLOR_GREY, "You can't fine other administrators."); GetPVarString(extraid, "ofinereason", szReason, sizeof(szReason)); mysql_escape_string(szReason, szReason, g_MySQLConnections); iFinedAmount = GetPVarInt(extraid, "ofineamount"); iTotalCashAfterFine = iCash - iFinedAmount; format(szQuery, sizeof(szQuery), "UPDATE players SET Cash = %d WHERE Username = '%s'", iTotalCashAfterFine, szPlayerName); mysql_tquery(g_MySQLConnections, szQuery, "OnQueryFinish", "ii", THREAD_NO_RESULT, extraid); format(szMessage, sizeof(szMessage), "AdmCmd: %s was offline fined $%d by %s, reason: %s", szPlayerName, iFinedAmount, GetPlayerNameEx(extraid), szReason); Log("logs/admin.log", szMessage); format(szMessage, sizeof(szMessage), "AdmCmd: %s was offline fined $%d by %s, reason: %s", szPlayerName, iFinedAmount, GetPlayerNameEx(extraid), szReason); ABroadCast(COLOR_LIGHTRED,szMessage,1); } else SendClientMessage(extraid, COLOR_GREY, "The player specified does not exist."); }

mysql_tquery(g_MySQLConnections, query, "OnQueryFinish", "ii", THREAD_OFFLINE_FINE, playerid);
It was apparently actually different, looked at the wrong script. Updated the main thread as well. It was actually different than the question I linked to.