Guest User

Simple Admin Sys by Norman

a guest
Nov 29th, 2011
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 10.41 KB | None | 0 0
  1. //kleines Amdinsystem von Norman :)
  2.  
  3.  
  4. #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
  5. #include <a_samp>
  6. #define rot 0xFF0019FF
  7.  
  8. public OnFilterScriptInit()
  9. {
  10.     print("\n--------------------------------------");
  11.     print(" Blank Filterscript by your name here");
  12.     print("--------------------------------------\n");
  13.     return 1;
  14. }
  15.  
  16. public OnPlayerCommandText(playerid, cmdtext[])
  17. {
  18.     dcmd(kick,4,cmdtext);
  19.     dcmd(ban,3,cmdtext);
  20.     dcmd(goto,4,cmdtext);
  21.     dcmd(come,4,cmdtext);
  22.     dcmd(slap,4,cmdtext);
  23.     dcmd(freeze,6,cmdtext);
  24.     dcmd(unfreeze,8,cmdtext);
  25.     return 0;
  26. }
  27.     dcmd_kick(playerid,params[]){
  28.         new pID,sGrund[100],pname[100],aname[100],string[100],string2[100];
  29.         if(sscanf(params, "us",pID,sGrund)){
  30.             return SendClientMessage(playerid,rot,"BENUTZE: /kick [playerid][Grund]");
  31.         }
  32.         if(IsPlayerAdmin(playerid)){
  33.                 GetPlayerName(pID, pname, sizeof(pname));
  34.                 GetPlayerName(playerid, aname, sizeof(aname));
  35.                 format(string2,sizeof(string2),"Du wurdest von Admin %s gekickt! (Grund: %s)",aname,sGrund);
  36.                 SendClientMessage(pID,rot,string2);
  37.                 TogglePlayerControllable(pID,0);
  38.                 Kick(pID);//kickt den Spieler
  39.                 format(string,sizeof(string),"Admin %s hat %s gekickt! (Grund: %s)",aname,pname,sGrund);
  40.                 SendClientMessageToAll(rot,string);
  41.             }
  42.             else
  43.             {
  44.             SendClientMessage(playerid,rot,"Du bist kein Admin!");
  45.             }
  46.         return 1;
  47.     }
  48.     dcmd_ban(playerid,params[]){
  49.         new pID,sGrund[100],pname[100],aname[100],string[100],string2[100];
  50.         if(sscanf(params, "us",pID,sGrund)){
  51.             return SendClientMessage(playerid,rot,"BENUTZE: /ban [playerid][Grund]");
  52.         }
  53.         if(IsPlayerAdmin(playerid)){
  54.                 GetPlayerName(pID, pname, sizeof(pname));
  55.                 GetPlayerName(playerid, aname, sizeof(aname));
  56.                 format(string2,sizeof(string2),"Du wurdest von Admin %s gebannt! (Grund: %s)",aname,sGrund);
  57.                 SendClientMessage(pID,rot,string2);
  58.                 TogglePlayerControllable(pID,0);
  59.                 Ban(pID);//kickt den Spieler
  60.                 format(string,sizeof(string),"Admin %s hat %s gebannt! (Grund: %s)",aname,pname,sGrund);
  61.                 SendClientMessageToAll(rot,string);
  62.             }
  63.             else
  64.             {
  65.             SendClientMessage(playerid,rot,"Du bist kein Admin!");
  66.             }
  67.         return 1;
  68.     }
  69.     dcmd_goto(playerid,params[]){
  70.         new pID,Float:x,Float:y,Float:z,aname[100],pname[100],string[100],string2[100];
  71.         if(sscanf(params, "u",pID)){
  72.             return SendClientMessage(playerid, rot,"BENUTZE: /goto [playerid]");
  73.         }
  74.         if(IsPlayerAdmin(playerid)){
  75.             GetPlayerPos(pID,x,y,z);
  76.             SetPlayerPos(playerid,x,y+1,z+1);
  77.             GetPlayerName(pID, pname, sizeof(pname));
  78.             GetPlayerName(playerid, aname, sizeof(aname));
  79.             format(string, sizeof(string),"Du hast dich zu %s geportet!",pname);
  80.             format(string2, sizeof(string2),"Admin %s hat sich zu dir geportet!",aname);
  81.             SendClientMessage(playerid,rot,string);
  82.             SendClientMessage(pID,rot,string2);
  83.         }
  84.         else
  85.         {
  86.             SendClientMessage(playerid,rot,"Du bist kein Admin!");
  87.         }
  88.         return 1;
  89.     }
  90.     dcmd_come(playerid,params[]){
  91.         new pID,Float:x,Float:y,Float:z,aname[100],pname[100],string[100],string2[100];
  92.         if(sscanf(params, "u",pID)){
  93.             return SendClientMessage(playerid, rot, "BENUTZE: /come [playerid]");
  94.         }
  95.         if(IsPlayerAdmin(playerid)){
  96.             GetPlayerPos(playerid,x,y,z);
  97.             SetPlayerPos(pID,x,y+1,z+1);
  98.             GetPlayerName(pID, pname, sizeof(pname));
  99.             GetPlayerName(playerid, aname, sizeof(aname));
  100.             format(string, sizeof(string),"Du hast %s zu dir geportet!",pname);
  101.             format(string2, sizeof(string2),"Admin %s hat dich zu sich geportet!",aname);
  102.             SendClientMessage(playerid,rot,string);
  103.             SendClientMessage(pID,rot,string2);
  104.         }
  105.         else
  106.         {
  107.             SendClientMessage(playerid,rot,"Du bist kein Admin!");
  108.         }
  109.         return 1;
  110.     }
  111.     dcmd_slap(playerid,params[]){
  112.         new Float:x,Float:y,Float:z;
  113.         new pID,aname[100],pname[100],string[100],string2[100];
  114.         if(sscanf(params,"u",pID)){
  115.             return SendClientMessage(playerid,rot,"BENUTZE: /slap [playerid]");
  116.         }
  117.         if(IsPlayerAdmin(playerid))
  118.         {
  119.             GetPlayerPos(pID,x,y,z);
  120.             SetPlayerPos(pID,x,y,z+15);
  121.             GetPlayerName(playerid,aname,sizeof(aname));
  122.             GetPlayerName(pID,pname,sizeof(pname));
  123.             format(string,sizeof(string),"Du hast %s geslapt!",pname);
  124.             format(string2,sizeof(string2),"Admin %s hat dich geslapt!",aname);
  125.             SendClientMessage(playerid,rot,string);
  126.             SendClientMessage(pID,rot,string2);
  127.         }
  128.         else
  129.         {
  130.             SendClientMessage(playerid,rot,"Du bist kein Admin!");
  131.         }
  132.         return 1;
  133.     }
  134.     dcmd_freeze(playerid,params[]){
  135.         new pID,aname[100],pname[100],string[100],string2[100];
  136.         if(sscanf(params,"u",pID)){
  137.             return SendClientMessage(playerid,rot,"BENUTZE: /freeze [playerid]");
  138.         }
  139.         if(IsPlayerAdmin(playerid))
  140.         {
  141.             TogglePlayerControllable(pID,0);
  142.             format(string,sizeof(string),"Du wurdest von Admin %s gefreezed!",aname);
  143.             format(string2,sizeof(string2),"Du hast %s gefreezed!",pname);
  144.             SendClientMessage(playerid,rot,string);
  145.             SendClientMessage(playerid,rot,string2);
  146.         }
  147.         return 1;
  148.     }
  149.     dcmd_unfreeze(playerid,params[]){
  150.         new pID,aname[100],pname[100],string[100],string2[100];
  151.         if(sscanf(params,"u",pID)){
  152.             return SendClientMessage(playerid,rot,"BENUTZE: /unfreeze [playerid]");
  153.         }
  154.         if(IsPlayerAdmin(playerid))
  155.         {
  156.             TogglePlayerControllable(pID,1);
  157.             format(string,sizeof(string),"Du wurdest von Admin %s unfreezed!",aname);
  158.             format(string2,sizeof(string2),"Du hast %s unfreezed!",pname);
  159.             SendClientMessage(playerid,rot,string);
  160.             SendClientMessage(playerid,rot,string2);
  161.         }
  162.         return 1;
  163.     }
  164.  
  165. //=================================================== SCANF CODE ==========================================================//
  166. stock sscanf(string[], format[], {Float,_}:...)
  167. {
  168.     #if defined isnull
  169.         if (isnull(string))
  170.     #else
  171.         if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
  172.     #endif
  173.         {
  174.             return format[0];
  175.         }
  176.     #pragma tabsize 4
  177.     new
  178.         formatPos = 0,
  179.         stringPos = 0,
  180.         paramPos = 2,
  181.         paramCount = numargs(),
  182.         delim = ' ';
  183.     while (string[stringPos] && string[stringPos] <= ' ')
  184.     {
  185.         stringPos++;
  186.     }
  187.     while (paramPos < paramCount && string[stringPos])
  188.     {
  189.         switch (format[formatPos++])
  190.         {
  191.             case '\0':
  192.             {
  193.                 return 0;
  194.             }
  195.             case 'i', 'd':
  196.             {
  197.                 new
  198.                     neg = 1,
  199.                     num = 0,
  200.                     ch = string[stringPos];
  201.                 if (ch == '-')
  202.                 {
  203.                     neg = -1;
  204.                     ch = string[++stringPos];
  205.                 }
  206.                 do
  207.                 {
  208.                     stringPos++;
  209.                     if ('0' <= ch <= '9')
  210.                     {
  211.                         num = (num * 10) + (ch - '0');
  212.                     }
  213.                     else
  214.                     {
  215.                         return -1;
  216.                     }
  217.                 }
  218.                 while ((ch = string[stringPos]) > ' ' && ch != delim);
  219.                 setarg(paramPos, 0, num * neg);
  220.             }
  221.             case 'h', 'x':
  222.             {
  223.                 new
  224.                     num = 0,
  225.                     ch = string[stringPos];
  226.                 do
  227.                 {
  228.                     stringPos++;
  229.                     switch (ch)
  230.                     {
  231.                         case 'x', 'X':
  232.                         {
  233.                             num = 0;
  234.                             continue;
  235.                         }
  236.                         case '0' .. '9':
  237.                         {
  238.                             num = (num << 4) | (ch - '0');
  239.                         }
  240.                         case 'a' .. 'f':
  241.                         {
  242.                             num = (num << 4) | (ch - ('a' - 10));
  243.                         }
  244.                         case 'A' .. 'F':
  245.                         {
  246.                             num = (num << 4) | (ch - ('A' - 10));
  247.                         }
  248.                         default:
  249.                         {
  250.                             return -1;
  251.                         }
  252.                     }
  253.                 }
  254.                 while ((ch = string[stringPos]) > ' ' && ch != delim);
  255.                 setarg(paramPos, 0, num);
  256.             }
  257.             case 'c':
  258.             {
  259.                 setarg(paramPos, 0, string[stringPos++]);
  260.             }
  261.             case 'f':
  262.             {
  263.  
  264.                 new changestr[16], changepos = 0, strpos = stringPos;
  265.                 while(changepos < 16 && string[strpos] && string[strpos] != delim)
  266.                 {
  267.                     changestr[changepos++] = string[strpos++];
  268.                     }
  269.                 changestr[changepos] = '\0';
  270.                 setarg(paramPos,0,_:floatstr(changestr));
  271.             }
  272.             case 'p':
  273.             {
  274.                 delim = format[formatPos++];
  275.                 continue;
  276.             }
  277.             case '\'':
  278.             {
  279.                 new
  280.                     end = formatPos - 1,
  281.                     ch;
  282.                 while ((ch = format[++end]) && ch != '\'') {}
  283.                 if (!ch)
  284.                 {
  285.                     return -1;
  286.                 }
  287.                 format[end] = '\0';
  288.                 if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
  289.                 {
  290.                     if (format[end + 1])
  291.                     {
  292.                         return -1;
  293.                     }
  294.                     return 0;
  295.                 }
  296.                 format[end] = '\'';
  297.                 stringPos = ch + (end - formatPos);
  298.                 formatPos = end + 1;
  299.             }
  300.             case 'u':
  301.             {
  302.                 new
  303.                     end = stringPos - 1,
  304.                     id = 0,
  305.                     bool:num = true,
  306.                     ch;
  307.                 while ((ch = string[++end]) && ch != delim)
  308.                 {
  309.                     if (num)
  310.                     {
  311.                         if ('0' <= ch <= '9')
  312.                         {
  313.                             id = (id * 10) + (ch - '0');
  314.                         }
  315.                         else
  316.                         {
  317.                             num = false;
  318.                         }
  319.                     }
  320.                 }
  321.                 if (num && IsPlayerConnected(id))
  322.                 {
  323.                     setarg(paramPos, 0, id);
  324.                 }
  325.                 else
  326.                 {
  327.                     #if !defined foreach
  328.                         #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
  329.                         #define __SSCANF_FOREACH__
  330.                     #endif
  331.                     string[end] = '\0';
  332.                     num = false;
  333.                     new
  334.                         name[MAX_PLAYER_NAME];
  335.                     id = end - stringPos;
  336.                     foreach (Player, playerid)
  337.                     {
  338.                         GetPlayerName(playerid, name, sizeof (name));
  339.                         if (!strcmp(name, string[stringPos], true, id))
  340.                         {
  341.                             setarg(paramPos, 0, playerid);
  342.                             num = true;
  343.                             break;
  344.                         }
  345.                     }
  346.                     if (!num)
  347.                     {
  348.                         setarg(paramPos, 0, INVALID_PLAYER_ID);
  349.                     }
  350.                     string[end] = ch;
  351.                     #if defined __SSCANF_FOREACH__
  352.                         #undef foreach
  353.                         #undef __SSCANF_FOREACH__
  354.                     #endif
  355.                 }
  356.                 stringPos = end;
  357.             }
  358.             case 's', 'z':
  359.             {
  360.                 new
  361.                     i = 0,
  362.                     ch;
  363.                 if (format[formatPos])
  364.                 {
  365.                     while ((ch = string[stringPos++]) && ch != delim)
  366.                     {
  367.                         setarg(paramPos, i++, ch);
  368.                     }
  369.                     if (!i)
  370.                     {
  371.                         return -1;
  372.                     }
  373.                 }
  374.                 else
  375.                 {
  376.                     while ((ch = string[stringPos++]))
  377.                     {
  378.                         setarg(paramPos, i++, ch);
  379.                     }
  380.                 }
  381.                 stringPos--;
  382.                 setarg(paramPos, i, '\0');
  383.             }
  384.             default:
  385.             {
  386.                 continue;
  387.             }
  388.         }
  389.         while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
  390.         {
  391.             stringPos++;
  392.         }
  393.         while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
  394.         {
  395.             stringPos++;
  396.         }
  397.         paramPos++;
  398.     }
  399.     do
  400.     {
  401.         if ((delim = format[formatPos++]) > ' ')
  402.         {
  403.             if (delim == '\'')
  404.             {
  405.                 while ((delim = format[formatPos++]) && delim != '\'') {}
  406.             }
  407.             else if (delim != 'z')
  408.             {
  409.                 return delim;
  410.             }
  411.         }
  412.     }
  413.     while (delim > ' ');
  414.     return 0;
  415. }
  416.  
Advertisement
Add Comment
Please, Sign In to add comment