27.04.2018, 09:45
Hey!
Im having a problem with this code
It bans the guy who issued the command either way you turn it. But in MySQL it adds the guy you wanted to ban.
Im having a problem with this code
Quote:
CMD:ban(playerid, params[]) //Ban a Player { new pID, reason[128], string[128], Year, Month, Day; if(pInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_RED, "ERROR: You are not authorized to use this command."); if(sscanf(params, "us[128]", pID, reason)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /ban (Username/ID) (Reason)"); if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, COLOR_RED, "ERROR: Wrong ID or that player is not connected."); SetTimerEx("BanTimer", 10, 0, "d", pID); format(string,sizeof(string), "{33CCFF}[BAN] %s {FFFFFF}has been banned from the server by {33CCFF}%s (%s).", pInfo[pID][pName], pInfo[playerid][pName], reason); SendClientMessageToAll(-1, string); getdate(Year, Month, Day); pInfo[pID][pBanned] = 1; strcpy(pInfo[pID][pBanAdmin], pInfo[playerid][pName], MAX_PLAYER_NAME); pInfo[pID][pBanReason] = reason; pInfo[pID][pBanD] = Day; pInfo[pID][pBanM] = Month; pInfo[pID][pBanY] = Year; new query[256]; mysql_format(Database, query, sizeof(query), "INSERT INTO `banned` (`Username`, `Admin`, `Reason`, `Day`, `Month`, `Year`) VALUES ('%s', '%s', '%s', '%d', '%d', '%d')", pInfo[pID][pName], pInfo[pID][pBanAdmin], pInfo[pID][pBanReason], pInfo[pID][pBanD], pInfo[pID][pBanM], pInfo[pID][pBanY]); mysql_query(Database, query); //Textdraws TextDrawShowForPlayer(playerid, BanBox1); TextDrawShowForPlayer(playerid, BanBox2); TextDrawShowForPlayer(playerid, BanOverview); TextDrawShowForPlayer(playerid, BanAppeal); TextDrawShowForPlayer(playerid, BanBox3); PlayerTextDrawShow(playerid, PlayerName[playerid]); PlayerTextDrawShow(playerid, AdminName[playerid]); PlayerTextDrawShow(playerid, BanReason[playerid]); PlayerTextDrawShow(playerid, BanDate[playerid]); new PlayerNameTextdraw[256], AdminNameTextdraw[256], BanReasonTextdraw[256], BanDateTextdraw[256]; format(PlayerNameTextdraw, sizeof(PlayerNameTextdraw), "Player Name: %s", pInfo[pID][pName]); format(AdminNameTextdraw, sizeof(AdminNameTextdraw), "Admin Name: %s", pInfo[playerid][pName]); format(BanReasonTextdraw, sizeof(BanReasonTextdraw), "Reason: %s", reason); format(BanDateTextdraw, sizeof(BanDateTextdraw), "Date: %d/%d/%d", pInfo[pID][pBanD], pInfo[pID][pBanM], pInfo[pID][pBanY]); PlayerTextDrawSetString(pID, PlayerName[playerid], PlayerNameTextdraw); PlayerTextDrawSetString(pID, AdminName[playerid], AdminNameTextdraw); PlayerTextDrawSetString(pID, BanReason[playerid], BanReasonTextdraw); PlayerTextDrawSetString(pID, BanDate[playerid], BanDateTextdraw); TogglePlayerControllable(playerid, 0); return 1; } |
Quote:
forward BanTimer(pID); public BanTimer(pID) { Kick(pID); } |