Advertisement
Guest User

Serial Ban System [0.1]

a guest
Feb 20th, 2013
4,492
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.93 KB | None | 0 0
  1. //#############################################################
  2. //Serial Ban Filterscript
  3. //Written by GWX from http://forum.sa-mp.com
  4. //Profile Link: http://forum.sa-mp.com/member.php?u=193359
  5. //#############################################################
  6.  
  7.  
  8. // This program is free software: you can redistribute it and/or modify
  9. // it under the terms of the GNU General Public License as published by
  10. // the Free Software Foundation, either version 3 of the License, or
  11. // (at your option) any later version.
  12. //
  13. // This program is distributed in the hope that it will be useful,
  14. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. // GNU General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU General Public License
  19. // along with this program.  If not, see <http://www.gnu.org/licenses/>.
  20.  
  21. //#############################################################
  22.  
  23.  
  24. #include <a_samp>
  25. #include <sscanf2>
  26.  
  27. #define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
  28.  
  29. native gpci(playerid, serial[], maxlen);
  30. new Location[100] = "/Serial_Bans/%s.lock";
  31.  
  32. public OnPlayerConnect(playerid)
  33. {
  34.     new Code[50], Line[256];
  35.     gpci(playerid, Code, sizeof Code);
  36.  
  37.     format(Line, sizeof(Line), Location, Code);
  38.     if(fexist(Line)) return Kick(playerid);
  39.  
  40.     return 1;
  41. }
  42.  
  43.  
  44. public OnPlayerCommandText(playerid, cmdtext[])
  45. {
  46.     dcmd(Ban, 3, cmdtext);
  47.     dcmd(Code, 4, cmdtext);
  48.     return 0;
  49. }
  50.  
  51.  
  52. dcmd_Ban(playerid, params[])
  53. {
  54.     if(!IsPlayerAdmin(playerid)) return 0;
  55.  
  56.     new Code[50], Line[128], User, Nickname[MAX_PLAYER_NAME];
  57.  
  58.     if(sscanf(params, "u", User)) return SendClientMessage(playerid, 0xFF0000FF, "{FF0000}Command:{FF0000} {FFFFFF}/Ban <Nickname / ID>{FFFFFF}");
  59.     if(!IsPlayerConnected(User)) return SendClientMessage(playerid, 0xFF0000FF, "User was not fount. Please check input data.");
  60.  
  61.     gpci(User, Code, sizeof(Code));
  62.     format(Line, sizeof(Line), Location, Code);
  63.    
  64.     GetPlayerName(User, Nickname, sizeof(Nickname));
  65.  
  66.     new File:Datoteka = fopen(Line, io_write);
  67.     fwrite(Datoteka, Nickname);
  68.     fclose(Datoteka);
  69.  
  70.     Kick(User);
  71.    
  72.     SendClientMessage(playerid, 0xFFFFFF, "User was sucesefully added to ban list and kicked from server.");
  73.     return 1;
  74. }
  75.  
  76.  
  77.  
  78.  
  79. dcmd_Code(playerid, params[])
  80. {
  81.     if(!IsPlayerAdmin(playerid)) return 0;
  82.  
  83.     new Code[50], Line[128], User;
  84.  
  85.     if(sscanf(params, "u", User)) return SendClientMessage(playerid, 0xFF0000FF, "{FF0000}Komanda:{FF0000} {FFFFFF}/Code <Nickname / ID>{FFFFFF}");
  86.     if(!IsPlayerConnected(User)) return SendClientMessage(playerid, 0xFF0000FF, "User was not fount. Please check input data.");
  87.  
  88.     gpci(User, Code, sizeof(Code));
  89.     format(Line, sizeof(Line), "User Serial: %s", Code);
  90.  
  91.  
  92.     SendClientMessage(playerid, 0xFFFFFF, Line);
  93.     return 1;
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement