01.11.2014, 21:31
Yesterday I decided to update my game mode from BlueG's R5 or R6 (can't remember) to the latest one.
I had to re-do most of the stuff and some functions and techniques had to be re-written from scratch (removing mysql_store_result and mysql_free_result, adapting the cache method and using mysql_tquery, forwarding different callbacks for it and etc...)
I've redone the whole save system and re-named most of the functions but after I started fixing up errors I've come to this problem:
I don't know how to re-write a snippet where the script uses the old function mysql_fetch_row_format.
This is the code:
Now as the new method and plugin the function mysql_fetch_row_format doesn't exist and I didn't find any replacement function for it (that probably starts with cache_*).
My question is how do I re-write the lines (that has a comment in the end of it) to fit the current version of BlueG's mysql plugin?
Thanks for the helpers!
EDIT:
I've tried to make a solution can you tell me if it will have the same affect as the old snippet?
I had to re-do most of the stuff and some functions and techniques had to be re-written from scratch (removing mysql_store_result and mysql_free_result, adapting the cache method and using mysql_tquery, forwarding different callbacks for it and etc...)
I've redone the whole save system and re-named most of the functions but after I started fixing up errors I've come to this problem:
I don't know how to re-write a snippet where the script uses the old function mysql_fetch_row_format.
This is the code:
pawn Code:
// Somewhere up there in the script:
format(string, sizeof(string), "SELECT Banned, Warnings, LastIP, Username FROM players WHERE Username = '%s'", szPlayerName);
mysql_tquery(gMySQLConnection, string, "OnPlayerCheckBannedAccount", "i", playerid);
pawn Code:
// Somewhere down there in the script:
forward OnPlayerCheckBannedAccount(playerid);
public OnPlayerCheckBannedAccount(playerid)
{
new
szResult[128],
szMessage[128],
szPlayerIP[20],
szPlayerName[MAX_PLAYER_NAME],
iPlayerBan,
iPlayerWarnings;
if(mysql_fetch_row_format(szResult, "|", gMySQLConnection)) { // NEEDS TO BE RE-WRITTEN
sscanf(szResult, "p<|>dds[16]s[20]", iPlayerBan, iPlayerWarnings, szPlayerIP, szPlayerName); // NEEDS TO BE RE-WRITTEN
if(iPlayerBan > 0) {
RemoveBan(szPlayerIP);
format(szMessage, sizeof(szMessage), "(( AdmCmd )) %s (IP: %s) was unbanned by %s.", szPlayerName, szPlayerIP, GetPlayerNameEx(playerid));
ABroadCast(COLOR_LIGHTRED, szMessage, 1);
if(iPlayerWarnings >= 3){
format(szQuery, sizeof(szQuery), "UPDATE players SET Banned = 0, Warnings = 0 WHERE Username = '%s'", szPlayerName);
}
else format(szQuery, sizeof(szQuery), "UPDATE players SET Banned = 0 WHERE Username = '%s'", szPlayerName);
mysql_query(gMySQLConnection, szQuery);
}
else SendClientMessage(playerid, COLOR_GREY, "The player specified isn't banned.");
}
else SendClientMessage(playerid, COLOR_GREY, "No rows exist with the criteria specified.");
return 1;
}
My question is how do I re-write the lines (that has a comment in the end of it) to fit the current version of BlueG's mysql plugin?
Thanks for the helpers!
EDIT:
I've tried to make a solution can you tell me if it will have the same affect as the old snippet?
pawn Code:
forward OnPlayerCheckBannedAccount(playerid);
public OnPlayerCheckBannedAccount(playerid)
{
new
szResult[128],
szMessage[128],
szPlayerIP[20],
szPlayerName[MAX_PLAYER_NAME],
iPlayerBan,
iPlayerWarnings,
rows, fields;
cache_get_data(rows, fields, gMySQLConnection);
if(rows) {
iPlayerBan = cache_get_field_content_int(0, "Banned", gMySQLConnection);
iPlayerWarnings = cache_get_field_content_int(0, "Warnings", gMySQLConnection);
cache_get_field_content(0, "LastIP", szPlayerIP, gMySQLConnection);
cache_get_field_content(0, "Username", szPlayername, gMySQLConnection);
if(iPlayerBan > 0)
{
RemoveBan(szPlayerIP);
format(szMessage, sizeof(szMessage), "(( AdmCmd )) %s (IP: %s) was unbanned by %s.", szPlayerName, szPlayerIP, GetPlayerNameEx(playerid));
ABroadCast(COLOR_LIGHTRED, szMessage, 1);
//format(szMessage, sizeof(szMessage), "AdmCmd: %s (IP: %s) was unbanned by %s.", szPlayerName, szPlayerIP, GetPlayerNameEx(playerid));
//Log("logs/ban.log", szMessage);
if(iPlayerWarnings >= 3){
format(szQuery, sizeof(szQuery), "UPDATE players SET Banned = 0, Warnings = 0 WHERE Username = '%s'", szPlayerName);
}
else format(szQuery, sizeof(szQuery), "UPDATE players SET Banned = 0 WHERE Username = '%s'", szPlayerName);
mysql_query(gMySQLConnection, szQuery);
}
else SendClientMessage(playerid, COLOR_GREY, "The player specified isn't banned.");
}
else SendClientMessage(playerid, COLOR_GREY, "No rows exist with the criteria specified.");
return 1;
}