Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 5.97 KB | None | 0 0
  1. //Define
  2. #define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
  3.  
  4. //Befehl
  5. dcmd_kick(playerid,params[])
  6. {
  7.     new pID;
  8.     new Grund[256];
  9.     if(sscanf(params, "us", pID, Grund))
  10.     {
  11.         return SendClientMessage(playerid,COLOR_RED,"Benutzung: /kick [Playerid] [Grund]");
  12.     }
  13.     if(!IsPlayerConnected(pID))
  14.     {
  15.         return SendClientMessage(playerid,COLOR_RED,"Kein Spieler mit angegebener ID Online");
  16.     }
  17.     if(SpielerInfo[playerid][alvl]<1)
  18.     {
  19.         return SendClientMessage(playerid,COLOR_RED,"Du bist kein Admin Level 1!");
  20.     }
  21.     else
  22.     {
  23.         if(SpielerInfo[playerid][alvl]<SpielerInfo[pID][alvl])
  24.         {
  25.             return SendClientMessage(playerid,COLOR_RED,"Du kannst diesen Befehl nicht an höherrangigen Admins ausführen!");
  26.         }
  27.         else
  28.         {
  29.             new name[MAX_PLAYER_NAME], string[256];
  30.             GetPlayerName(pID, name, sizeof(name));
  31.             new aname[MAX_PLAYER_NAME];
  32.             GetPlayerName(playerid, aname, sizeof(aname));
  33.             format(string, sizeof(string), "[AdmCmd] %s wurde von %s gekickt. Grund: %s ", name, aname, Grund);
  34.             SendClientMessageToAll(COLOR_RED, string);
  35.             Kick(pID);
  36.         }
  37.     }
  38.     return 1;
  39. }
  40.  
  41.  
  42.  
  43.  
  44.  
  45. //=============================================SSCANF ZEUGS=========================================//
  46. stock sscanf(string[], format[], {Float,_}:...)
  47. {
  48.     #if defined isnull
  49.         if (isnull(string))
  50.     #else
  51.         if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
  52.     #endif
  53.         {
  54.             return format[0];
  55.         }
  56.     #pragma tabsize 4
  57.     new
  58.         formatPos = 0,
  59.         stringPos = 0,
  60.         paramPos = 2,
  61.         paramCount = numargs(),
  62.         delim = ' ';
  63.     while (string[stringPos] && string[stringPos] <= ' ')
  64.     {
  65.         stringPos++;
  66.     }
  67.     while (paramPos < paramCount && string[stringPos])
  68.     {
  69.         switch (format[formatPos++])
  70.         {
  71.             case '\0':
  72.             {
  73.                 return 0;
  74.             }
  75.             case 'i', 'd':
  76.             {
  77.                 new
  78.                     neg = 1,
  79.                     num = 0,
  80.                     ch = string[stringPos];
  81.                 if (ch == '-')
  82.                 {
  83.                     neg = -1;
  84.                     ch = string[++stringPos];
  85.                 }
  86.                 do
  87.                 {
  88.                     stringPos++;
  89.                     if ('0' <= ch <= '9')
  90.                     {
  91.                         num = (num * 10) + (ch - '0');
  92.                     }
  93.                     else
  94.                     {
  95.                         return -1;
  96.                     }
  97.                 }
  98.                 while ((ch = string[stringPos]) > ' ' && ch != delim);
  99.                 setarg(paramPos, 0, num * neg);
  100.             }
  101.             case 'h', 'x':
  102.             {
  103.                 new
  104.                     num = 0,
  105.                     ch = string[stringPos];
  106.                 do
  107.                 {
  108.                     stringPos++;
  109.                     switch (ch)
  110.                     {
  111.                         case 'x', 'X':
  112.                         {
  113.                             num = 0;
  114.                             continue;
  115.                         }
  116.                         case '0' .. '9':
  117.                         {
  118.                             num = (num << 4) | (ch - '0');
  119.                         }
  120.                         case 'a' .. 'f':
  121.                         {
  122.                             num = (num << 4) | (ch - ('a' - 10));
  123.                         }
  124.                         case 'A' .. 'F':
  125.                         {
  126.                             num = (num << 4) | (ch - ('A' - 10));
  127.                         }
  128.                         default:
  129.                         {
  130.                             return -1;
  131.                         }
  132.                     }
  133.                 }
  134.                 while ((ch = string[stringPos]) > ' ' && ch != delim);
  135.                 setarg(paramPos, 0, num);
  136.             }
  137.             case 'c':
  138.             {
  139.                 setarg(paramPos, 0, string[stringPos++]);
  140.             }
  141.             case 'f':
  142.             {
  143.  
  144.                 new changestr[16], changepos = 0, strpos = stringPos;
  145.                 while(changepos < 16 && string[strpos] && string[strpos] != delim)
  146.                 {
  147.                     changestr[changepos++] = string[strpos++];
  148.                     }
  149.                 changestr[changepos] = '\0';
  150.                 setarg(paramPos,0,_:floatstr(changestr));
  151.             }
  152.             case 'p':
  153.             {
  154.                 delim = format[formatPos++];
  155.                 continue;
  156.             }
  157.             case '\'':
  158.             {
  159.                 new
  160.                     end = formatPos - 1,
  161.                     ch;
  162.                 while ((ch = format[++end]) && ch != '\'') {}
  163.                 if (!ch)
  164.                 {
  165.                     return -1;
  166.                 }
  167.                 format[end] = '\0';
  168.                 if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
  169.                 {
  170.                     if (format[end + 1])
  171.                     {
  172.                         return -1;
  173.                     }
  174.                     return 0;
  175.                 }
  176.                 format[end] = '\'';
  177.                 stringPos = ch + (end - formatPos);
  178.                 formatPos = end + 1;
  179.             }
  180.             case 'u':
  181.             {
  182.                 new
  183.                     end = stringPos - 1,
  184.                     id = 0,
  185.                     bool:num = true,
  186.                     ch;
  187.                 while ((ch = string[++end]) && ch != delim)
  188.                 {
  189.                     if (num)
  190.                     {
  191.                         if ('0' <= ch <= '9')
  192.                         {
  193.                             id = (id * 10) + (ch - '0');
  194.                         }
  195.                         else
  196.                         {
  197.                             num = false;
  198.                         }
  199.                     }
  200.                 }
  201.                 if (num && IsPlayerConnected(id))
  202.                 {
  203.                     setarg(paramPos, 0, id);
  204.                 }
  205.                 else
  206.                 {
  207.                     #if !defined foreach
  208.                         #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
  209.                         #define __SSCANF_FOREACH__
  210.                     #endif
  211.                     string[end] = '\0';
  212.                     num = false;
  213.                     new
  214.                         name[MAX_PLAYER_NAME];
  215.                     id = end - stringPos;
  216.                     foreach (Player, playerid)
  217.                     {
  218.                         GetPlayerName(playerid, name, sizeof (name));
  219.                         if (!strcmp(name, string[stringPos], true, id))
  220.                         {
  221.                             setarg(paramPos, 0, playerid);
  222.                             num = true;
  223.                             break;
  224.                         }
  225.                     }
  226.                     if (!num)
  227.                     {
  228.                         setarg(paramPos, 0, INVALID_PLAYER_ID);
  229.                     }
  230.                     string[end] = ch;
  231.                     #if defined __SSCANF_FOREACH__
  232.                         #undef foreach
  233.                         #undef __SSCANF_FOREACH__
  234.                     #endif
  235.                 }
  236.                 stringPos = end;
  237.             }
  238.             case 's', 'z':
  239.             {
  240.                 new
  241.                     i = 0,
  242.                     ch;
  243.                 if (format[formatPos])
  244.                 {
  245.                     while ((ch = string[stringPos++]) && ch != delim)
  246.                     {
  247.                         setarg(paramPos, i++, ch);
  248.                     }
  249.                     if (!i)
  250.                     {
  251.                         return -1;
  252.                     }
  253.                 }
  254.                 else
  255.                 {
  256.                     while ((ch = string[stringPos++]))
  257.                     {
  258.                         setarg(paramPos, i++, ch);
  259.                     }
  260.                 }
  261.                 stringPos--;
  262.                 setarg(paramPos, i, '\0');
  263.             }
  264.             default:
  265.             {
  266.                 continue;
  267.             }
  268.         }
  269.         while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
  270.         {
  271.             stringPos++;
  272.         }
  273.         while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
  274.         {
  275.             stringPos++;
  276.         }
  277.         paramPos++;
  278.     }
  279.     do
  280.     {
  281.         if ((delim = format[formatPos++]) > ' ')
  282.         {
  283.             if (delim == '\'')
  284.             {
  285.                 while ((delim = format[formatPos++]) && delim != '\'') {}
  286.             }
  287.             else if (delim != 'z')
  288.             {
  289.                 return delim;
  290.             }
  291.         }
  292.     }
  293.     while (delim > ' ');
  294.     return 0;
  295. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement