jlalt

banlatest

Nov 27th, 2015
858
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 25.72 KB | None | 0 0
  1. #include a_samp
  2. #include a_mysql
  3. #include zcmd
  4.  
  5. #define red          0xFF0000AA
  6. #define COLOR_Silver 0xCACACAAA
  7.  
  8. //==================================News======================================//
  9. new offlineb[MAX_PLAYERS],
  10.     banned[MAX_PLAYERS],
  11.     whatunbanip[32],
  12.     banreason[128],
  13.     whatbanip[32],
  14.     totalbans,
  15.     totalip,
  16.     mysql
  17. ;
  18. //====================================Forwards================================//
  19. forward BanCheck(playerid);
  20. forward BanIPCheck(playerid);
  21. forward kickplayer(playerid);
  22. forward Unban(playerid);
  23. forward Unbanip(playerid);
  24. forward Banip(playerid);
  25. forward Baninfo(playerid);
  26. forward DBaninfo(playerid);
  27. forward offlineban(playerid,reason[]);
  28. forward TotalBans();
  29. forward TotalBans1();
  30. forward Totalbanips();
  31. //============================================================================//
  32.  
  33. public OnFilterScriptInit()
  34. {
  35.     mysql_log(LOG_ERROR | LOG_WARNING | LOG_DEBUG);
  36.     mysql = mysql_connect("HOST", "USER_NAME", "DATABASE", "PASSWORD");
  37.     if(mysql_errno(mysql) != 0)
  38.     {
  39.          print("Could not connect to database!");
  40.     }
  41.     else
  42.     {
  43.         print("Successfully connected on DB ");
  44.         new Query[250];
  45.         format(Query,sizeof(Query),"CREATE TABLE IF NOT EXISTS banneds(name VARCHAR(128), ip VARCHAR(128), date VARCHAR(128), time VARCHAR(128)\
  46.         ,bannedby VARCHAR(128), banned INT(10), reason VARCHAR(128), bdate VARCHAR(128), tempban INT(10) )");
  47.         mysql_tquery(mysql, Query, "", "");
  48.         format(Query,sizeof(Query),"CREATE TABLE IF NOT EXISTS bannedips(ip VARCHAR(128) )");
  49.         mysql_tquery(mysql, Query, "", "");
  50.         mysql_format(mysql, Query, sizeof(Query),"SELECT * FROM `banneds` WHERE `banned` = 1");
  51.         mysql_tquery(mysql, Query, "TotalBans", "");
  52.         mysql_format(mysql, Query, sizeof(Query),"SELECT * FROM `banneds` WHERE `tempban` = 1");
  53.         mysql_tquery(mysql, Query, "Totalbans1", "");
  54.         mysql_format(mysql, Query, sizeof(Query),"SELECT * FROM `bannedips`");
  55.         mysql_tquery(mysql, Query, "Totalbanips", "");
  56.     }
  57.     return 1;
  58. }
  59.  
  60. public TotalBans() {
  61.    new rows, fields;
  62.    cache_get_data(rows, fields, mysql);
  63.    if(rows) {
  64.       totalbans += rows;
  65.   }
  66. }
  67.  
  68. public TotalBans1() {
  69.    new rows, fields;
  70.    cache_get_data(rows, fields, mysql);
  71.    if(rows) {
  72.       totalbans += rows;
  73.   }
  74. }
  75.  
  76. public Totalbanips() {
  77.    new rows, fields;
  78.    cache_get_data(rows, fields, mysql);
  79.    if(rows) {
  80.       totalip += rows;
  81.   }
  82. }
  83. public OnFilterScriptExit() {
  84.     mysql_close();
  85. }
  86.  
  87. public OnPlayerConnect(playerid) {
  88.     banned[playerid] = 0;
  89.     new Query[250];
  90.  
  91.     mysql_format(mysql, Query, sizeof(Query),"SELECT * FROM `banneds` WHERE `name` = '%e' LIMIT 1", pName(playerid));
  92.     mysql_tquery(mysql, Query, "BanCheck", "i", playerid);
  93.     return 1;
  94.  }
  95.  
  96. CMD:ban(playerid,params[]) {
  97.     if(IsPlayerAdmin(playerid)) {
  98.             new strdate[128],strtime[128], tmp[256], tmp2[256], Index;      tmp = strtok(params,Index), tmp2 = strtok(params,Index);
  99.             if(!strlen(params)) return SendClientMessage(playerid, 0xDC143CAA, "USAGE: /ban [playerid] [reason]");
  100.             if(!strlen(tmp2)) return SendClientMessage(playerid, 0xDC143CAA, "ERROR: You must give a reason");
  101.             new player1, ip[128], string[128];
  102.             player1 = strval(tmp);
  103.             if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID && player1 != playerid && !IsPlayerAdmin(player1)) {
  104.                 GetPlayerIp(playerid,ip,sizeof(ip));
  105.                 new year,month,day,hour,minuite,second; getdate(year, month, day); gettime(hour,minuite,second);
  106.                 format(string,sizeof(string),"|- %s has been banned by Administrator %s [Reason: %s] [Date: %d/%d/%d] [Time: %d:%d] -|",pName(player1),pName(playerid),params[2],day,month,year,hour,minuite);
  107.                 SendClientMessageToAll(COLOR_Silver,string);
  108.                 print(string);
  109.  
  110.                 format(strdate, sizeof(strdate), "%d-%d-%d ",year,month,day);
  111.                 format(strtime,sizeof(strtime),"%d:%d:%d",hour,minuite,second);
  112.                 new Query[250];
  113.  
  114.                 format(Query, sizeof(Query), "UPDATE `banneds` SET `ip` = '%s', `date` = '%s', `time` = '%s', `bannedby` = '%s', `banned` = '%d', `reason` = '%s' WHERE `name` = '%s'", ip,strdate,strtime,pName(playerid),1,params[2],pName(playerid));
  115.                 mysql_tquery(mysql, Query, "", ""); totalbans ++;
  116.                 format(Query, sizeof(Query),"INSERT INTO `bannedips`(`ip`) VALUES ('%s')",ip);
  117.                 mysql_tquery(mysql, Query, "", ""); totalip ++;
  118.                 return SetTimerEx("kickplayer", 500, false, "i", tmp);
  119.             } else return SendClientMessage(playerid, 0xDC143CAA, "Player is not connected or is yourself or is the highest level admin");
  120.     } else return SendClientMessage(playerid,0xDC143CAA,"ERROR: You are not a high enough level to use this command");
  121. }
  122. CMD:tempban(playerid,params[]) {
  123.     if(IsPlayerAdmin(playerid)) {
  124.             new strdate[128],strtime[128], player1w[128], reason[128], byearw[128],bmonthw[128],bdayw[128], Index; player1w = strtok(params,Index), reason = strtok(params,Index); byearw = strtok(params,Index), bmonthw = strtok(params,Index), bdayw = strtok(params,Index);
  125.             if(!strlen(player1w)) {
  126.             SendClientMessage(playerid, 0xDC143CAA, "USAGE: /tempban [playerid] [reason] [years months days]");
  127.             return SendClientMessage(playerid, 0xFF9900AA, "Example: /tempban 1 example 0 0 6 [ player will be banned for six days ]");
  128.             }
  129.             if(!strlen(reason)) return SendClientMessage(playerid, red, "ERROR: You must give a reason");
  130.  
  131.             if(!strlen(byearw)) return SendClientMessage(playerid, red, "ERROR: You must give a year");
  132.             if(!strlen(bmonthw)) return SendClientMessage(playerid, red, "ERROR: You must give a month");
  133.             if(!strlen(bdayw)) return SendClientMessage(playerid, red, "ERROR: You must give a day");
  134.            
  135.             new player1n,byearn,bmonthn,bdayn,ip[128], string[150];
  136.             player1n = strval(player1w); byearn = strval(byearw); bmonthn = strval(bmonthw); bdayn = strval(bdayw);
  137.            
  138.             if(IsPlayerConnected(player1n) && player1n != INVALID_PLAYER_ID) {
  139.                 GetPlayerIp(playerid,ip,sizeof(ip));
  140.                 new year,month,day,hour,minuite,second; getdate(year, month, day); gettime(hour,minuite,second);
  141.                 format(string,sizeof(string),"|- %s has been temporary banned by Administrator %s [Reason: %s] [Date: %d/%d/%d] [Time: %d:%d] -|",pName(player1n),pName(playerid),params[2],day,month,year,hour,minuite);
  142.                 SendClientMessageToAll(COLOR_Silver,string);
  143.                 print(string);
  144.                 format(strdate, sizeof(strdate), "%d-%d-%d ",year,month,day);
  145.                 format(strtime,sizeof(strtime),"%d:%d:%d",hour,minuite,second);
  146.                 new tempbandate[3],bandate[128];
  147.                 tempbandate[0] = year+byearn; tempbandate[1] = month+bmonthn; tempbandate[2] = day+bdayn;
  148.                 format(bandate,sizeof bandate,"%d-%d-%d",tempbandate[0],tempbandate[1],tempbandate[2]);
  149.                 new Query[250];
  150.  
  151.                 format(Query, sizeof(Query), "UPDATE `banneds` SET `ip` = '%s', `date` = '%s', `time` = '%s', `bannedby` = '%s', `tempban` = '%d', `reason` = '%s', `bdate` = '%s' WHERE `name` = '%s'", ip,strdate,strtime,pName(playerid),1,params[2],bandate,pName(player1n));
  152.                 mysql_tquery(mysql, Query, "", ""); printf("%s",Query); totalbans ++;
  153.                 format(Query, sizeof(Query),"INSERT INTO `bannedips`(`ip`) VALUES ('%s')",ip);
  154.                 mysql_tquery(mysql, Query, "", ""); totalip ++;
  155.  
  156.                 return SetTimerEx("kickplayer", 500, false, "i", player1n);
  157.             } else return SendClientMessage(playerid, 0xDC143CAA, "Player is not connected or is yourself or is the highest level admin");
  158.     } else return SendClientMessage(playerid,0xDC143CAA,"ERROR: You are not a high enough level to use this command");
  159. }
  160. CMD:unban(playerid,params[]) {
  161.      if(IsPlayerAdmin(playerid)) {
  162.      if(isnull(params)) return SendClientMessage(playerid,0xDC143CAA,"Usage: /unban [playername]");
  163.      new Query[250];
  164.      format(Query, sizeof(Query), "SELECT * FROM banneds WHERE `name` = '%s'", params);
  165.      mysql_tquery(mysql, Query, "Unban", "i", playerid);
  166.      } else return SendClientMessage(playerid,0xDC143CAA,"ERROR: You are not a high enough level to use this command");
  167.      return 1;
  168. }
  169. CMD:banlist(playerid,params[]) {
  170.   if(IsPlayerAdmin(playerid)) {
  171.     new string[200];
  172.     format(string,sizeof(string),"{33FF33}Total {FF0000}Banned {33FF33}Players: %d\n{33FF33}Total {FF0000}Banned {33FF33}Ips: %d\nType Name in below form to check ban Information",totalbans,totalip);
  173.     ShowPlayerDialog(playerid, 2648, DIALOG_STYLE_INPUT, "{FF0000}Banned {33FF33}Players List", string, "Search", "Close");
  174.     } else return SendClientMessage(playerid,0xDC143CAA,"ERROR: You are not a high enough level to use this command");
  175.   return 1;
  176. }
  177. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
  178.   if(dialogid == 2648) {
  179.     if(response == 1) {
  180.      new string[200];
  181.      format(string,sizeof(string),"{33FF33}Total {FF0000}Banned {33FF33}Players: %d\n{33FF33}Total {FF0000}Banned {33FF33}Ips: %d\nType Name in below form to check ban Information",totalbans,totalip);
  182.      if(!strlen(inputtext)) return ShowPlayerDialog(playerid, 2648, DIALOG_STYLE_INPUT, "{FF0000}Banned {33FF33}Players List", string, "Search", "Close");
  183.      new Query[128];
  184.      format(Query, sizeof(Query), "SELECT * FROM banneds WHERE `name` = '%s'", inputtext);
  185.      mysql_tquery(mysql, Query, "DBaninfo", "i", playerid);
  186.     } if(response == 0) {
  187.     SendClientMessage(playerid,0xFF0000AA,"Ban BOT: {33FF33}You have Closed Dialog Ban List");
  188.     }
  189.   }
  190.   return 0;
  191. }
  192. CMD:unbanip(playerid,params[]) {
  193.    if(IsPlayerAdmin(playerid)) {
  194.      if(isnull(params)) return SendClientMessage(playerid,0xDC143CAA,"Usage: /unbanip [ip]");
  195.      new size; size = strval(params);
  196.      if(size > 10 && size < 30) {
  197.      new Query[250];
  198.      format(Query, sizeof(Query), "SELECT * FROM bannedips WHERE `ip` = '%s'", params);
  199.      strins(whatunbanip, params, 0);
  200.      mysql_tquery(mysql, Query, "Unbanip", "i", playerid);
  201.      } else return SendClientMessage(playerid,0xDC143CAA,"ERROR: IP is too short or is too long");
  202.    } else return SendClientMessage(playerid,0xDC143CAA,"ERROR: You are not a high enough level to use this command");
  203.    return 1;
  204. }
  205.  
  206. CMD:banip(playerid,params[]) {
  207.    if(IsPlayerAdmin(playerid)) {
  208.      if(isnull(params)) return SendClientMessage(playerid,0xDC143CAA,"Usage: /banip [ip]");
  209.      new size; size = strval(params);
  210.      if(size > 10 && size < 30) {
  211.      new Query[250];
  212.      format(Query, sizeof(Query), "SELECT * FROM bannedips WHERE `ip` = '%s'", params);
  213.      mysql_tquery(mysql, Query, "Banip", "i", playerid); offlineb[playerid] = 0;
  214.      strins(whatbanip, params, 0);
  215.      } else return SendClientMessage(playerid,0xDC143CAA,"ERROR: IP is too short or is too long");
  216.    } else return SendClientMessage(playerid,0xDC143CAA,"ERROR: You are not a high enough level to use this command");
  217.    return 1;
  218. }
  219. public Banip(playerid) {
  220.    new rows, fields,string[128],Query[250];
  221.    cache_get_data(rows, fields, mysql);
  222.    if(rows)
  223.       {
  224.       if(offlineb[playerid] == 0) SendClientMessage(playerid,0xDC143CAA,"ERROR: That ip already banned");
  225.       return whatbanip = "";
  226.       }
  227.    if(!rows)
  228.       {
  229.        format(Query, sizeof(Query),"INSERT INTO `bannedips`(`ip`) VALUES ('%s')",whatbanip);
  230.        mysql_tquery(mysql, Query, "", ""); totalip ++;
  231.        if(offlineb[playerid] == 0) {
  232.        format(string,sizeof(string),"[IP]: %s has been successfully banned",whatbanip);
  233.        SendClientMessage(playerid,0x00FFFFAA,string); }
  234.        whatbanip = "";
  235.       }
  236.    return 1;
  237. }
  238.  
  239. CMD:baninfo(playerid,params[]) {
  240.    if(IsPlayerAdmin(playerid)) {
  241.      if(isnull(params)) return SendClientMessage(playerid,0xDC143CAA,"Usage: /baninfo [playername]");
  242.      new Query[250];
  243.      format(Query, sizeof(Query), "SELECT * FROM banneds WHERE `name` = '%s'", params);
  244.      mysql_tquery(mysql, Query, "Baninfo", "i", playerid);
  245.  
  246.    } else return SendClientMessage(playerid,0xDC143CAA,"ERROR: You are not a high enough level to use this command");
  247.    return 1;
  248. }
  249.  
  250. //================================Publics=====================================//
  251. public BanCheck(playerid) {
  252.     new rows, fields,ibanned[10][2],ifbanned[2],save[5][80],checkdate[2];
  253.     cache_get_data(rows, fields, mysql);
  254.     if(rows)
  255.     {
  256.          cache_get_field_content(0, "banned", ibanned[0], mysql, 10);
  257.          ifbanned[0] = strval(ibanned[0]);
  258.          if(ifbanned[0] == 1) {
  259.          cache_get_field_content(0, "date", save[0], mysql, 80);
  260.          cache_get_field_content(0, "time", save[1], mysql, 80);
  261.          cache_get_field_content(0, "bannedby", save[2], mysql, 80);
  262.          cache_get_field_content(0, "reason", save[3], mysql, 80);
  263.          new str[350],content[128]; format(content,sizeof content,"%s %s",save[0],save[1]);
  264.          format(str, sizeof(str),"{C0C0C0}Your Account's currently Banned.\n\n{00FFFF}In-Game Name: {33FF33}%s\n{00FFFF}Administrator: {33FF33}%s\n{00FFFF}Date: {33FF33}%s\n{00FFFF}Reason: {33FF33}%s\n{C0C0C0}* if you think that you're banned wrongfully,\nfeel free to make unban appeal on our forum: forum",pName(playerid),save[2],content,save[3]);
  265.          ShowPlayerDialog(playerid, 801, DIALOG_STYLE_MSGBOX, "{FF0000}You Are Banned!", str, "Close","");
  266.          SetTimerEx("kickplayer", 500, false, "i", playerid);
  267.          } else if(ifbanned[0] == 0) {
  268.          cache_get_field_content(0, "tempban", ibanned[1], mysql, 10);
  269.          ifbanned[1] = strval(ibanned[1]);
  270.          if(ifbanned[1] == 1) {
  271.          cache_get_field_content(0, "bdate", save[0], mysql, 80);
  272.          new Year,Month,Day,string[128],ip[50]; getdate(Year, Month, Day);
  273.          format(string,sizeof string,"%d-%d-%d",Year,Month,Day);
  274.          strins(checkdate[1], string, 0);
  275.          strins(checkdate[0], save[0], 0);
  276.          if(checkdate[0] - checkdate[1] <= 0-0-0) {
  277.            new Query[250]; GetPlayerIp(playerid,ip,sizeof ip);
  278.            format(Query, sizeof(Query),"UPDATE `banneds` SET `tempban` = 0,`bannedby` = %d,`reason` = %d WHERE `name` = '%s'",0,0,pName(playerid));
  279.            mysql_tquery(mysql, Query, "", "");
  280.            format(Query, 100, "DELETE FROM `bannedips` WHERE `ip` = '%s'",ip);
  281.            mysql_tquery(mysql, Query, "", "");
  282.            return SendClientMessage(playerid, 0x33FF33AA,"Ban BOT: |- Your Ban Has been Expired -|");
  283.          }
  284.          new saves[3][128],by[128],expire[128];
  285.          cache_get_field_content(0, "date", saves[0], mysql, 128);
  286.          cache_get_field_content(0, "time", saves[1], mysql, 128);
  287.          cache_get_field_content(0, "reason", saves[2], mysql, 128);
  288.          cache_get_field_content(0, "bannedby", by, mysql, 128);
  289.          cache_get_field_content(0, "bdate", expire, mysql, 128);
  290.          new str[350],content[128]; format(content,sizeof content,"%s %s",saves[0],saves[1]);
  291.          format(str, sizeof(str),"{C0C0C0}Your Account's currently Banned.\n\n{00FFFF}In-Game Name: {33FF33}%s\n{00FFFF}Administrator: {33FF33}%s\n{00FFFF}Date: {33FF33}%s\n{00FFFF}Reason: {33FF33}%s\n{00FFFF}Ban Expire Date: {33FF33}%s\n{C0C0C0}* if you think that you're banned wrongfully,\nfeel free to make unban appeal on our forum: forum"\
  292.          ,pName(playerid),by,content,saves[2],expire);
  293.          ShowPlayerDialog(playerid, 801, DIALOG_STYLE_MSGBOX, "{FF0000}You Are Temporary Banned!", str, "Close","");
  294.          SetTimerEx("kickplayer", 500, false, "i", playerid);
  295.          }
  296.      }
  297.    }
  298.     if(!rows)
  299.     {
  300.      new Query[250],ip1[32]; GetPlayerIp(playerid,ip1,sizeof(ip1));
  301.      format(Query, sizeof(Query), "SELECT * FROM `bannedips` WHERE `ip` = '%s'", ip1);
  302.      mysql_tquery(mysql, Query, "BanIPCheck", "i", playerid);
  303.      }
  304.     return 1;
  305. }
  306.  
  307. public BanIPCheck(playerid) {
  308.        new rows, fields,string[128];
  309.        cache_get_data(rows, fields, mysql);
  310.        if(rows)
  311.         {
  312.          format(string,sizeof(string),"%s has been Auto Kicked | Reason: Banned IP |",pName(playerid));
  313.          SendClientMessageToAll(COLOR_Silver,string);
  314.          SetTimerEx("kickplayer", 500, false, "i", playerid);
  315.        }
  316.        if(!rows)
  317.       {
  318.        new Query[250],datum[50],hour1,minute1,second1,year1,month1,day1,tijd[50],ip1[32];
  319.        getdate(year1, month1, day1); gettime(hour1,minute1,second1); GetPlayerIp(playerid,ip1,sizeof(ip1));
  320.        format(datum, sizeof(datum), "%d-%d-%d", year1, month1, day1); format(tijd, sizeof(tijd), "%d:%d:%d", hour1, minute1, second1);
  321.        new none[15]; none = "None";
  322.        format(Query, sizeof(Query),"INSERT INTO `banneds` (name,ip,date,time,bannedby,banned,reason,bdate,tempban) VALUES ('%s','%s','%s','%s','%s','%d','%s','%s','%d')",pName(playerid),ip1,datum,tijd,none,0,none,none,0);
  323.        mysql_tquery(mysql, Query, "", "");
  324.    }
  325. }
  326.  
  327. public Unban(playerid) {
  328.   new rows, fields,string[128];
  329.   cache_get_data(rows, fields, mysql);
  330.   if(rows)
  331.       {
  332.        new Query[250],saving0[10],saving1[32],saving2[32],unban;
  333.        cache_get_field_content(0, "name", saving2, mysql, 32);
  334.        cache_get_field_content(0, "banned", saving0, mysql, 10);
  335.        cache_get_field_content(0, "ip", saving1, mysql, 32);
  336.        unban = strval(saving0);
  337.        if(unban == 1) {
  338.        new none[10]; none = "0";
  339.        format(Query, sizeof(Query),"UPDATE `banneds` SET `banned` = 0,`banned` = 0,`tempban` = %s,`reason` = %s WHERE `name` = '%s'",none,none,saving2);
  340.        mysql_tquery(mysql, Query, "", "");
  341.        format(Query, 100, "DELETE FROM `bannedips` WHERE `ip` = '%s'", saving1);
  342.        mysql_tquery(mysql, Query, "", ""); totalbans --; totalip --;
  343.        format(string,sizeof(string),"%s successfully has been unbanned",saving2);
  344.        SendClientMessage(playerid,0x00FFFFAA,string);
  345.        } else return SendClientMessage(playerid,0xDC143CAA,"ERROR: This Player is not banned");
  346.     } else return SendClientMessage(playerid,0xDC143CAA,"ERROR: Player Name Not Exist on Database");
  347.   return 1;
  348. }
  349.  
  350. CMD:oban(playerid,params[]) {
  351.     if(IsPlayerAdmin(playerid)) {
  352.        new tmp[256], tmp2[256], Index;      tmp = strtok(params,Index), tmp2 = strtok(params,Index);
  353.        if(!strlen(tmp) || !strlen(tmp2)) return SendClientMessage(playerid,0xDC143CAA," Usage /oban [playername] [reason]");
  354.        new Query[250];
  355.        format(Query, sizeof(Query), "SELECT * FROM banneds WHERE `name` = '%s'", tmp);
  356.        strins(banreason, tmp2, 0);
  357.        return mysql_tquery(mysql, Query, "offlineban", "i", playerid);
  358.     } else return SendClientMessage(playerid,0xDC143CAA,"ERROR: You need to be rcon to use this command");
  359. }
  360.        
  361. public offlineban(playerid) {
  362.   new rows, fields,string[128];
  363.   cache_get_data(rows, fields, mysql);
  364.   if(rows)
  365.       {
  366.        new Query[250],saving[3][128],banned1;
  367.        cache_get_field_content(0, "name", saving[0], mysql, 128);
  368.        cache_get_field_content(0, "banned", saving[1], mysql, 32);
  369.        cache_get_field_content(0, "ip", saving[2], mysql, 32);
  370.        banned1 = strval(saving[1]);
  371.        if(banned1 == 0) {
  372.        format(Query, sizeof(Query),"UPDATE `banneds` SET `banned` = 1, `bannedby` = '%s' ,`reason` = '%s' WHERE `name` = '%s'",pName(playerid),banreason,saving[0]);
  373.        mysql_tquery(mysql, Query, "", ""); offlineb[playerid] = 1; banreason = "";
  374.        strins(whatbanip, saving[2], 0); totalbans ++; printf("%s",Query);
  375.        format(Query, sizeof(Query), "SELECT * FROM bannedips WHERE `ip` = '%s'", saving[2]);
  376.        mysql_tquery(mysql, Query, "Banip", "i", playerid);
  377.        format(string,sizeof(string),"%s, has been  successfully banned",saving[0]);
  378.        SendClientMessage(playerid,0x00FFFFAA,string);
  379.        } else { banreason = ""; return SendClientMessage(playerid,0xDC143CAA,"ERROR: This Player is already banned");}
  380.     } else {banreason = ""; return SendClientMessage(playerid,0xDC143CAA,"ERROR: Player Name Not Exist on Database");}
  381.   return 1;
  382. }
  383. public Unbanip(playerid) {
  384.    new rows, fields,string[128];
  385.    cache_get_data(rows, fields, mysql);
  386.    if(rows)
  387.       {
  388.        new Query[250];
  389.        format(Query, 100, "DELETE FROM `bannedips` WHERE `ip` = '%s'", whatunbanip);
  390.        mysql_tquery(mysql, Query, "", ""); totalip --;
  391.        format(string,sizeof(string),"[IP]: %s has been successfully unbanned", whatunbanip);
  392.        SendClientMessage(playerid,0x00FFFFAA,string);
  393.        whatunbanip = "";
  394.    } else return SendClientMessage(playerid,0xDC143CAA,"ERROR: IP Not Exist on banned ips Database"); whatunbanip = "";
  395.    return 1;
  396. }
  397.  
  398. public Baninfo(playerid) {
  399.    new rows, fields;
  400.    cache_get_data(rows, fields, mysql);
  401.    if(rows)
  402.       {
  403.        new save[5][50],save5[128],banned1,str[350],str2[80],datetime[50];
  404.        cache_get_field_content(0, "banned", save[0], mysql, 10);
  405.        banned1 = strval(save[0]);
  406.        if(banned1 == 1) {
  407.          cache_get_field_content(0, "date", save[1], mysql, 50);
  408.          cache_get_field_content(0, "time", save[2], mysql, 50);
  409.          cache_get_field_content(0, "bannedby", save[3], mysql, 50);
  410.          cache_get_field_content(0, "name", save[4], mysql, 50);
  411.          cache_get_field_content(0, "reason", save5, mysql, 128);
  412.          format(str2,sizeof(str2),"%s Ban Information",save[4]);
  413.          format(datetime,sizeof(datetime),"%s %s",save[1],save[2]);
  414.          format(str, sizeof(str),"{00FFFF}Player Name: {33FF33}%s\n\n{00FFFF}Banned By: {33FF33}%s\n\n{00FFFF}Date: {33FF33}%s\n\n{00FFFF}Reason: {33FF33}%s",save[4],save[3],datetime,save5);
  415.          ShowPlayerDialog(playerid, 0, DIALOG_STYLE_MSGBOX, str2, str, "Close","");
  416.        } if(banned1 == 0) {
  417.          cache_get_field_content(0, "tempban", save[0], mysql, 10);
  418.          banned1 = strval(save[0]);
  419.          if(banned1 == 1) {
  420.            new saves[3][128],by[128],expire[128];
  421.            cache_get_field_content(0, "date", saves[0], mysql, 128);
  422.            cache_get_field_content(0, "time", saves[1], mysql, 128);
  423.            cache_get_field_content(0, "reason", saves[2], mysql, 128);
  424.            cache_get_field_content(0, "name", save[4], mysql, 50);
  425.            cache_get_field_content(0, "bannedby", by, mysql, 128);
  426.            cache_get_field_content(0, "bdate", expire, mysql, 128);
  427.            new content[128]; format(content,sizeof content,"%s %s",saves[0],saves[1]);
  428.            format(str2,sizeof(str2),"%s Ban Information",save[4]);
  429.            format(str, sizeof(str),"{00FFFF}Player Name: {33FF33}%s\n\n{00FFFF}Banned By: {33FF33}%s\n{00FFFF}Date: {33FF33}%s\n{00FFFF}Reason: {33FF33}%s\n{00FFFF}Ban Expire Date: {33FF33}%s\n{C0C0C0}* if you think that you're banned wrongfully,\nfeel free to make unban appeal on our forum: forum"\
  430.        ,save[4],by,content,saves[2],expire);
  431.            ShowPlayerDialog(playerid, 0, DIALOG_STYLE_MSGBOX, str2, str, "Close","");
  432.        }
  433.        } else return SendClientMessage(playerid,0xDC143CAA,"ERROR: This player is not banned");
  434.    } else return SendClientMessage(playerid,0xDC143CAA,"ERROR: Player Name not Exist on database");
  435.    return 1;
  436. }
  437.  
  438. public DBaninfo(playerid) {
  439.    new rows, fields;
  440.    cache_get_data(rows, fields, mysql);
  441.    if(rows)
  442.     {
  443.        new save[5][50],save5[128],banned1,str[350],str2[80],datetime[50];
  444.        cache_get_field_content(0, "banned", save[0], mysql, 10);
  445.        banned1 = strval(save[0]);
  446.        if(banned1 == 1) {
  447.          cache_get_field_content(0, "date", save[1], mysql, 50);
  448.          cache_get_field_content(0, "time", save[2], mysql, 50);
  449.          cache_get_field_content(0, "bannedby", save[3], mysql, 50);
  450.          cache_get_field_content(0, "name", save[4], mysql, 50);
  451.          cache_get_field_content(0, "reason", save5, mysql, 128);
  452.          format(str2,sizeof(str2),"%s Ban Information",save[4]);
  453.          format(datetime,sizeof(datetime),"%s %s",save[1],save[2]);
  454.          format(str, sizeof(str),"{00FFFF}Player Name: {33FF33}%s\n\n{00FFFF}Banned By: {33FF33}%s\n\n{00FFFF}Date: {33FF33}%s\n\n{00FFFF}Reason: {33FF33}%s",save[4],save[3],datetime,save5);
  455.          ShowPlayerDialog(playerid, 0, DIALOG_STYLE_MSGBOX, str2, str, "Close","");
  456.        } if(banned1 == 0) {
  457.          cache_get_field_content(0, "tempban", save[0], mysql, 10);
  458.          banned1 = strval(save[0]);
  459.          if(banned1 == 1) {
  460.            new saves[3][128],by[128],expire[128];
  461.            cache_get_field_content(0, "date", saves[0], mysql, 128);
  462.            cache_get_field_content(0, "time", saves[1], mysql, 128);
  463.            cache_get_field_content(0, "reason", saves[2], mysql, 128);
  464.            cache_get_field_content(0, "name", save[4], mysql, 50);
  465.            cache_get_field_content(0, "bannedby", by, mysql, 128);
  466.            cache_get_field_content(0, "bdate", expire, mysql, 128);
  467.            new content[128]; format(content,sizeof content,"%s %s",saves[0],saves[1]);
  468.            format(str2,sizeof(str2),"%s Ban Information",save[4]);
  469.            format(str, sizeof(str),"{00FFFF}Player Name: {33FF33}%s\n\n{00FFFF}Banned By: {33FF33}%s\n{00FFFF}Date: {33FF33}%s\n{00FFFF}Reason: {33FF33}%s\n{00FFFF}Ban Expire Date: {33FF33}%s\n{C0C0C0}* if you think that you're banned wrongfully,\nfeel free to make unban appeal on our forum: forum"\
  470.        ,save[4],by,content,saves[2],expire);
  471.            ShowPlayerDialog(playerid, 0, DIALOG_STYLE_MSGBOX, str2, str, "Close","");
  472.          } else return ShowPlayerDialog(playerid, 2648, DIALOG_STYLE_INPUT, "{FF0000}Banned {33FF33}Players List", "Player Name you Entered Are not banned", "Search", "Close");
  473.        }
  474.    } else return ShowPlayerDialog(playerid, 2648, DIALOG_STYLE_INPUT, "{FF0000}Banned {33FF33}Players List", "Player Name not Exist on database", "Search", "Close");
  475.    return 1;
  476. }
  477.  
  478. public kickplayer(playerid) {
  479.     return Kick(playerid);
  480. }
  481. //==================================a fuction=================================//
  482. strtok(const string[], &index)
  483. {
  484.     new length = strlen(string);
  485.     while ((index < length) && (string[index] <= ' '))
  486.     {
  487.         index++;
  488.     }
  489.  
  490.     new offset = index;
  491.     new result[20];
  492.     while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  493.     {
  494.         result[index - offset] = string[index];
  495.         index++;
  496.     }
  497.     result[index - offset] = EOS;
  498.     return result;
  499. }
  500. pName(playerid) {
  501.   new pname[MAX_PLAYER_NAME];
  502.   GetPlayerName(playerid, pname, sizeof(pname));
  503.   return pname;
  504. }
  505. //============================================================================//
Advertisement
Add Comment
Please, Sign In to add comment