jlalt

ban shystem

Dec 31st, 2015
343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 26.51 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) || PlayerInfo[playerid][Level] >= 4) {
  98.             new strdate[128],strtime[128], player1, tmp2[256];
  99.             if(sscanf(params,"is",player1,tmp2)) return SendClientMessage(playerid, 0xDC143CAA, "USAGE: /ban [playerid] [reason]");
  100.             new string[128];
  101.             if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID && player1 != playerid) {
  102.                 if(!IsPlayerNPC(playerid) && IsPlayerAdmin(player1)) return SendClientMessage(playerid, 0xDC143CAA, "Player is not connected or is yourself or is the highest level admin");
  103.                 new year,month,day,hour,minuite,second; getdate(year, month, day); gettime(hour,minuite,second);
  104.                 format(string,sizeof(string),"|- %s has been banned by Administrator %s [Reason: %s] [Date: %d/%d/%d] [Time: %d:%d] -|",pName(player1),pName(playerid),tmp2,day,month,year,hour,minuite);
  105.                 SendClientMessageToAll(COLOR_Silver,string);
  106.                 print(string);
  107.  
  108.                 format(strdate, sizeof(strdate), "%d-%d-%d ",year,month,day);
  109.                 format(strtime,sizeof(strtime),"%d:%d:%d",hour,minuite,second);
  110.                 new Query[250];
  111.  
  112.                 format(Query, sizeof(Query), "UPDATE `banneds` SET `ip` = '%s', `date` = '%s', `time` = '%s', `bannedby` = '%s', `banned` = '%d', `reason` = '%s' WHERE `name` = '%s'", pIP(player1),strdate,strtime,pName(playerid),1,tmp2,pName(player1));
  113.                 mysql_tquery(mysql, Query, "", "");
  114.                 format(Query, sizeof(Query),"INSERT INTO `bannedips`(`ip`) VALUES ('%s')",pIP(player1));
  115.                 mysql_tquery(mysql, Query, "", "");
  116.                 return SetTimerEx("kickplayer", 500, false, "i", player1);
  117.             } else return SendClientMessage(playerid, 0xDC143CAA, "Player is not connected or is yourself or is the highest level admin");
  118.     } else return SendClientMessage(playerid,0xDC143CAA,"ERROR: You are not a high enough level to use this command");
  119. }
  120. CMD:tempban(playerid,params[]) {
  121.     if(IsPlayerAdmin(playerid)) {
  122.             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);
  123.             if(!strlen(player1w)) {
  124.             SendClientMessage(playerid, 0xDC143CAA, "USAGE: /tempban [playerid] [reason] [years months days]");
  125.             return SendClientMessage(playerid, 0xFF9900AA, "Example: /tempban 1 example 0 0 6 [ player will be banned for six days ]");
  126.             }
  127.             if(!strlen(reason)) return SendClientMessage(playerid, red, "ERROR: You must give a reason");
  128.  
  129.             if(!strlen(byearw)) return SendClientMessage(playerid, red, "ERROR: You must give a year");
  130.             if(!strlen(bmonthw)) return SendClientMessage(playerid, red, "ERROR: You must give a month");
  131.             if(!strlen(bdayw)) return SendClientMessage(playerid, red, "ERROR: You must give a day");
  132.  
  133.             new player1n,byearn,bmonthn,bdayn,ip[128], string[150];
  134.             player1n = strval(player1w); byearn = strval(byearw); bmonthn = strval(bmonthw); bdayn = strval(bdayw);
  135.  
  136.             if(IsPlayerConnected(player1n) && player1n != INVALID_PLAYER_ID) {
  137.                 GetPlayerIp(playerid,ip,sizeof(ip));
  138.                 new year,month,day,hour,minuite,second; getdate(year, month, day); gettime(hour,minuite,second);
  139.                 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);
  140.                 SendClientMessageToAll(COLOR_Silver,string);
  141.                 print(string);
  142.                 format(strdate, sizeof(strdate), "%d-%d-%d ",year,month,day);
  143.                 format(strtime,sizeof(strtime),"%d:%d:%d",hour,minuite,second);
  144.                 new tempbandate[3],bandate[128];
  145.                 tempbandate[0] = year+byearn; tempbandate[1] = month+bmonthn; tempbandate[2] = day+bdayn;
  146.                 format(bandate,sizeof bandate,"%d-%d-%d",tempbandate[0],tempbandate[1],tempbandate[2]);
  147.                 new Query[250];
  148.  
  149.                 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));
  150.                 mysql_tquery(mysql, Query, "", ""); printf("%s",Query); totalbans ++;
  151.                 format(Query, sizeof(Query),"INSERT INTO `bannedips`(`ip`) VALUES ('%s')",ip);
  152.                 mysql_tquery(mysql, Query, "", ""); totalip ++;
  153.  
  154.                 return SetTimerEx("kickplayer", 500, false, "i", player1n);
  155.             } else return SendClientMessage(playerid, 0xDC143CAA, "Player is not connected or is yourself or is the highest level admin");
  156.     } else return SendClientMessage(playerid,0xDC143CAA,"ERROR: You are not a high enough level to use this command");
  157. }
  158. CMD:unban(playerid,params[]) {
  159.      if(IsPlayerAdmin(playerid)) {
  160.      if(isnull(params)) return SendClientMessage(playerid,0xDC143CAA,"Usage: /unban [playername]");
  161.      new Query[250];
  162.      format(Query, sizeof(Query), "SELECT * FROM banneds WHERE `name` = '%s'", params);
  163.      mysql_tquery(mysql, Query, "Unban", "i", playerid);
  164.      } else return SendClientMessage(playerid,0xDC143CAA,"ERROR: You are not a high enough level to use this command");
  165.      return 1;
  166. }
  167. CMD:banlist(playerid,params[]) {
  168.   if(IsPlayerAdmin(playerid) || PlayerInfo[playerid][Level] >= 6) {
  169.     new Query[128];
  170.     mysql_format(mysql, Query, sizeof(Query),"SELECT * FROM `banneds` WHERE `banned` = 1 OR `tempban` = 1");
  171.     mysql_tquery(mysql, Query, "TotalBans", "");
  172.     mysql_format(mysql, Query, sizeof(Query),"SELECT * FROM `banneds` WHERE `tempban` = 1");
  173.     mysql_tquery(mysql, Query, "Totalbans1", "");
  174.     mysql_format(mysql, Query, sizeof(Query),"SELECT * FROM `bannedips`");
  175.     mysql_tquery(mysql, Query, "Totalbanips", "");
  176.     new string[200];
  177.     format(string,sizeof(string),"\tBan List\n\n{ff4d4d}Banned Accounts: {FFFFFF}%d\n{ff4d4d}Banned IPS: {FFFFFF}%d\n{ff4d4d}Temporary Banneds: {FFFFFF}%d",totalbans,totalip,totaltbans);
  178.     ShowPlayerDialog(playerid, 2648, DIALOG_STYLE_INPUT, "Ban List", string, "Search", "Close");
  179.     } else return SendClientMessage(playerid,0xDC143CAA,"ERROR: You are not a high enough level to use this command");
  180.   return 1;
  181. }
  182. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
  183.   if(dialogid == 2648) {
  184.     if(response == 1) {
  185.      new string[200];
  186.      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);
  187.      if(!strlen(inputtext)) return ShowPlayerDialog(playerid, 2648, DIALOG_STYLE_INPUT, "{FF0000}Banned {33FF33}Players List", string, "Search", "Close");
  188.      new Query[128];
  189.      format(Query, sizeof(Query), "SELECT * FROM banneds WHERE `name` = '%s'", inputtext);
  190.      mysql_tquery(mysql, Query, "DBaninfo", "i", playerid);
  191.     } if(response == 0) {
  192.     SendClientMessage(playerid,0xFF0000AA,"Ban BOT: {33FF33}You have Closed Dialog Ban List");
  193.     }
  194.   }
  195.   return 0;
  196. }
  197. CMD:unbanip(playerid,params[]) {
  198.    if(IsPlayerAdmin(playerid)) {
  199.      if(isnull(params)) return SendClientMessage(playerid,0xDC143CAA,"Usage: /unbanip [ip]");
  200.      new size; size = strval(params);
  201.      if(size > 10 && size < 30) {
  202.      new Query[250];
  203.      format(Query, sizeof(Query), "SELECT * FROM bannedips WHERE `ip` = '%s'", params);
  204.      strins(whatunbanip, params, 0);
  205.      mysql_tquery(mysql, Query, "Unbanip", "i", playerid);
  206.      } else return SendClientMessage(playerid,0xDC143CAA,"ERROR: IP is too short or is too long");
  207.    } else return SendClientMessage(playerid,0xDC143CAA,"ERROR: You are not a high enough level to use this command");
  208.    return 1;
  209. }
  210.  
  211. CMD:banip(playerid,params[]) {
  212.    if(IsPlayerAdmin(playerid)) {
  213.      if(isnull(params)) return SendClientMessage(playerid,0xDC143CAA,"Usage: /banip [ip]");
  214.      new size; size = strval(params);
  215.      if(size > 10 && size < 30) {
  216.      new Query[250];
  217.      format(Query, sizeof(Query), "SELECT * FROM bannedips WHERE `ip` = '%s'", params);
  218.      mysql_tquery(mysql, Query, "Banip", "i", playerid); offlineb[playerid] = 0;
  219.      strins(whatbanip, params, 0);
  220.      } else return SendClientMessage(playerid,0xDC143CAA,"ERROR: IP is too short or is too long");
  221.    } else return SendClientMessage(playerid,0xDC143CAA,"ERROR: You are not a high enough level to use this command");
  222.    return 1;
  223. }
  224. public Banip(playerid) {
  225.    new rows, fields,string[128],Query[250];
  226.    cache_get_data(rows, fields, mysql);
  227.    if(rows)
  228.       {
  229.       if(offlineb[playerid] == 0) SendClientMessage(playerid,0xDC143CAA,"ERROR: That ip already banned");
  230.       return whatbanip = "";
  231.       }
  232.    if(!rows)
  233.       {
  234.        format(Query, sizeof(Query),"INSERT INTO `bannedips`(`ip`) VALUES ('%s')",whatbanip);
  235.        mysql_tquery(mysql, Query, "", ""); totalip ++;
  236.        if(offlineb[playerid] == 0) {
  237.        format(string,sizeof(string),"[IP]: %s has been successfully banned",whatbanip);
  238.        SendClientMessage(playerid,0x00FFFFAA,string); }
  239.        whatbanip = "";
  240.       }
  241.    return 1;
  242. }
  243.  
  244. CMD:baninfo(playerid,params[]) {
  245.    if(IsPlayerAdmin(playerid)) {
  246.      if(isnull(params)) return SendClientMessage(playerid,0xDC143CAA,"Usage: /baninfo [playername]");
  247.      new Query[250];
  248.      format(Query, sizeof(Query), "SELECT * FROM banneds WHERE `name` = '%s'", params);
  249.      mysql_tquery(mysql, Query, "Baninfo", "i", playerid);
  250.  
  251.    } else return SendClientMessage(playerid,0xDC143CAA,"ERROR: You are not a high enough level to use this command");
  252.    return 1;
  253. }
  254.  
  255. //================================Publics=====================================//
  256. public BanCheck(playerid) {
  257.     new rows, fields,ibanned[10][2],ifbanned[2],save[4][80],Query[250];
  258.     cache_get_data(rows, fields, mysql);
  259.     if(rows)
  260.     {
  261.          format(Query, sizeof(Query),"UPDATE `banneds` SET `ip` = '%s' WHERE `name` = '%s'",pIP(playerid),pName(playerid));
  262.          mysql_tquery(mysql, Query, "", "");
  263.          cache_get_field_content(0, "banned", ibanned[0], mysql, 10);
  264.          ifbanned[0] = strval(ibanned[0]);
  265.          if(ifbanned[0] == 1) {
  266.          cache_get_field_content(0, "date", save[0], mysql, 80);
  267.          cache_get_field_content(0, "time", save[1], mysql, 80);
  268.          cache_get_field_content(0, "bannedby", save[2], mysql, 80);
  269.          cache_get_field_content(0, "reason", save[3], mysql, 80);
  270.          new str[350],content[128]; format(content,sizeof content,"%s %s",save[0],save[1]);
  271.          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]);
  272.          ShowPlayerDialog(playerid, 801, DIALOG_STYLE_MSGBOX, "{FF0000}You Are Banned!", str, "Close","");
  273.          return SetTimerEx("kickplayer", 500, false, "i", playerid);
  274.          } else if(ifbanned[0] == 0) {
  275.          cache_get_field_content(0, "tempban", ibanned[1], mysql, 10);
  276.          ifbanned[1] = strval(ibanned[1]);
  277.          if(ifbanned[1] == 1) {
  278.          new whatdate;
  279.          whatdate = cache_get_field_content_int(0,"bdate",mysql);
  280.          new Year,Month,Day,string;
  281.          getdate(Year, Month, Day);
  282.          Year *= 12;
  283.          Year *= 30;
  284.          Month *= 30;
  285.          string = Year+Month+Day;
  286.          printf("%d %d",whatdate,string);
  287.          if(whatdate - string <= 0) {
  288.            format(Query, sizeof(Query),"UPDATE `banneds` SET `tempban` = 0,`bannedby` = %d,`reason` = %d WHERE `name` = '%s'",0,0,pName(playerid));
  289.            mysql_tquery(mysql, Query, "", "");
  290.            format(Query, 100, "DELETE FROM `bannedips` WHERE `ip` = '%s'",pIP(playerid));
  291.            mysql_tquery(mysql, Query, "", "");
  292.            return SendClientMessage(playerid, 0x33FF33AA,"Ban BOT: |- Your Ban Has been Expired -|");
  293.          }
  294.          new saves[3][128],by[128],expire;
  295.          cache_get_field_content(0, "date", saves[0], mysql, 128);
  296.          cache_get_field_content(0, "time", saves[1], mysql, 128);
  297.          cache_get_field_content(0, "reason", saves[2], mysql, 128);
  298.          cache_get_field_content(0, "bannedby", by, mysql, 128);
  299.          expire = cache_get_field_content_int(0, "bdate",mysql);
  300.          new str[350],content[128]; format(content,sizeof content,"%s %s",saves[0],saves[1]);
  301.          expire -= string;
  302.          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 After: {33FF33}%d Days\n{C0C0C0}* if you think that you're banned wrongfully,\nfeel free to make unban appeal on our forum: forum"\
  303.          ,pName(playerid),by,content,saves[2],expire);
  304.          ShowPlayerDialog(playerid, 801, DIALOG_STYLE_MSGBOX, "{FF0000}You Are Temporary Banned!", str, "Close","");
  305.          return SetTimerEx("kickplayer", 500, false, "i", playerid);
  306.          }
  307.          }
  308.          format(Query, sizeof(Query), "SELECT * FROM accounts WHERE `Name` = '%s'",pName(playerid));
  309.          mysql_tquery(mysql, Query, "LoadAccount", "i",playerid);
  310.       }
  311.     if(!rows)
  312.     {
  313.      format(Query, sizeof(Query), "SELECT * FROM `bannedips` WHERE `ip` = '%s'", pIP(playerid));
  314.      mysql_tquery(mysql, Query, "BanIPCheck", "i", playerid);
  315.      }
  316.     return 1;
  317. }
  318.  
  319. public BanIPCheck(playerid) {
  320.     new rows, fields,string[128];
  321.     cache_get_data(rows, fields, mysql);
  322.     if(rows)
  323.       {
  324.        format(string,sizeof(string),"%s has been Auto Kicked | Reason: Banned IP |",pName(playerid));
  325.        SendClientMessageToAll(COLOR_Silver,string);
  326.        return SetTimerEx("kickplayer", 500, false, "i", playerid);
  327.        }
  328.     if(!rows)
  329.       {
  330.        new Query[250],datum[50],hour1,minute1,second1,year1,month1,day1,tijd[50];
  331.        getdate(year1, month1, day1); gettime(hour1,minute1,second1);
  332.        format(datum, sizeof(datum), "%d-%d-%d", year1, month1, day1); format(tijd, sizeof(tijd), "%d:%d:%d", hour1, minute1, second1);
  333.        new none[15]; none = "None";
  334.        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),pIP(playerid),datum,tijd,none,0,none,none,0);
  335.        mysql_tquery(mysql, Query, "", "");
  336.    }
  337.     new Query[128];
  338.     format(Query, sizeof(Query), "SELECT * FROM accounts WHERE `Name` = '%s'",pName(playerid));
  339.     return mysql_tquery(mysql, Query, "LoadAccount", "i",playerid);
  340. }
  341.  
  342. public Unban(playerid) {
  343.   new rows, fields,string[128];
  344.   cache_get_data(rows, fields, mysql);
  345.   if(rows)
  346.       {
  347.        new Query[250],saving0[10],saving1[32],saving2[32],unban;
  348.        cache_get_field_content(0, "name", saving2, mysql, 32);
  349.        cache_get_field_content(0, "banned", saving0, mysql, 10);
  350.        cache_get_field_content(0, "ip", saving1, mysql, 32);
  351.        unban = strval(saving0);
  352.        if(unban == 1) {
  353.        new none[10]; none = "0";
  354.        format(Query, sizeof(Query),"UPDATE `banneds` SET `banned` = 0,`banned` = 0,`tempban` = %s,`reason` = %s WHERE `name` = '%s'",none,none,saving2);
  355.        mysql_tquery(mysql, Query, "", "");
  356.        format(Query, 100, "DELETE FROM `bannedips` WHERE `ip` = '%s'", saving1);
  357.        mysql_tquery(mysql, Query, "", ""); totalbans --; totalip --;
  358.        format(string,sizeof(string),"%s successfully has been unbanned",saving2);
  359.        SendClientMessage(playerid,0x00FFFFAA,string);
  360.        } else return SendClientMessage(playerid,0xDC143CAA,"ERROR: This Player is not banned");
  361.     } else return SendClientMessage(playerid,0xDC143CAA,"ERROR: Player Name Not Exist on Database");
  362.   return 1;
  363. }
  364.  
  365. CMD:oban(playerid,params[]) {
  366.     if(IsPlayerAdmin(playerid)) {
  367.        new tmp[256], tmp2[256], Index;      tmp = strtok(params,Index), tmp2 = strtok(params,Index);
  368.        if(!strlen(tmp) || !strlen(tmp2)) return SendClientMessage(playerid,0xDC143CAA," Usage /oban [playername] [reason]");
  369.        new Query[250];
  370.        format(Query, sizeof(Query), "SELECT * FROM banneds WHERE `name` = '%s'", tmp);
  371.        strins(banreason, tmp2, 0);
  372.        return mysql_tquery(mysql, Query, "offlineban", "i", playerid);
  373.     } else return SendClientMessage(playerid,0xDC143CAA,"ERROR: You need to be rcon to use this command");
  374. }
  375.  
  376. public offlineban(playerid) {
  377.   new rows, fields,string[128];
  378.   cache_get_data(rows, fields, mysql);
  379.   if(rows)
  380.       {
  381.        new Query[250],saving[3][128],banned1;
  382.        cache_get_field_content(0, "name", saving[0], mysql, 128);
  383.        cache_get_field_content(0, "banned", saving[1], mysql, 32);
  384.        cache_get_field_content(0, "ip", saving[2], mysql, 32);
  385.        banned1 = strval(saving[1]);
  386.        if(banned1 == 0) {
  387.        format(Query, sizeof(Query),"UPDATE `banneds` SET `banned` = 1, `bannedby` = '%s' ,`reason` = '%s' WHERE `name` = '%s'",pName(playerid),banreason,saving[0]);
  388.        mysql_tquery(mysql, Query, "", ""); offlineb[playerid] = 1; banreason = "";
  389.        strins(whatbanip, saving[2], 0); totalbans ++; printf("%s",Query);
  390.        format(Query, sizeof(Query), "SELECT * FROM bannedips WHERE `ip` = '%s'", saving[2]);
  391.        mysql_tquery(mysql, Query, "Banip", "i", playerid);
  392.        format(string,sizeof(string),"%s, has been  successfully banned",saving[0]);
  393.        SendClientMessage(playerid,0x00FFFFAA,string);
  394.        } else { banreason = ""; return SendClientMessage(playerid,0xDC143CAA,"ERROR: This Player is already banned");}
  395.     } else {banreason = ""; return SendClientMessage(playerid,0xDC143CAA,"ERROR: Player Name Not Exist on Database");}
  396.   return 1;
  397. }
  398. public Unbanip(playerid) {
  399.    new rows, fields,string[128];
  400.    cache_get_data(rows, fields, mysql);
  401.    if(rows)
  402.       {
  403.        new Query[250];
  404.        format(Query, 100, "DELETE FROM `bannedips` WHERE `ip` = '%s'", whatunbanip);
  405.        mysql_tquery(mysql, Query, "", ""); totalip --;
  406.        format(string,sizeof(string),"[IP]: %s has been successfully unbanned", whatunbanip);
  407.        SendClientMessage(playerid,0x00FFFFAA,string);
  408.        whatunbanip = "";
  409.    } else return SendClientMessage(playerid,0xDC143CAA,"ERROR: IP Not Exist on banned ips Database"); whatunbanip = "";
  410.    return 1;
  411. }
  412.  
  413. public Baninfo(playerid) {
  414.    new rows, fields;
  415.    cache_get_data(rows, fields, mysql);
  416.    if(rows)
  417.       {
  418.        new save[5][50],save5[128],banned1,str[350],str2[80],datetime[50];
  419.        cache_get_field_content(0, "banned", save[0], mysql, 10);
  420.        banned1 = strval(save[0]);
  421.        if(banned1 == 1) {
  422.          cache_get_field_content(0, "date", save[1], mysql, 50);
  423.          cache_get_field_content(0, "time", save[2], mysql, 50);
  424.          cache_get_field_content(0, "bannedby", save[3], mysql, 50);
  425.          cache_get_field_content(0, "name", save[4], mysql, 50);
  426.          cache_get_field_content(0, "reason", save5, mysql, 128);
  427.          format(str2,sizeof(str2),"%s Ban Information",save[4]);
  428.          format(datetime,sizeof(datetime),"%s %s",save[1],save[2]);
  429.          format(str, sizeof(str),"{00FFFF}Player Name: {33FF33}%s\n{00FFFF}Banned By: {33FF33}%s\n{00FFFF}Date: {33FF33}%s\n{00FFFF}Reason: {33FF33}%s",save[4],save[3],datetime,save5);
  430.          ShowPlayerDialog(playerid, 0, DIALOG_STYLE_MSGBOX, str2, str, "Close","");
  431.        } if(banned1 == 0) {
  432.          cache_get_field_content(0, "tempban", save[0], mysql, 10);
  433.          banned1 = strval(save[0]);
  434.          if(banned1 == 1) {
  435.            new saves[3][128],by[128],expire;
  436.            cache_get_field_content(0, "date", saves[0], mysql, 128);
  437.            cache_get_field_content(0, "time", saves[1], mysql, 128);
  438.            cache_get_field_content(0, "reason", saves[2], mysql, 128);
  439.            cache_get_field_content(0, "name", save[4], mysql, 50);
  440.            cache_get_field_content(0, "bannedby", by, mysql, 128);
  441.            expire = cache_get_field_content_int(0, "bdate", mysql);
  442.            new content[128]; format(content,sizeof content,"%s %s",saves[0],saves[1]);
  443.            format(str2,sizeof(str2),"%s Ban Information",save[4]);
  444.            new date,Year,Month,Day;
  445.            getdate(Year,Month,Day);
  446.            Year *= 12;
  447.            Year *= 30;
  448.            Month *= 30;
  449.            date = Year+Month+Day;
  450.            expire -= date;
  451.            format(str, sizeof(str),"{00FFFF}Player Name: {33FF33}%s\n{00FFFF}Banned By: {33FF33}%s\n{00FFFF}Date: {33FF33}%s\n{00FFFF}Reason: {33FF33}%s\n{00FFFF}Ban Expire After: {33FF33}%d Days"
  452.            ,save[4],by,content,saves[2],expire);
  453.            ShowPlayerDialog(playerid, 0, DIALOG_STYLE_MSGBOX, str2, str, "Close","");
  454.        }
  455.        } else return SendClientMessage(playerid,0xDC143CAA,"ERROR: This player is not banned");
  456.    } else return SendClientMessage(playerid,0xDC143CAA,"ERROR: Player Name not Exist on database");
  457.    return 1;
  458. }
  459.  
  460. public DBaninfo(playerid) {
  461.    new rows, fields;
  462.    cache_get_data(rows, fields, mysql);
  463.    if(rows)
  464.     {
  465.        new save[5][50],save5[128],banned1,str[350],str2[80],datetime[50];
  466.        cache_get_field_content(0, "banned", save[0], mysql, 10);
  467.        banned1 = strval(save[0]);
  468.        if(banned1 == 1) {
  469.          cache_get_field_content(0, "date", save[1], mysql, 50);
  470.          cache_get_field_content(0, "time", save[2], mysql, 50);
  471.          cache_get_field_content(0, "bannedby", save[3], mysql, 50);
  472.          cache_get_field_content(0, "name", save[4], mysql, 50);
  473.          cache_get_field_content(0, "reason", save5, mysql, 128);
  474.          format(str2,sizeof(str2),"%s Ban Information",save[4]);
  475.          format(datetime,sizeof(datetime),"%s %s",save[1],save[2]);
  476.          format(str, sizeof(str),"{00FFFF}Player Name: {33FF33}%s\n{00FFFF}Banned By: {33FF33}%s\n{00FFFF}Date: {33FF33}%s\n{00FFFF}Reason: {33FF33}%s",save[4],save[3],datetime,save5);
  477.          ShowPlayerDialog(playerid, 0, DIALOG_STYLE_MSGBOX, str2, str, "Close","");
  478.        } if(banned1 == 0) {
  479.          cache_get_field_content(0, "tempban", save[0], mysql, 10);
  480.          banned1 = strval(save[0]);
  481.          if(banned1 == 1) {
  482.            new saves[3][128],by[128],expire;
  483.            cache_get_field_content(0, "date", saves[0], mysql, 128);
  484.            cache_get_field_content(0, "time", saves[1], mysql, 128);
  485.            cache_get_field_content(0, "reason", saves[2], mysql, 128);
  486.            cache_get_field_content(0, "name", save[4], mysql, 50);
  487.            cache_get_field_content(0, "bannedby", by, mysql, 128);
  488.            expire = cache_get_field_content_int(0, "bdate",mysql);
  489.            new content[128]; format(content,sizeof content,"%s %s",saves[0],saves[1]);
  490.            format(str2,sizeof(str2),"%s Ban Information",save[4]);
  491.            new date,Year,Month,Day;
  492.            getdate(Year,Month,Day);
  493.            Year *= 12;
  494.            Year *= 30;
  495.            Month *= 30;
  496.            date = Year+Month+Day;
  497.            expire -= date;
  498.            format(str, sizeof(str),"{00FFFF}Player Name: {33FF33}%s\n{00FFFF}Banned By: {33FF33}%s\n{00FFFF}Date: {33FF33}%s\n{00FFFF}Reason: {33FF33}%s\n{00FFFF}Ban Expire After: {33FF33}%d Days"
  499.            ,save[4],by,content,saves[2],expire);
  500.            ShowPlayerDialog(playerid, 0, DIALOG_STYLE_MSGBOX, str2, str, "Close","");
  501.          } else return ShowPlayerDialog(playerid, 2648, DIALOG_STYLE_INPUT, "Ban List", "Player name you entered are not banned", "Search", "Close");
  502.        }
  503.    } else return ShowPlayerDialog(playerid, 2648, DIALOG_STYLE_INPUT, "Ban List", "No bans were found.", "Search", "Close");
  504.    return 1;
  505. }
  506.  
  507.  
  508. public kickplayer(playerid) {
  509.     return Kick(playerid);
  510. }
  511. //==================================a fuction=================================//
  512. strtok(const string[], &index)
  513. {
  514.     new length = strlen(string);
  515.     while ((index < length) && (string[index] <= ' '))
  516.     {
  517.         index++;
  518.     }
  519.  
  520.     new offset = index;
  521.     new result[20];
  522.     while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  523.     {
  524.         result[index - offset] = string[index];
  525.         index++;
  526.     }
  527.     result[index - offset] = EOS;
  528.     return result;
  529. }
  530. pName(playerid) {
  531.   new pname[MAX_PLAYER_NAME];
  532.   GetPlayerName(playerid, pname, sizeof(pname));
  533.   return pname;
  534. }
  535. //============================================================================//
Advertisement
Add Comment
Please, Sign In to add comment