Advertisement
Guest User

Untitled

a guest
May 5th, 2013
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define FILTERSCRIPT
  2.  
  3. #include <a_samp>
  4.  
  5. #define COLOR_RED 0xFF2100FF
  6. #define COLOR_PINK 0xFF00FFFF
  7.  
  8. #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
  9.  
  10. new caged[MAX_PLAYERS];
  11. new Float:CageInfoX[MAX_PLAYERS];
  12. new Float:CageInfoY[MAX_PLAYERS];
  13. new Float:CageInfoZ[MAX_PLAYERS];
  14. new cage1[MAX_PLAYERS];
  15. new cage2[MAX_PLAYERS];
  16. new cage3[MAX_PLAYERS];
  17. new cage4[MAX_PLAYERS];
  18. new cage5[MAX_PLAYERS];
  19. new cage6[MAX_PLAYERS];
  20.    
  21. //------------------------------------------------------------------------------
  22.  
  23. public OnFilterScriptInit()
  24. {
  25.     print("\n--------------------------------------");
  26.     print(" Cage system by [AK]Nazgul");
  27.     print("--------------------------------------\n");
  28.     return 1;
  29. }
  30.  
  31. public OnFilterScriptExit()
  32. {
  33.     return 1;
  34. }
  35.  
  36. //------------------------------------------------------------------------------
  37.  
  38. forward cagetimer(playerid);
  39. public cagetimer(playerid)
  40. {
  41.     SetPlayerPos(playerid,CageInfoX[playerid],CageInfoY[playerid],CageInfoZ[playerid]+2);
  42. }
  43.  
  44. //------------------------------------------------------------------------------
  45.  
  46. public OnPlayerSpawn(playerid)
  47. {
  48.     if(caged[playerid] == 1)
  49.     {
  50.         SetTimerEx("cagetimer",500,false,"u",playerid);
  51.     }
  52.     return 1;
  53. }
  54.  
  55. //------------------------------------------------------------------------------
  56.  
  57. public OnPlayerCommandText(playerid, cmdtext[])
  58. {
  59.     dcmd(cage, 4, cmdtext);
  60.    
  61.     dcmd(kill, 4, cmdtext);
  62.     return 0;
  63. }
  64. //##############################################################################
  65. //######################################DCMD####################################
  66.     dcmd_kill(playerid,params[])
  67.     {
  68.         #pragma unused params
  69.         SetPlayerHealth(playerid,0);
  70.         return 1;
  71.     }
  72.     dcmd_cage(playerid,params[])
  73.     {
  74.         if(IsPlayerAdmin(playerid))
  75.         {
  76.             new pID;
  77.             if(sscanf(params,"u",pID)) return SendClientMessage(playerid,COLOR_RED,"USAGE: /cage [ID]");
  78.             if(caged[pID] == 0)
  79.             {
  80.  
  81.                 DestroyObject(cage1[pID]);
  82.                 DestroyObject(cage2[pID]);
  83.                 DestroyObject(cage3[pID]);
  84.                 DestroyObject(cage4[pID]);
  85.                 DestroyObject(cage5[pID]);
  86.                 DestroyObject(cage6[pID]);
  87.  
  88.                 new string[128];
  89.                 new Float:X, Float:Y, Float:Z;
  90.  
  91.                 GetPlayerPos(pID,X,Y,Z);
  92.                 cage1[pID] = CreateObject(985, X, Y, Z+10, 0, 0, 0);
  93.                 cage2[pID] = CreateObject(985, X+4 ,Y-4 , Z+10, 0, 0, 90);
  94.                 cage3[pID] = CreateObject(985, X-4 , Y-4 , Z+10, 0, 0, 90);
  95.                 cage4[pID] = CreateObject(985, X , Y-8 , Z+10, 0, 0, 0);
  96.                 cage5[pID] = CreateObject(985, X , Y-4 , Z+8.2, 90, 0, 0);
  97.                 cage6[pID] = CreateObject(985, X , Y-4 , Z+8.2, 90, 0, 180);
  98.  
  99.                 SetPlayerPos(pID,X,Y- 2,Z+15);
  100.                 CageInfoX[pID]= X;
  101.                 CageInfoY[pID]= Y-2;
  102.                 CageInfoZ[pID]= Z+15;
  103.                 caged[pID] = 1;
  104.                 format(string,128,"[Admin] You have caged %s -> /dcage <id> to uncage.",PlayerName(pID));
  105.                 SendClientMessage(playerid,COLOR_RED,string);
  106.                 new str[128];
  107.                 format(str,128,"** ADMIN CAGE: %s (%i) has been caged",PlayerName(pID),pID);
  108.                 SendClientMessageToAll(COLOR_PINK,str);
  109.                 return 1;
  110.             }
  111.             else
  112.             {
  113.                 DestroyObject(cage1[pID]);
  114.                 DestroyObject(cage2[pID]);
  115.                 DestroyObject(cage3[pID]);
  116.                 DestroyObject(cage4[pID]);
  117.                 DestroyObject(cage5[pID]);
  118.                 DestroyObject(cage6[pID]);
  119.  
  120.                 SetPlayerPos(pID,CageInfoX[pID],CageInfoY[pID],CageInfoZ[pID]-10);
  121.                 caged[pID] = 0;
  122.                 new str[128];
  123.                 format(str,128,"** ADMIN CAGE: %s (%i) has been uncaged",PlayerName(pID),pID);
  124.                 SendClientMessageToAll(COLOR_PINK,str);
  125.                 return 1;
  126.             }
  127.         }
  128.         else{SendClientMessage(playerid,COLOR_RED,"You can't use this command!"); return 1;}
  129.     }
  130.    
  131.    
  132. //------------------------------------------------------------------------------
  133.  
  134. stock PlayerName(playerid)
  135. {
  136.     new name[MAX_PLAYER_NAME];
  137.     GetPlayerName(playerid,name,sizeof(name)); return name;
  138. }
  139.  
  140. //##############################################################################
  141. //######################################SSCANF##################################
  142.  
  143. stock sscanf(string[], format[], {Float,_}:...)
  144. {
  145.     #if defined isnull
  146.         if (isnull(string))
  147.     #else
  148.         if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
  149.     #endif
  150.         {
  151.             return format[0];
  152.         }
  153.     #pragma tabsize 4
  154.     new
  155.         formatPos = 0,
  156.         stringPos = 0,
  157.         paramPos = 2,
  158.         paramCount = numargs(),
  159.         delim = ' ';
  160.     while (string[stringPos] && string[stringPos] <= ' ')
  161.     {
  162.         stringPos++;
  163.     }
  164.     while (paramPos < paramCount && string[stringPos])
  165.     {
  166.         switch (format[formatPos++])
  167.         {
  168.             case '\0':
  169.             {
  170.                 return 0;
  171.             }
  172.             case 'i', 'd':
  173.             {
  174.                 new
  175.                     neg = 1,
  176.                     num = 0,
  177.                     ch = string[stringPos];
  178.                 if (ch == '-')
  179.                 {
  180.                     neg = -1;
  181.                     ch = string[++stringPos];
  182.                 }
  183.                 do
  184.                 {
  185.                     stringPos++;
  186.                     if ('0' <= ch <= '9')
  187.                     {
  188.                         num = (num * 10) + (ch - '0');
  189.                     }
  190.                     else
  191.                     {
  192.                         return -1;
  193.                     }
  194.                 }
  195.                 while ((ch = string[stringPos]) > ' ' && ch != delim);
  196.                 setarg(paramPos, 0, num * neg);
  197.             }
  198.             case 'h', 'x':
  199.             {
  200.                 new
  201.                     num = 0,
  202.                     ch = string[stringPos];
  203.                 do
  204.                 {
  205.                     stringPos++;
  206.                     switch (ch)
  207.                     {
  208.                         case 'x', 'X':
  209.                         {
  210.                             num = 0;
  211.                             continue;
  212.                         }
  213.                         case '0' .. '9':
  214.                         {
  215.                             num = (num << 4) | (ch - '0');
  216.                         }
  217.                         case 'a' .. 'f':
  218.                         {
  219.                             num = (num << 4) | (ch - ('a' - 10));
  220.                         }
  221.                         case 'A' .. 'F':
  222.                         {
  223.                             num = (num << 4) | (ch - ('A' - 10));
  224.                         }
  225.                         default:
  226.                         {
  227.                             return -1;
  228.                         }
  229.                     }
  230.                 }
  231.                 while ((ch = string[stringPos]) > ' ' && ch != delim);
  232.                 setarg(paramPos, 0, num);
  233.             }
  234.             case 'c':
  235.             {
  236.                 setarg(paramPos, 0, string[stringPos++]);
  237.             }
  238.             case 'f':
  239.             {
  240.  
  241.                 new changestr[16], changepos = 0, strpos = stringPos;
  242.                 while(changepos < 16 && string[strpos] && string[strpos] != delim)
  243.                 {
  244.                     changestr[changepos++] = string[strpos++];
  245.                     }
  246.                 changestr[changepos] = '\0';
  247.                 setarg(paramPos,0,_:floatstr(changestr));
  248.             }
  249.             case 'p':
  250.             {
  251.                 delim = format[formatPos++];
  252.                 continue;
  253.             }
  254.             case '\'':
  255.             {
  256.                 new
  257.                     end = formatPos - 1,
  258.                     ch;
  259.                 while ((ch = format[++end]) && ch != '\'') {}
  260.                 if (!ch)
  261.                 {
  262.                     return -1;
  263.                 }
  264.                 format[end] = '\0';
  265.                 if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
  266.                 {
  267.                     if (format[end + 1])
  268.                     {
  269.                         return -1;
  270.                     }
  271.                     return 0;
  272.                 }
  273.                 format[end] = '\'';
  274.                 stringPos = ch + (end - formatPos);
  275.                 formatPos = end + 1;
  276.             }
  277.             case 'u':
  278.             {
  279.                 new
  280.                     end = stringPos - 1,
  281.                     id = 0,
  282.                     bool:num = true,
  283.                     ch;
  284.                 while ((ch = string[++end]) && ch != delim)
  285.                 {
  286.                     if (num)
  287.                     {
  288.                         if ('0' <= ch <= '9')
  289.                         {
  290.                             id = (id * 10) + (ch - '0');
  291.                         }
  292.                         else
  293.                         {
  294.                             num = false;
  295.                         }
  296.                     }
  297.                 }
  298.                 if (num && IsPlayerConnected(id))
  299.                 {
  300.                     setarg(paramPos, 0, id);
  301.                 }
  302.                 else
  303.                 {
  304.                     #if !defined foreach
  305.                         #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
  306.                         #define __SSCANF_FOREACH__
  307.                     #endif
  308.                     string[end] = '\0';
  309.                     num = false;
  310.                     new
  311.                         name[MAX_PLAYER_NAME];
  312.                     id = end - stringPos;
  313.                     foreach (Player, playerid)
  314.                     {
  315.                         GetPlayerName(playerid, name, sizeof (name));
  316.                         if (!strcmp(name, string[stringPos], true, id))
  317.                         {
  318.                             setarg(paramPos, 0, playerid);
  319.                             num = true;
  320.                             break;
  321.                         }
  322.                     }
  323.                     if (!num)
  324.                     {
  325.                         setarg(paramPos, 0, INVALID_PLAYER_ID);
  326.                     }
  327.                     string[end] = ch;
  328.                     #if defined __SSCANF_FOREACH__
  329.                         #undef foreach
  330.                         #undef __SSCANF_FOREACH__
  331.                     #endif
  332.                 }
  333.                 stringPos = end;
  334.             }
  335.             case 's', 'z':
  336.             {
  337.                 new
  338.                     i = 0,
  339.                     ch;
  340.                 if (format[formatPos])
  341.                 {
  342.                     while ((ch = string[stringPos++]) && ch != delim)
  343.                     {
  344.                         setarg(paramPos, i++, ch);
  345.                     }
  346.                     if (!i)
  347.                     {
  348.                         return -1;
  349.                     }
  350.                 }
  351.                 else
  352.                 {
  353.                     while ((ch = string[stringPos++]))
  354.                     {
  355.                         setarg(paramPos, i++, ch);
  356.                     }
  357.                 }
  358.                 stringPos--;
  359.                 setarg(paramPos, i, '\0');
  360.             }
  361.             default:
  362.             {
  363.                 continue;
  364.             }
  365.         }
  366.         while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
  367.         {
  368.             stringPos++;
  369.         }
  370.         while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
  371.         {
  372.             stringPos++;
  373.         }
  374.         paramPos++;
  375.     }
  376.     do
  377.     {
  378.         if ((delim = format[formatPos++]) > ' ')
  379.         {
  380.             if (delim == '\'')
  381.             {
  382.                 while ((delim = format[formatPos++]) && delim != '\'') {}
  383.             }
  384.             else if (delim != 'z')
  385.             {
  386.                 return delim;
  387.             }
  388.         }
  389.     }
  390.     while (delim > ' ');
  391.     return 0;
  392. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement