Advertisement
Guest User

Serialbanner by Gredsoft

a guest
Jul 17th, 2012
459
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 6.95 KB | None | 0 0
  1. #include <a_samp>
  2. #include <ocmd>
  3. #include <SII>
  4.  
  5. #define COLOR_GREY      0x969696FF
  6. #define COLOR_BAN       0xA9C4E4FF
  7.  
  8. native gpci(playerid, const serial[ ], maxlen);
  9.  
  10. public OnFilterScriptInit()
  11. {
  12.     print("\nSerialbanner by Gredsoft loaded\n");
  13.     return 1;
  14. }
  15.  
  16. public OnFilterScriptExit()
  17. {
  18.     print("\nSerialbanner by Gredsoft unloaded\n");
  19.     return 1;
  20. }
  21.  
  22. public OnPlayerConnect(playerid)
  23. {
  24.     if(fexist(GetPlayerSerialINI(playerid))) {
  25.         SendClientMessage(playerid,COLOR_BAN,"You are banned from this server.");
  26.         Kick(playerid);
  27.     }
  28.     return 1;
  29. }
  30.  
  31. ocmd:sban(playerid,params[])
  32. {
  33.     new targetid,reason[256];
  34.     if(!IsPlayerAdmin(playerid))return SendClientMessage(playerid,0xC20000FF,"Du besitzt nicht die benötigten Rechte für diese Aktion!");
  35.     if(sscanf(params,"us",targetid,reason))return SendClientMessage(playerid,0xFFA300FF, "BENUTZUNG: /sban <SpielerID / Teil vom Namen> <Grund>");
  36.     if(!IsPlayerConnected(targetid))return SendClientMessage(playerid,0xC20000FF,"Dieser Spieler ist nicht verbunden!");
  37.     if(INI_Open(GetPlayerSerialINI(targetid))) {
  38.         INI_WriteInt("Banned",1);
  39.         INI_Save();
  40.         INI_Close();
  41.     }
  42.     new playername[MAX_PLAYER_NAME],targetname[MAX_PLAYER_NAME],string[256];
  43.     GetPlayerName(playerid,playername,sizeof(playername));
  44.     GetPlayerName(targetid,targetname,sizeof(targetname));
  45.     format(string,sizeof(string),"%s wurde von %s gebannt. Grund: %s ( Serial-Ban )",targetname,playername,reason);
  46.     SendClientMessageToAll(0xC5242DFF,string);
  47.     Kick(targetid);
  48.     return 1;
  49. }
  50. ocmd:ls(playerid,params[])
  51. {
  52.     if(!IsPlayerAdmin(playerid))return SendClientMessage(playerid,0xC20000FF,"Du besitzt nicht die benötigten Rechte für diese Aktion!");
  53.     SendClientMessage(playerid,COLOR_GREY,"-- Serials aller Spieler --");
  54.     for(new i = 0; i < MAX_PLAYERS; i++) {
  55.         if(IsPlayerConnected(i)) {
  56.             new playername[MAX_PLAYER_NAME],str[256];
  57.             GetPlayerName(i,playername,sizeof(playername));
  58.             format(str,sizeof(str),"~~ %s - %s ~~",playername,GetPlayerSerial(i));
  59.             SendClientMessage(playerid,COLOR_GREY,str);
  60.         }
  61.     }
  62.     return 1;
  63. }
  64.  
  65. stock GetPlayerSerial(playerid)
  66. {
  67.     new serial[512];
  68.     gpci(playerid,serial,sizeof(serial));
  69.     return serial;
  70. }
  71.  
  72. stock GetPlayerSerialINI(playerid)
  73. {
  74.     new serialini[512];
  75.     format(serialini,sizeof(serialini),"Serialbans/%s.sb",GetPlayerSerial(playerid));
  76.     return serialini;
  77. }
  78.  
  79. stock sscanf(string[], format[], {Float,_}:...)
  80. {
  81.     #if defined isnull
  82.         if (isnull(string))
  83.     #else
  84.         if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
  85.     #endif
  86.         {
  87.             return format[0];
  88.         }
  89.     #pragma tabsize 4
  90.     new
  91.         formatPos = 0,
  92.         stringPos = 0,
  93.         paramPos = 2,
  94.         paramCount = numargs(),
  95.         delim = ' ';
  96.     while (string[stringPos] && string[stringPos] <= ' ')
  97.     {
  98.         stringPos++;
  99.     }
  100.     while (paramPos < paramCount && string[stringPos])
  101.     {
  102.         switch (format[formatPos++])
  103.         {
  104.             case '\0':
  105.             {
  106.                 return 0;
  107.             }
  108.             case 'i', 'd':
  109.             {
  110.                 new
  111.                     neg = 1,
  112.                     num = 0,
  113.                     ch = string[stringPos];
  114.                 if (ch == '-')
  115.                 {
  116.                     neg = -1;
  117.                     ch = string[++stringPos];
  118.                 }
  119.                 do
  120.                 {
  121.                     stringPos++;
  122.                     if ('0' <= ch <= '9')
  123.                     {
  124.                         num = (num * 10) + (ch - '0');
  125.                     }
  126.                     else
  127.                     {
  128.                         return -1;
  129.                     }
  130.                 }
  131.                 while ((ch = string[stringPos]) > ' ' && ch != delim);
  132.                 setarg(paramPos, 0, num * neg);
  133.             }
  134.             case 'h', 'x':
  135.             {
  136.                 new
  137.                     num = 0,
  138.                     ch = string[stringPos];
  139.                 do
  140.                 {
  141.                     stringPos++;
  142.                     switch (ch)
  143.                     {
  144.                         case 'x', 'X':
  145.                         {
  146.                             num = 0;
  147.                             continue;
  148.                         }
  149.                         case '0' .. '9':
  150.                         {
  151.                             num = (num << 4) | (ch - '0');
  152.                         }
  153.                         case 'a' .. 'f':
  154.                         {
  155.                             num = (num << 4) | (ch - ('a' - 10));
  156.                         }
  157.                         case 'A' .. 'F':
  158.                         {
  159.                             num = (num << 4) | (ch - ('A' - 10));
  160.                         }
  161.                         default:
  162.                         {
  163.                             return -1;
  164.                         }
  165.                     }
  166.                 }
  167.                 while ((ch = string[stringPos]) > ' ' && ch != delim);
  168.                 setarg(paramPos, 0, num);
  169.             }
  170.             case 'c':
  171.             {
  172.                 setarg(paramPos, 0, string[stringPos++]);
  173.             }
  174.             case 'f':
  175.             {
  176.  
  177.                 new changestr[16], changepos = 0, strpos = stringPos;
  178.                 while(changepos < 16 && string[strpos] && string[strpos] != delim)
  179.                 {
  180.                     changestr[changepos++] = string[strpos++];
  181.                     }
  182.                 changestr[changepos] = '\0';
  183.                 setarg(paramPos,0,_:floatstr(changestr));
  184.             }
  185.             case 'p':
  186.             {
  187.                 delim = format[formatPos++];
  188.                 continue;
  189.             }
  190.             case '\'':
  191.             {
  192.                 new
  193.                     end = formatPos - 1,
  194.                     ch;
  195.                 while ((ch = format[++end]) && ch != '\'') {}
  196.                 if (!ch)
  197.                 {
  198.                     return -1;
  199.                 }
  200.                 format[end] = '\0';
  201.                 if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
  202.                 {
  203.                     if (format[end + 1])
  204.                     {
  205.                         return -1;
  206.                     }
  207.                     return 0;
  208.                 }
  209.                 format[end] = '\'';
  210.                 stringPos = ch + (end - formatPos);
  211.                 formatPos = end + 1;
  212.             }
  213.             case 'u':
  214.             {
  215.                 new
  216.                     end = stringPos - 1,
  217.                     id = 0,
  218.                     bool:num = true,
  219.                     ch;
  220.                 while ((ch = string[++end]) && ch != delim)
  221.                 {
  222.                     if (num)
  223.                     {
  224.                         if ('0' <= ch <= '9')
  225.                         {
  226.                             id = (id * 10) + (ch - '0');
  227.                         }
  228.                         else
  229.                         {
  230.                             num = false;
  231.                         }
  232.                     }
  233.                 }
  234.                 if (num && IsPlayerConnected(id))
  235.                 {
  236.                     setarg(paramPos, 0, id);
  237.                 }
  238.                 else
  239.                 {
  240.                     #if !defined foreach
  241.                         #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
  242.                         #define __SSCANF_FOREACH__
  243.                     #endif
  244.                     string[end] = '\0';
  245.                     num = false;
  246.                     new
  247.                         name[MAX_PLAYER_NAME];
  248.                     id = end - stringPos;
  249.                     foreach (Player, playerid)
  250.                     {
  251.                         GetPlayerName(playerid, name, sizeof (name));
  252.                         if (!strcmp(name, string[stringPos], true, id))
  253.                         {
  254.                             setarg(paramPos, 0, playerid);
  255.                             num = true;
  256.                             break;
  257.                         }
  258.                     }
  259.                     if (!num)
  260.                     {
  261.                         setarg(paramPos, 0, INVALID_PLAYER_ID);
  262.                     }
  263.                     string[end] = ch;
  264.                     #if defined __SSCANF_FOREACH__
  265.                         #undef foreach
  266.                         #undef __SSCANF_FOREACH__
  267.                     #endif
  268.                 }
  269.                 stringPos = end;
  270.             }
  271.             case 's', 'z':
  272.             {
  273.                 new
  274.                     i = 0,
  275.                     ch;
  276.                 if (format[formatPos])
  277.                 {
  278.                     while ((ch = string[stringPos++]) && ch != delim)
  279.                     {
  280.                         setarg(paramPos, i++, ch);
  281.                     }
  282.                     if (!i)
  283.                     {
  284.                         return -1;
  285.                     }
  286.                 }
  287.                 else
  288.                 {
  289.                     while ((ch = string[stringPos++]))
  290.                     {
  291.                         setarg(paramPos, i++, ch);
  292.                     }
  293.                 }
  294.                 stringPos--;
  295.                 setarg(paramPos, i, '\0');
  296.             }
  297.             default:
  298.             {
  299.                 continue;
  300.             }
  301.         }
  302.         while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
  303.         {
  304.             stringPos++;
  305.         }
  306.         while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
  307.         {
  308.             stringPos++;
  309.         }
  310.         paramPos++;
  311.     }
  312.     do
  313.     {
  314.         if ((delim = format[formatPos++]) > ' ')
  315.         {
  316.             if (delim == '\'')
  317.             {
  318.                 while ((delim = format[formatPos++]) && delim != '\'') {}
  319.             }
  320.             else if (delim != 'z')
  321.             {
  322.                 return delim;
  323.             }
  324.         }
  325.     }
  326.     while (delim > ' ');
  327.     return 0;
  328. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement