Advertisement
Martex

FS

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