Advertisement
WeenSoares_

[FilterScript]WSBan - Sistema de Banimento - ZCMD

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