Guest User

RoadBlocks by Gredsoft

a guest
Jul 17th, 2012
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 7.53 KB | None | 0 0
  1. #include <a_samp>
  2. #include <ocmd>
  3.  
  4. #define MAX_ROADBLOCKS      50
  5.  
  6. new RB[MAX_ROADBLOCKS];
  7. new bool:IsRBC[MAX_ROADBLOCKS];
  8.  
  9. public OnFilterScriptInit()
  10. {
  11.     print("\nRoadblock Filterscript by Gredsoft\n");
  12.    
  13.     for(new i = 0; i < MAX_ROADBLOCKS; i++)
  14.     {
  15.         IsRBC[i] = false;
  16.         DestroyObject(RB[i]);
  17.     }
  18.    
  19.     return 1;
  20. }
  21.  
  22. public OnFilterScriptExit()
  23. {
  24.     for(new i = 0; i < MAX_ROADBLOCKS; i++)
  25.     {
  26.         IsRBC[i] = false;
  27.         DestroyObject(RB[i]);
  28.     }
  29. }
  30.  
  31. ocmd:rbc(playerid,params[])
  32. {
  33.     new skin;
  34.     skin = GetPlayerSkin(playerid);
  35.     if(skin < 280 || skin > 288)return SendClientMessage(playerid,-1,"[RBFS] Du bist kein Polizist!");
  36.    
  37.     new Float:x,Float:y,Float:z,Float:a;
  38.    
  39.     GetPlayerPos(playerid,x,y,z);
  40.     GetPlayerFacingAngle(playerid,a);
  41.    
  42.     for(new i = 0; i < MAX_ROADBLOCKS; i++)
  43.     {
  44.         if(!IsRBC[i]) {
  45.             IsRBC[i] = true;
  46.             RB[i] = CreateObject(978,x,y,z - 0.6,0.0,0.0,a -180.0);
  47.             for(new i2 = 0; i2 < MAX_PLAYERS; i2++)
  48.             {
  49.                 new iskin;
  50.                 iskin = GetPlayerSkin(i2);
  51.                 if(iskin > 279 && iskin < 289){
  52.                     new str[128];
  53.                     format(str,sizeof(str),"[RBFS] Polizist %s hat eine Straßensperre aufgestellt!",ReturnPlayerName(playerid));
  54.                     SendClientMessage(i2,-1,str);
  55.                 }
  56.             }
  57.             return 1;
  58.         }
  59.     }
  60.     SendClientMessage(playerid,-1,"[RBFS] Es können keine weiteren Straßensperren mehr aufgestellt werden.");
  61.     SendClientMessage(playerid,-1,"[RBFS] Möglichkeiten: /rbda | /rbd (Nummer)");
  62.     return 1;
  63. }
  64. ocmd:rbd(playerid,params[])
  65. {
  66.     new skin;
  67.     skin = GetPlayerSkin(playerid);
  68.     if(skin < 280 || skin > 288)return SendClientMessage(playerid,-1,"[RBFS] Du bist kein Polizist!");
  69.    
  70.     new rbid;
  71.    
  72.     if(sscanf(params,"i",rbid))return SendClientMessage(playerid,-1,"[RBFS] Benutzung: /rbd <ID>");
  73.     if(!IsRBC[rbid])return SendClientMessage(playerid,-1,"[RBFS] Es existiert keine Straßensperre unter dieser ID.");
  74.     DestroyObject(RB[rbid]);
  75.     IsRBC[rbid] = false;
  76.     for(new i = 0; i < MAX_PLAYERS; i++)
  77.     {
  78.         new iskin;
  79.         iskin = GetPlayerSkin(i);
  80.         if(iskin > 279 && iskin < 289){
  81.             new str[128];
  82.             format(str,sizeof(str),"[RBFS] Polizist %s hat die Straßensperre mit der ID %i abgestellt!",ReturnPlayerName(playerid),rbid);
  83.             SendClientMessage(i,-1,str);
  84.         }
  85.     }
  86.     return 1;
  87. }
  88. ocmd:rbda(playerid,params[])
  89. {
  90.     new skin;
  91.     skin = GetPlayerSkin(playerid);
  92.     if(skin < 280 || skin > 288)return SendClientMessage(playerid,-1,"[RBFS] Du bist kein Polizist!");
  93.    
  94.     for(new i = 0; i < MAX_ROADBLOCKS; i++)
  95.     {
  96.         IsRBC[i] = false;
  97.         DestroyObject(RB[i]);
  98.     }
  99.     for(new i = 0; i < MAX_PLAYERS; i++)
  100.     {
  101.         new iskin;
  102.         iskin = GetPlayerSkin(i);
  103.         if(iskin > 279 && iskin < 289){
  104.             new str[128];
  105.             format(str,sizeof(str),"[RBFS] Polizist %s hat alle Straßensperren abgestellt!",ReturnPlayerName(playerid));
  106.             SendClientMessage(i,-1,str);
  107.         }
  108.     }
  109.     return 1;
  110. }
  111.  
  112. stock ReturnPlayerName(playerid)
  113. {
  114.     new name[MAX_PLAYER_NAME];
  115.     GetPlayerName(playerid,name,sizeof(name));
  116.     return name;
  117. }
  118.  
  119. stock sscanf(string[], format[], {Float,_}:...)
  120. {
  121.     #if defined isnull
  122.         if (isnull(string))
  123.     #else
  124.         if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
  125.     #endif
  126.         {
  127.             return format[0];
  128.         }
  129.     #pragma tabsize 4
  130.     new
  131.         formatPos = 0,
  132.         stringPos = 0,
  133.         paramPos = 2,
  134.         paramCount = numargs(),
  135.         delim = ' ';
  136.     while (string[stringPos] && string[stringPos] <= ' ')
  137.     {
  138.         stringPos++;
  139.     }
  140.     while (paramPos < paramCount && string[stringPos])
  141.     {
  142.         switch (format[formatPos++])
  143.         {
  144.             case '\0':
  145.             {
  146.                 return 0;
  147.             }
  148.             case 'i', 'd':
  149.             {
  150.                 new
  151.                     neg = 1,
  152.                     num = 0,
  153.                     ch = string[stringPos];
  154.                 if (ch == '-')
  155.                 {
  156.                     neg = -1;
  157.                     ch = string[++stringPos];
  158.                 }
  159.                 do
  160.                 {
  161.                     stringPos++;
  162.                     if ('0' <= ch <= '9')
  163.                     {
  164.                         num = (num * 10) + (ch - '0');
  165.                     }
  166.                     else
  167.                     {
  168.                         return -1;
  169.                     }
  170.                 }
  171.                 while ((ch = string[stringPos]) > ' ' && ch != delim);
  172.                 setarg(paramPos, 0, num * neg);
  173.             }
  174.             case 'h', 'x':
  175.             {
  176.                 new
  177.                     num = 0,
  178.                     ch = string[stringPos];
  179.                 do
  180.                 {
  181.                     stringPos++;
  182.                     switch (ch)
  183.                     {
  184.                         case 'x', 'X':
  185.                         {
  186.                             num = 0;
  187.                             continue;
  188.                         }
  189.                         case '0' .. '9':
  190.                         {
  191.                             num = (num << 4) | (ch - '0');
  192.                         }
  193.                         case 'a' .. 'f':
  194.                         {
  195.                             num = (num << 4) | (ch - ('a' - 10));
  196.                         }
  197.                         case 'A' .. 'F':
  198.                         {
  199.                             num = (num << 4) | (ch - ('A' - 10));
  200.                         }
  201.                         default:
  202.                         {
  203.                             return -1;
  204.                         }
  205.                     }
  206.                 }
  207.                 while ((ch = string[stringPos]) > ' ' && ch != delim);
  208.                 setarg(paramPos, 0, num);
  209.             }
  210.             case 'c':
  211.             {
  212.                 setarg(paramPos, 0, string[stringPos++]);
  213.             }
  214.             case 'f':
  215.             {
  216.  
  217.                 new changestr[16], changepos = 0, strpos = stringPos;
  218.                 while(changepos < 16 && string[strpos] && string[strpos] != delim)
  219.                 {
  220.                     changestr[changepos++] = string[strpos++];
  221.                     }
  222.                 changestr[changepos] = '\0';
  223.                 setarg(paramPos,0,_:floatstr(changestr));
  224.             }
  225.             case 'p':
  226.             {
  227.                 delim = format[formatPos++];
  228.                 continue;
  229.             }
  230.             case '\'':
  231.             {
  232.                 new
  233.                     end = formatPos - 1,
  234.                     ch;
  235.                 while ((ch = format[++end]) && ch != '\'') {}
  236.                 if (!ch)
  237.                 {
  238.                     return -1;
  239.                 }
  240.                 format[end] = '\0';
  241.                 if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
  242.                 {
  243.                     if (format[end + 1])
  244.                     {
  245.                         return -1;
  246.                     }
  247.                     return 0;
  248.                 }
  249.                 format[end] = '\'';
  250.                 stringPos = ch + (end - formatPos);
  251.                 formatPos = end + 1;
  252.             }
  253.             case 'u':
  254.             {
  255.                 new
  256.                     end = stringPos - 1,
  257.                     id = 0,
  258.                     bool:num = true,
  259.                     ch;
  260.                 while ((ch = string[++end]) && ch != delim)
  261.                 {
  262.                     if (num)
  263.                     {
  264.                         if ('0' <= ch <= '9')
  265.                         {
  266.                             id = (id * 10) + (ch - '0');
  267.                         }
  268.                         else
  269.                         {
  270.                             num = false;
  271.                         }
  272.                     }
  273.                 }
  274.                 if (num && IsPlayerConnected(id))
  275.                 {
  276.                     setarg(paramPos, 0, id);
  277.                 }
  278.                 else
  279.                 {
  280.                     #if !defined foreach
  281.                         #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
  282.                         #define __SSCANF_FOREACH__
  283.                     #endif
  284.                     string[end] = '\0';
  285.                     num = false;
  286.                     new
  287.                         name[MAX_PLAYER_NAME];
  288.                     id = end - stringPos;
  289.                     foreach (Player, playerid)
  290.                     {
  291.                         GetPlayerName(playerid, name, sizeof (name));
  292.                         if (!strcmp(name, string[stringPos], true, id))
  293.                         {
  294.                             setarg(paramPos, 0, playerid);
  295.                             num = true;
  296.                             break;
  297.                         }
  298.                     }
  299.                     if (!num)
  300.                     {
  301.                         setarg(paramPos, 0, INVALID_PLAYER_ID);
  302.                     }
  303.                     string[end] = ch;
  304.                     #if defined __SSCANF_FOREACH__
  305.                         #undef foreach
  306.                         #undef __SSCANF_FOREACH__
  307.                     #endif
  308.                 }
  309.                 stringPos = end;
  310.             }
  311.             case 's', 'z':
  312.             {
  313.                 new
  314.                     i = 0,
  315.                     ch;
  316.                 if (format[formatPos])
  317.                 {
  318.                     while ((ch = string[stringPos++]) && ch != delim)
  319.                     {
  320.                         setarg(paramPos, i++, ch);
  321.                     }
  322.                     if (!i)
  323.                     {
  324.                         return -1;
  325.                     }
  326.                 }
  327.                 else
  328.                 {
  329.                     while ((ch = string[stringPos++]))
  330.                     {
  331.                         setarg(paramPos, i++, ch);
  332.                     }
  333.                 }
  334.                 stringPos--;
  335.                 setarg(paramPos, i, '\0');
  336.             }
  337.             default:
  338.             {
  339.                 continue;
  340.             }
  341.         }
  342.         while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
  343.         {
  344.             stringPos++;
  345.         }
  346.         while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
  347.         {
  348.             stringPos++;
  349.         }
  350.         paramPos++;
  351.     }
  352.     do
  353.     {
  354.         if ((delim = format[formatPos++]) > ' ')
  355.         {
  356.             if (delim == '\'')
  357.             {
  358.                 while ((delim = format[formatPos++]) && delim != '\'') {}
  359.             }
  360.             else if (delim != 'z')
  361.             {
  362.                 return delim;
  363.             }
  364.         }
  365.     }
  366.     while (delim > ' ');
  367.     return 0;
  368. }
Advertisement
Add Comment
Please, Sign In to add comment