Advertisement
WeenSoares_

[FilterScript]WSBan - Sistema de Banimento - ZCMD

Jan 5th, 2012
360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.55 KB | None | 0 0
  1. /*
  2. [FilterScrit]WSBan - Sistema de Banimento
  3. Criado por: WeenSoares.
  4. Ninguém está autorizado a fazer postagens deste
  5. [FilterScript] em outro site, a não ser com minha autoriazação !
  6. Todos os comandos foram feitos em ZCMD & SSCANF.
  7. Tamanho: 15KB
  8. Data/Hora da criação: 05/01/2012 - 13:12:42
  9. Contato: weensoares@live.com
  10. */
  11. #include <a_samp>
  12. #include <SII>
  13. #include <zcmd>
  14. #include <sscanf2>
  15. //==============================/*FORWARDS*/==============================//
  16. forward Banido(playerid);
  17. forward CheckBan(playerid);
  18. //==============================/*CORES*/==============================//
  19. #define COR_LARANJA 0xFF7100FF
  20. #define COR_BRANCO 0xFFFFFFAA
  21. #define COR_VERDEFORTE 0x33AA33AA
  22. #define COR_AZUL 0x33AAFFFF
  23. #define COR_AZULCLARO 0x00FFFFAA
  24. #define COR_VERMELHO 0xFF0000FF
  25. #define COR_AZUL 0x33AAFFFF
  26. //==============================/*DEFINIÇÃO DE DIALOG*/==============================//
  27. #define DIALOG_BANIDO 555
  28. //==============================/*NEWS*/==============================//
  29. new file[100];
  30. new TimerBan[MAX_PLAYERS];
  31. new playername[MAX_PLAYER_NAME];
  32. new Motivo[64];
  33. new Ip[24];
  34. new DiaBan;
  35. //==============================/*FILTERSCRIPTINIT*/==============================//
  36. public OnFilterScriptInit()
  37. {
  38.  
  39. print("******************************************************");
  40. print("* [FilterScrit]WSBan - Sistema de Banimento *\n");
  41. print("* Carregando... *\n\n");
  42. print("* Carregado 100%. *");
  43. print("******************************************************");
  44. return 1;
  45. }
  46. //==============================/*CALLBACKS*/==============================//
  47. public OnPlayerConnect(playerid)
  48. {
  49. CheckBan(playerid);
  50. new string[128], Adm[21], MotivoBan[100], Hora, Minuto, Segundo, HoraBan, MinutoBan, SegundoBan, Dia, Mes, Ano, MesBan, AnoBan;
  51. GetPlayerName(playerid, playername, sizeof(playername));
  52. GetPlayerIp(playerid, Ip, sizeof(Ip));
  53. format(file, sizeof(file), "ContasBanidas/%s.ini", playername);
  54. if(fexist(file))
  55. {
  56. INI_Open(file);
  57. INI_ReadString(Adm, "Admin", 24);
  58. INI_ReadString(MotivoBan, "MotivoBan", 100);
  59. Dia = INI_ReadInt("Dia");
  60. Mes = INI_ReadInt("Mes");
  61. Ano = INI_ReadInt("Ano");
  62. DiaBan = INI_ReadInt("DiaBan");
  63. MesBan = INI_ReadInt("MesBan");
  64. AnoBan = INI_ReadInt("AnoBan");
  65. Hora = INI_ReadInt("Hora");
  66. Minuto = INI_ReadInt("Minuto");
  67. Segundo = INI_ReadInt("Segundo");
  68. HoraBan = INI_ReadInt("HoraBan");
  69. MinutoBan = INI_ReadInt("MinutoBan");
  70. SegundoBan = INI_ReadInt("SegundoBan");
  71. SendClientMessage(playerid, COR_BRANCO, "----------------------------------------------------------------------------------------------------------------------");
  72. SendClientMessage(playerid, COR_LARANJA, " [INFO] Seu nick está banido. ");
  73. format(string, sizeof(string), "[WSBan]: Admin: %s | Data: %d/%d/%d | Hora: %d:%d:%d | Motivo: %s ", Adm, Dia, Mes, Ano, Hora, Minuto, Segundo, MotivoBan);
  74. SendClientMessage(playerid, COR_LARANJA, string);
  75. format(string, sizeof(string), "[WSBan]: Vencimento Data: %d/%d/%d | Hora: %d:%d:%d", DiaBan, MesBan, AnoBan, HoraBan, MinutoBan, SegundoBan);
  76. SendClientMessage(playerid, COR_LARANJA, string);
  77. SendClientMessage(playerid, COR_BRANCO, "----------------------------------------------------------------------------------------------------------------------");
  78. INI_Close();
  79. TimerBan[playerid] = 5;
  80. SetTimerEx("Banido", 1000, true, "i", playerid);
  81. return 1;
  82. }
  83. format(file, sizeof(file), "IPsBanidos/%s.ini", Ip);
  84. if(fexist(file))
  85. {
  86. INI_Open(file);
  87. INI_ReadString(Adm, "Admin", 24);
  88. INI_ReadString(MotivoBan, "MotivoBan", 100);
  89. Dia = INI_ReadInt("Dia");
  90. Mes = INI_ReadInt("Mes");
  91. Ano = INI_ReadInt("Ano");
  92. DiaBan = INI_ReadInt("DiaBan");
  93. MesBan = INI_ReadInt("MesBan");
  94. AnoBan = INI_ReadInt("AnoBan");
  95. Hora = INI_ReadInt("Hora");
  96. Minuto = INI_ReadInt("Minuto");
  97. Segundo = INI_ReadInt("Segundo");
  98. HoraBan = INI_ReadInt("HoraBan");
  99. MinutoBan = INI_ReadInt("MinutoBan");
  100. SegundoBan = INI_ReadInt("SegundoBan");
  101. SendClientMessage(playerid, COR_BRANCO, "----------------------------------------------------------------------------------------------------------------------");
  102. SendClientMessage(playerid, COR_LARANJA, " [INFO] Seu IP está banido. ");
  103. format(string, sizeof(string), "[WSBan]: Admin: %s | Data: %d/%d/%d | Hora: %d:%d:%d | Motivo: %s ", Adm, Dia, Mes, Ano, Hora, Minuto, Segundo, MotivoBan);
  104. SendClientMessage(playerid, COR_LARANJA, string);
  105. format(string, sizeof(string), "[WSBan]: Vencimento Data: %d/%d/%d | Hora: %d:%d:%d", DiaBan, MesBan, AnoBan, HoraBan, MinutoBan, SegundoBan);
  106. SendClientMessage(playerid, COR_LARANJA, string);
  107. SendClientMessage(playerid, COR_BRANCO, "----------------------------------------------------------------------------------------------------------------------");
  108. INI_Close();
  109. TimerBan[playerid] = 5;
  110. SetTimerEx("Banido", 1000, true, "i", playerid);
  111. return 1;
  112. }
  113. return 1;
  114. }
  115. public OnPlayerRequestSpawn(playerid)
  116. {
  117. new string[128];
  118. if(TimerBan[playerid] >= 1)
  119. {
  120. format(file, sizeof(file), "ContasBanidas/%s.ini", playername);
  121. if(INI_Open(file))
  122. {
  123. format(string, sizeof(string), "[WSBan]: Você está banido e será kickado em %d segundo(s)", TimerBan[playerid]);
  124. ShowPlayerDialog(playerid, DIALOG_BANIDO, DIALOG_STYLE_MSGBOX, "## NICK BANIDO ##", string, "Ok", "");
  125. return 1;
  126. }
  127. format(file, sizeof(file), "IPsBanidos/%s.ini", Ip);
  128. if(INI_Open(file))
  129. {
  130. format(string, sizeof(string), "[WSBan]: Você está banido e será kickado em %d segundo(s)", TimerBan[playerid]);
  131. ShowPlayerDialog(playerid, DIALOG_BANIDO, DIALOG_STYLE_MSGBOX, "## NICK BANIDO ##", string, "Ok", "");
  132. return 1;
  133. }
  134. }
  135. return 1;
  136. }
  137. //================= /*COMANDOS*/ ==========================//
  138. CMD:ban(playerid, params[])
  139. {
  140. new string[128], Dia, Mes, Ano, Hora, Minuto, Segundo, MesBan, AnoBan,
  141. giveplayerid, giveplayername[MAX_PLAYER_NAME];
  142. if(sscanf(params, "uds[128]", giveplayerid, DiaBan, Motivo))
  143. {
  144. SendClientMessage(playerid, 0x33AA33AA, "Uso correto: /ban [id] [dias] [motivo]");
  145. }
  146. else
  147. {
  148. getdate(Ano, Mes, Dia);
  149. gettime(Hora, Minuto, Segundo);
  150. GetPlayerName(playerid, playername, sizeof(playername));
  151. GetPlayerName(giveplayerid, giveplayername, sizeof(giveplayername));
  152. GetPlayerIp(giveplayerid, Ip, sizeof(Ip));
  153. if(IsPlayerConnected(playerid))
  154. {
  155. if(IsPlayerAdmin(playerid))
  156. {
  157. if(IsPlayerConnected(giveplayerid))
  158. {
  159. if(DiaBan > 30)
  160. {
  161. SendClientMessage(playerid, COR_AZULCLARO, "[WSBan]: Você só pode banir este player no máximo 30 dias!");
  162. return 1;
  163. }
  164. format(string, sizeof(string), "[WSBan]: O Administrador %s baniu %s por %i dias, [Motivo: %s]", playername, giveplayername, DiaBan, Motivo);
  165. SendClientMessageToAll(COR_VERMELHO, string);
  166. format(string, sizeof(string), "%d/%d/%d", Dia, Mes, Ano);
  167. format(file, sizeof(file), "ContasBanidas/%s.ini", giveplayername);
  168. if(INI_Open(file))
  169. {
  170. INI_WriteString("Admin", playername);
  171. INI_WriteInt("Dia", Dia);
  172. INI_WriteInt("Mes", Mes);
  173. INI_WriteInt("Ano", Ano);
  174. INI_WriteInt("Hora", Hora);
  175. INI_WriteInt("Minuto", Minuto);
  176. INI_WriteInt("Segundo", Segundo);
  177. INI_WriteInt("DiaBan", Dia);
  178. INI_WriteInt("MesBan", Mes);
  179. INI_WriteInt("AnoBan", Ano);
  180. INI_WriteInt("HoraBan", Hora);
  181. INI_WriteInt("MinutoBan", Minuto);
  182. INI_WriteInt("SegundoBan", Segundo);
  183. INI_WriteString("MotivoBan", Motivo);
  184. INI_WriteString("IP", Ip);
  185. Dia += DiaBan;
  186. INI_WriteInt("DiaBan", Dia);
  187. while(Dia > 31)
  188. {
  189. Dia -= 31;
  190. Mes++;
  191. INI_WriteInt("DiaBan", Dia);
  192. INI_WriteInt("MesBan", Mes);
  193. }
  194. while(Mes > 12)
  195. {
  196. Mes -= 12;
  197. Ano++;
  198. INI_WriteInt("MesBan", Mes);
  199. INI_WriteInt("AnoBan", Ano);
  200. }
  201. DiaBan = INI_ReadInt("DiaBan");
  202. MesBan = INI_ReadInt("MesBan");
  203. AnoBan = INI_ReadInt("AnoBan");
  204. INI_Save();
  205. INI_Close();
  206. }
  207. format(file, sizeof(file), "IPsBanidos/%s.ini", Ip);
  208. if(INI_Open(file))
  209. {
  210. INI_WriteString("Admin", playername);
  211. INI_WriteInt("Dia", Dia);
  212. INI_WriteInt("Mes", Mes);
  213. INI_WriteInt("Ano", Ano);
  214. INI_WriteInt("Hora", Hora);
  215. INI_WriteInt("Minuto", Minuto);
  216. INI_WriteInt("Segundo", Segundo);
  217. INI_WriteInt("DiaBan", DiaBan);
  218. INI_WriteInt("MesBan", MesBan);
  219. INI_WriteInt("AnoBan", AnoBan);
  220. INI_WriteInt("HoraBan", Hora);
  221. INI_WriteInt("MinutoBan", Minuto);
  222. INI_WriteInt("SegundoBan", Segundo);
  223. INI_WriteString("MotivoBan", Motivo);
  224. INI_WriteString("IP", Ip);
  225. INI_Save();
  226. INI_Close();
  227. }
  228. Kick(giveplayerid);
  229. }
  230. else
  231. {
  232. format(string, sizeof(string), "[WSBan]: O ID %d não está online.", giveplayerid);
  233. SendClientMessage(playerid, COR_AZULCLARO, string);
  234. }
  235. }
  236. else
  237. {
  238. SendClientMessage(playerid, COR_AZULCLARO, "[WSBan]: Você não tem permissão para usar este comando!");
  239. }
  240. }
  241. else
  242. {
  243. SendClientMessage(playerid, COR_AZULCLARO, "[WSBan]: Você tem que está logado para usar este comando!");
  244. }
  245. }
  246. return 1;
  247. }
  248. CMD:desbanirconta(playerid, params[])
  249. {
  250. new nomedobanido[MAX_PLAYER_NAME], string[100];
  251. if(sscanf(params, "s[128]", nomedobanido))
  252. {
  253. SendClientMessage(playerid, 0x33AA33AA, "Uso correto: /desbanirconta [nome do banido]");
  254. }
  255. else
  256. {
  257. if(IsPlayerConnected(playerid))
  258. {
  259. if(IsPlayerAdmin(playerid))
  260. {
  261. format(file, sizeof(file), "ContasBanidas/%s.ini", nomedobanido);
  262. if(fexist(file))
  263. {
  264. INI_Open(file);
  265. INI_ReadString(Ip, "IP", 24);
  266. format(string, sizeof(string), "AdmCMD: Você desbaniu a conta: %s", nomedobanido);
  267. SendClientMessage(playerid, COR_AZUL, string);
  268. format(file, sizeof(file), "IPsBanidos/%s.ini", Ip);
  269. INI_Remove(file);
  270. format(file, sizeof(file), "ContasBanidas/%s.ini", nomedobanido);
  271. INI_Remove(file);
  272. INI_Close();
  273. }
  274. else
  275. {
  276. SendClientMessage(playerid, COR_VERMELHO, "[WSBan]: Essa conta não existe ou não esta banida!");
  277. }
  278. }
  279. else
  280. {
  281. SendClientMessage(playerid, COR_AZULCLARO, "[WSBan]: Você não tem permissão para usar este comando!");
  282. }
  283. }
  284. else
  285. {
  286. SendClientMessage(playerid, COR_AZULCLARO, "[WSBan]: Você tem que está logado para usar este comando!");
  287. }
  288. }
  289. return 1;
  290. }
  291. //================= /*TEMPO PARA SER DESCONECTADO*/ ==========================//
  292. public Banido(playerid)
  293. {
  294. switch(TimerBan[playerid])
  295. {
  296. case 5:
  297. {
  298. GameTextForPlayer(playerid, "~y~ 5", 1000, 3);
  299. }
  300. case 4:
  301. {
  302. GameTextForPlayer(playerid, "~y~ 4", 1000, 3);
  303. }
  304. case 3:
  305. {
  306. GameTextForPlayer(playerid, "~y~ 3", 1000, 3);
  307. }
  308. case 2:
  309. {
  310. GameTextForPlayer(playerid, "~y~ 2", 1000, 3);
  311. }
  312. case 1:
  313. {
  314. GameTextForPlayer(playerid, "~y~ 1", 1000, 3);
  315. }
  316. case 0:
  317. {
  318. GameTextForPlayer(playerid, "~r~ Kickado", 1000, 3);
  319. Kick(playerid);
  320. }
  321. }
  322. TimerBan[playerid] --;
  323. }
  324. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  325. {
  326. if(dialogid == DIALOG_BANIDO)
  327. {
  328. if(response)
  329. {
  330. new string[128];
  331. if(TimerBan[playerid] >= 1)
  332. {
  333. format(file, sizeof(file), "ContasBanidas/%s.ini", playername);
  334. if(INI_Open(file))
  335. {
  336. format(string, sizeof(string), "[WSBan]: Você está banido e será kickado em %d segundo(s)", TimerBan[playerid]);
  337. ShowPlayerDialog(playerid, DIALOG_BANIDO, DIALOG_STYLE_MSGBOX, "## NICK BANIDO ##", string, "Ok", "");
  338. return 1;
  339. }
  340. format(file, sizeof(file), "IPsBanidos/%s.ini", Ip);
  341. if(INI_Open(file))
  342. {
  343. format(string, sizeof(string), "[WSBan]: Você está banido e será kickado em %d segundo(s)", TimerBan[playerid]);
  344. ShowPlayerDialog(playerid, DIALOG_BANIDO, DIALOG_STYLE_MSGBOX, "## IP BANIDO ##", string, "Ok", "");
  345. return 1;
  346. }
  347. }
  348. }
  349. }
  350. return 1;
  351. }
  352. public OnPlayerSpawn(playerid)
  353. {
  354. if(TimerBan[playerid] >= 1)
  355. {
  356. ForceClassSelection(playerid);
  357. return 1;
  358. }
  359. return 1;
  360. }
  361. public CheckBan(playerid)
  362. {
  363. GetPlayerIp(playerid, Ip, sizeof(Ip));
  364. GetPlayerName(playerid, playername, sizeof(playername));
  365. new ano[2], mes[2], dia[2], hora[2], minuto[2], segundo[2];
  366. gettime(hora[0], minuto[0], segundo[0]);
  367. getdate(ano[0], mes[0], dia[0]);
  368. format(file, sizeof(file), "ContasBanidas/%s.ini", playername);
  369. if(fexist(file))
  370. {
  371. INI_Open(file);
  372. dia[1] = INI_ReadInt("DiaBan");
  373. mes[1] = INI_ReadInt("MesBan");
  374. ano[1] = INI_ReadInt("AnoBan");
  375. INI_Close();
  376. }
  377. else
  378. {
  379. format(file, sizeof(file), "IPsBanidos/%s.ini", Ip);
  380. INI_Open(file);
  381. dia[1] = INI_ReadInt("DiaBan");
  382. mes[1] = INI_ReadInt("MesBan");
  383. ano[1] = INI_ReadInt("AnoBan");
  384. INI_Close();
  385. }
  386. format(file, sizeof(file), "ContasBanidas/%s.ini", playername);
  387. if(fexist(file))
  388. {
  389. INI_Open(file);
  390. hora[1] = INI_ReadInt("HoraBan");
  391. minuto[1] = INI_ReadInt("MinutoBan");
  392. segundo[1] = INI_ReadInt("SegundoBan");
  393. INI_Close();
  394. }
  395. else
  396. {
  397. format(file, sizeof(file), "IPsBanidos/%s.ini", Ip);
  398. INI_Open(file);
  399. hora[1] = INI_ReadInt("HoraBan");
  400. minuto[1] = INI_ReadInt("MinutoBan");
  401. segundo[1] = INI_ReadInt("SegundoBan");
  402. INI_Close();
  403. }
  404. if(dia[0] >= dia[1] && mes[0] >= mes[1] && ano[0] >= ano[1] &&
  405. hora[0] >= hora[1] && minuto[0] >= minuto[1] && segundo[0] >= segundo[1])
  406. {
  407. GetPlayerName(playerid, playername, sizeof(playername));
  408. format(file, sizeof(file), "ContasBanidas/%s.ini", playername);
  409. if(fexist(file))
  410. {
  411. INI_Remove(file);
  412. INI_Close();
  413. }
  414. GetPlayerIp(playerid, Ip, sizeof(Ip));
  415. format(file, sizeof(file), "IPsBanidos/%s.ini", Ip);
  416. if(fexist(file))
  417. {
  418. INI_Remove(file);
  419. INI_Close();
  420. }
  421. }
  422. return 1;
  423. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement