13.02.2015, 17:52
Hey,
I've been trying to upgrade from MySQL R5 to R33. I had a function which checks if the player is banned using their name or their IP. But I have tried a few time converting it to MySQL R33 but I can't seem to get it to work.
Here is the original R5 version:
Thanks,
FunnyBear
I've been trying to upgrade from MySQL R5 to R33. I had a function which checks if the player is banned using their name or their IP. But I have tried a few time converting it to MySQL R33 but I can't seem to get it to work.
Here is the original R5 version:
pawn Код:
stock CheckBan(playerid)
{
new query[900], bExpiration, bID, IP[16];
GetPlayerIp(playerid, IP, sizeof(IP));
format(query,sizeof(query),"SELECT * FROM bans WHERE (Name = '%s' OR IP = '%s') AND Status = '1'", GetName(playerid), IP );
mysql_query(query);
///////////////////////////////////////////////
new query446[400], pname[24], savingstring[20];
GetPlayerName(playerid, pname, 24);
format(query446, sizeof(query446), "SELECT * FROM playerdata WHERE user = '%s'", pname);
mysql_query(query446);
while(mysql_fetch_row_format(query446,"|"))
{
mysql_fetch_field_row(savingstring, "pScore"); SetPlayerScore(playerid, strval(savingstring));
mysql_fetch_field_row(savingstring, "pMoney"); GivePlayerMoney(playerid, strval(savingstring));
}
//////////////////////////////////////////////
mysql_store_result();
if(mysql_num_rows() >= 1)
{
new bReason[128], bannedBy[MAX_PLAYER_NAME], Name[MAX_PLAYER_NAME], Dialog[900], IP1[16];
while(mysql_fetch_row_format(query,"|"))
{
mysql_fetch_field_row(Name, "Name");
mysql_fetch_field_row(bReason, "Reason");
mysql_fetch_field_row(bannedBy, "BannedBy");
mysql_fetch_field_row(IP1, "IP");
mysql_fetch_field_row(query, "BanID"); bID = strval(query);
mysql_fetch_field_row(query, "Expiration"); bExpiration = strval(query);
if(bExpiration > 0)
{
if(gettime() >= bExpiration)
{
format(query, sizeof(query), "UPDATE bans SET Status = 0 WHERE BanID = '%d'", bID);
mysql_query(query);
}
else
{
format(Dialog, sizeof(Dialog), "{FF0000}You are banned from this server! Ban details:\n\n{FF0000}Name:{FFFFFF} %s \n{FF0000}IP:{FFFFFF} %s\n{FF0000}Reason:{FFFFFF} %s \n{FF0000}Banned By:{FFFFFF} %s\n\n{FF0000}You will be unbanned in %d day(s)!\n\n{FF0000}If you think this ban is unfair, you can apply for an unban appeal at our forums\n{FF0000}Note - We do not unban hackers, or people who lie in their appeal", Name, IP1, bReason, bannedBy, (bExpiration-gettime()+86400)/86400);
ShowPlayerDialog(playerid, DIALOG_BAN, DIALOG_STYLE_MSGBOX, "{FF0000}Banned!", Dialog, "Close", "");
}
}
else
{
format(Dialog, sizeof(Dialog), "{FF0000}You are banned from this server! Ban details:\n\n{FF0000}Name:{FFFFFF} %s \n{FF0000}IP:{FFFFFF} %s\n{FF0000}Reason:{FFFFFF} %s \n{FF0000}Banned By:{FFFFFF} %s\n\n{FF0000}You are banned forever!\n\n{FF0000}If you think this ban is unfair, you can apply for an unban appeal at our forums\n{FF0000}Note - We do not unban hackers, or people who lie in their appeal", Name, IP1, bReason, bannedBy);
ShowPlayerDialog(playerid, DIALOG_BAN, DIALOG_STYLE_MSGBOX, "{FF0000}Banned!", Dialog, "Close", "");
}
}
return 1;
}
mysql_free_result();
return 0;
}
FunnyBear