Advertisement
946ben

946ben's Feuerwerks-System

Jun 29th, 2011
470
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 10.67 KB | None | 0 0
  1. #include <a_samp>
  2. #include <zcmd>
  3.  
  4. #define MAX_ROCKETS 100 // Maximale Raketen
  5.  
  6. new rockets[MAX_PLAYERS];
  7.  
  8. new shop;
  9.  
  10. forward ex1(light);
  11. forward ex2(light);
  12. forward ex3(light);
  13. forward ex4(light);
  14. forward ex5(light, light1, light2, light3, light4, light5);
  15.  
  16. public OnFilterScriptInit()
  17. {
  18.     shop = CreatePickup(1252,2,-2033.6658,148.2576,28.8359);
  19.     print("\n--------------------------------------");
  20.     print("    Feuerwerks-System by 946ben     ");
  21.     print("--------------------------------------\n");
  22.     return 1;
  23. }
  24.  
  25. public OnFilterScriptExit()
  26. {
  27.         DestroyPickup(shop);
  28.         for(new player=0; player<MAX_PLAYERS; player++)
  29.         {
  30.                 if(IsPlayerConnected(player))
  31.                 {
  32.                         rockets[player] = 0;
  33.                 }
  34.         }
  35.         return 1;
  36. }
  37.  
  38. COMMAND:feuerwerk(playerid,params[])
  39. {
  40.         if(rockets[playerid] == 0) return SendClientMessage(playerid, 0x008080FF, "Du hast keine Raketen.");
  41.         new Float:x, Float:y, Float:z, light, rand;
  42.         rand = random(9);
  43.         rockets[playerid]--;
  44.         GetPlayerPos(playerid, x, y, z);
  45.         light = CreateObject(354, x, y, z, 0, 0, 96.0);
  46.         if(rand == 2 || rand == 3) {
  47.               MoveObject(light, x+15, y, z, 30);
  48.               SendClientMessage(playerid, 0x008080FF, "Rakete falsch gezündet. Lauf schnell!");
  49.               SendClientMessage(playerid, 0x008080FF, "Rakete falsch gezündet. Lauf schnell!");
  50.               SendClientMessage(playerid, 0x008080FF, "Rakete falsch gezündet. Lauf schnell!");
  51.         } else {
  52.               MoveObject(light, x+10, y, z+30, 30);
  53.         }
  54.         SetTimerEx("ex1", 1000, false, "i", light);
  55.         SetTimerEx("ex2", 1250, false, "i", light);
  56.         SetTimerEx("ex3", 1500, false, "i", light);
  57.         SetTimerEx("ex4", 2000, false, "i", light);
  58.         return 1;
  59. }
  60.  
  61. COMMAND:buyraketen(playerid,params[])
  62. {
  63.         new number, string[128];
  64.         if(sscanf(params, "d",number)) return SendClientMessage(playerid,0x008080FF, "/buyraketen [Anzahl]");
  65.         if(!IsPlayerInRangeOfPoint(playerid,5.0,-2033.6658,148.2576,28.8359)) return SendClientMessage(playerid,0x008080FF, "Du bist nicht am Kaufpunkt.");
  66.         new afterbuynumber = number+rockets[playerid];
  67.         if(afterbuynumber > MAX_ROCKETS) {
  68.                 format(string, sizeof(string), "Du kannst noch maximal %d Raketen kaufen.", MAX_ROCKETS-rockets[playerid]);
  69.                 return SendClientMessage(playerid,0x008080FF, string);
  70.         }
  71.         new rechnung= number*10;
  72.         if(GetPlayerMoney(playerid) < rechnung) SendClientMessage(playerid,0x008080FF, "Du hast nicht genug Geld. Eine Rakete kostet 10$.");
  73.         GivePlayerMoney(playerid, -(number*10));
  74.         rockets[playerid] = rockets[playerid] + number;
  75.         format(string, sizeof(string), "Du hast jetzt %d Raketen. Kosten: %d$", rockets[playerid], rechnung);
  76.         SendClientMessage(playerid,0x008080FF, string);
  77.         return 1;
  78. }
  79.  
  80. COMMAND:raketeninfo(playerid,params[])
  81. {
  82.         new string[128];
  83.         format(string, sizeof(string), "Du hast %d Raketen.", rockets[playerid]);
  84.         SendClientMessage(playerid,0x008080FF, string);
  85.         return 1;
  86. }
  87.  
  88. public OnPlayerPickUpPickup(playerid, pickupid)
  89. {
  90.     if(pickupid == shop)
  91.     {
  92.         GameTextForPlayer(playerid, "Raketen kaufen:~n~~>~/buyraketen [Anzahl]~n~~n~Kosten:~n~~>~10$ je", 5000, 0);
  93.     }
  94.     return 1;
  95. }
  96.  
  97. public ex1(light)
  98. {
  99.     new Float:x, Float:y, Float:z, light1, light2, light3, light4, light5;
  100.     GetObjectPos(light, x, y, z);
  101.     light1 = CreateObject(354, x+5, y-5, z, 0, 0, 96.0);
  102.     light2 = CreateObject(354, x-5, y+5, z, 0, 0, 96.0);
  103.     light3 = CreateObject(354, x+5, y-5, z-5, 0, 0, 96.0);
  104.     light4 = CreateObject(354, x-5, y+5, z-5, 0, 0, 96.0);
  105.     light5 = CreateObject(354, x+2, y-2, z, 0, 0, 96.0);
  106.     SetTimerEx("ex5", 1250, false, "iiiiii", light, light1, light2, light3, light4, light5);
  107.     CreateExplosion(x, y, z, 2, 20.0);
  108.     CreateExplosion(x-5, y+5, z, 2, 20.0);
  109.     CreateExplosion(x+5, y-5, z, 2, 20.0);
  110.     CreateExplosion(x+5, y+5, z, 2, 20.0);
  111.     CreateExplosion(x-5, y-5, z, 2, 20.0);
  112.     return 1;
  113. }
  114.  
  115. public ex2(light)
  116. {
  117.     new Float:x, Float:y, Float:z;
  118.     GetObjectPos(light, x, y, z);
  119.     CreateExplosion(x, y, z, 2, 20.0);
  120.     CreateExplosion(x-5, y+5, z, 2, 20.0);
  121.     CreateExplosion(x+5, y-5, z, 2, 20.0);
  122.     CreateExplosion(x-7, y+6, z, 7, 20.0);
  123.     CreateExplosion(x+7, y-6, z, 7, 20.0);
  124.     CreateExplosion(x+5, y+5, z, 2, 20.0);
  125.     CreateExplosion(x-5, y-5, z, 2, 20.0);
  126.     return 1;
  127. }
  128.  
  129. public ex3(light)
  130. {
  131.     new Float:x, Float:y, Float:z;
  132.     GetObjectPos(light, x, y, z);
  133.     CreateExplosion(x, y, z, 2, 20.0);
  134.     CreateExplosion(x-5, y+5, z, 2, 20.0);
  135.     CreateExplosion(x+5, y-5, z, 2, 20.0);
  136.     CreateExplosion(x+5, y+5, z, 2, 20.0);
  137.     CreateExplosion(x-5, y-5, z, 2, 20.0);
  138.     CreateExplosion(x-7, y+8, z, 7, 20.0);
  139.     CreateExplosion(x+9, y-6, z, 7, 20.0);
  140.     return 1;
  141. }
  142.  
  143. public ex4(light)
  144. {
  145.     new Float:x, Float:y, Float:z;
  146.     GetObjectPos(light, x, y, z);
  147.     CreateExplosion(x, y, z, 2, 25.0);
  148.     CreateExplosion(x-7, y+7, z, 2, 25.0);
  149.     CreateExplosion(x+7, y-7, z, 2, 25.0);
  150.     CreateExplosion(x+7, y+7, z, 2, 25.0);
  151.     CreateExplosion(x-7, y-7, z, 2, 25.0);
  152.     CreateExplosion(x-6, y+8, z, 7, 20.0);
  153.     CreateExplosion(x+6, y-8, z, 7, 20.0);
  154.     return 1;
  155. }
  156.  
  157. public ex5(light, light1, light2, light3, light4, light5)
  158. {
  159.     new Float:x, Float:y, Float:z;
  160.     GetObjectPos(light, x, y, z);
  161.     DestroyObject(light);
  162.     CreateExplosion(x, y, z, 2, 20.0);
  163.     CreateExplosion(x-9, y+9, z, 2, 25.0);
  164.     CreateExplosion(x+9, y-9, z, 2, 25.0);
  165.     CreateExplosion(x+9, y+9, z, 2, 25.0);
  166.     CreateExplosion(x-9, y-9, z, 2, 25.0);
  167.     CreateExplosion(x-7, y+6, z, 7, 20.0);
  168.     CreateExplosion(x+7, y-6, z, 7, 20.0);
  169.     CreateExplosion(x-8, y+8, z, 7, 20.0);
  170.     CreateExplosion(x+5, y-8, z, 7, 20.0);
  171.     DestroyObject(light1);
  172.     DestroyObject(light2);
  173.     DestroyObject(light3);
  174.     DestroyObject(light4);
  175.     DestroyObject(light5);
  176.     return 1;
  177. }
  178.  
  179. stock strtok(const string[], &index)
  180. {
  181.     new length = strlen(string);
  182.     while ((index < length) && (string[index] <= ' '))
  183.     {
  184.         index++;
  185.     }
  186.  
  187.     new offset = index;
  188.     new result[20];
  189.     while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  190.     {
  191.         result[index - offset] = string[index];
  192.         index++;
  193.     }
  194.     result[index - offset] = EOS;
  195.     return result;
  196. }
  197.  
  198. stock sscanf(string[], format[], {Float,_}:...)
  199. {
  200.     #if defined isnull
  201.         if (isnull(string))
  202.     #else
  203.         if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
  204.     #endif
  205.         {
  206.             return format[0];
  207.         }
  208.     #pragma tabsize 4
  209.     new
  210.         formatPos = 0,
  211.         stringPos = 0,
  212.         paramPos = 2,
  213.         paramCount = numargs(),
  214.         delim = ' ';
  215.     while (string[stringPos] && string[stringPos] <= ' ')
  216.     {
  217.         stringPos++;
  218.     }
  219.     while (paramPos < paramCount && string[stringPos])
  220.     {
  221.         switch (format[formatPos++])
  222.         {
  223.             case '\0':
  224.             {
  225.                 return 0;
  226.             }
  227.             case 'i', 'd':
  228.             {
  229.                 new
  230.                     neg = 1,
  231.                     num = 0,
  232.                     ch = string[stringPos];
  233.                 if (ch == '-')
  234.                 {
  235.                     neg = -1;
  236.                     ch = string[++stringPos];
  237.                 }
  238.                 do
  239.                 {
  240.                     stringPos++;
  241.                     if ('0' <= ch <= '9')
  242.                     {
  243.                         num = (num * 10) + (ch - '0');
  244.                     }
  245.                     else
  246.                     {
  247.                         return -1;
  248.                     }
  249.                 }
  250.                 while ((ch = string[stringPos]) > ' ' && ch != delim);
  251.                 setarg(paramPos, 0, num * neg);
  252.             }
  253.             case 'h', 'x':
  254.             {
  255.                 new
  256.                     num = 0,
  257.                     ch = string[stringPos];
  258.                 do
  259.                 {
  260.                     stringPos++;
  261.                     switch (ch)
  262.                     {
  263.                         case 'x', 'X':
  264.                         {
  265.                             num = 0;
  266.                             continue;
  267.                         }
  268.                         case '0' .. '9':
  269.                         {
  270.                             num = (num << 4) | (ch - '0');
  271.                         }
  272.                         case 'a' .. 'f':
  273.                         {
  274.                             num = (num << 4) | (ch - ('a' - 10));
  275.                         }
  276.                         case 'A' .. 'F':
  277.                         {
  278.                             num = (num << 4) | (ch - ('A' - 10));
  279.                         }
  280.                         default:
  281.                         {
  282.                             return -1;
  283.                         }
  284.                     }
  285.                 }
  286.                 while ((ch = string[stringPos]) > ' ' && ch != delim);
  287.                 setarg(paramPos, 0, num);
  288.             }
  289.             case 'c':
  290.             {
  291.                 setarg(paramPos, 0, string[stringPos++]);
  292.             }
  293.             case 'f':
  294.             {
  295.  
  296.                 new changestr[16], changepos = 0, strpos = stringPos;
  297.                 while(changepos < 16 && string[strpos] && string[strpos] != delim)
  298.                 {
  299.                     changestr[changepos++] = string[strpos++];
  300.                     }
  301.                 changestr[changepos] = '\0';
  302.                 setarg(paramPos,0,_:floatstr(changestr));
  303.             }
  304.             case 'p':
  305.             {
  306.                 delim = format[formatPos++];
  307.                 continue;
  308.             }
  309.             case '\'':
  310.             {
  311.                 new
  312.                     end = formatPos - 1,
  313.                     ch;
  314.                 while ((ch = format[++end]) && ch != '\'') {}
  315.                 if (!ch)
  316.                 {
  317.                     return -1;
  318.                 }
  319.                 format[end] = '\0';
  320.                 if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
  321.                 {
  322.                     if (format[end + 1])
  323.                     {
  324.                         return -1;
  325.                     }
  326.                     return 0;
  327.                 }
  328.                 format[end] = '\'';
  329.                 stringPos = ch + (end - formatPos);
  330.                 formatPos = end + 1;
  331.             }
  332.             case 'u':
  333.             {
  334.                 new
  335.                     end = stringPos - 1,
  336.                     id = 0,
  337.                     bool:num = true,
  338.                     ch;
  339.                 while ((ch = string[++end]) && ch != delim)
  340.                 {
  341.                     if (num)
  342.                     {
  343.                         if ('0' <= ch <= '9')
  344.                         {
  345.                             id = (id * 10) + (ch - '0');
  346.                         }
  347.                         else
  348.                         {
  349.                             num = false;
  350.                         }
  351.                     }
  352.                 }
  353.                 if (num && IsPlayerConnected(id))
  354.                 {
  355.                     setarg(paramPos, 0, id);
  356.                 }
  357.                 else
  358.                 {
  359.                     #if !defined foreach
  360.                         #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
  361.                         #define __SSCANF_FOREACH__
  362.                     #endif
  363.                     string[end] = '\0';
  364.                     num = false;
  365.                     new
  366.                         name[MAX_PLAYER_NAME];
  367.                     id = end - stringPos;
  368.                     foreach (Player, playerid)
  369.                     {
  370.                         GetPlayerName(playerid, name, sizeof (name));
  371.                         if (!strcmp(name, string[stringPos], true, id))
  372.                         {
  373.                             setarg(paramPos, 0, playerid);
  374.                             num = true;
  375.                             break;
  376.                         }
  377.                     }
  378.                     if (!num)
  379.                     {
  380.                         setarg(paramPos, 0, INVALID_PLAYER_ID);
  381.                     }
  382.                     string[end] = ch;
  383.                     #if defined __SSCANF_FOREACH__
  384.                         #undef foreach
  385.                         #undef __SSCANF_FOREACH__
  386.                     #endif
  387.                 }
  388.                 stringPos = end;
  389.             }
  390.             case 's', 'z':
  391.             {
  392.                 new
  393.                     i = 0,
  394.                     ch;
  395.                 if (format[formatPos])
  396.                 {
  397.                     while ((ch = string[stringPos++]) && ch != delim)
  398.                     {
  399.                         setarg(paramPos, i++, ch);
  400.                     }
  401.                     if (!i)
  402.                     {
  403.                         return -1;
  404.                     }
  405.                 }
  406.                 else
  407.                 {
  408.                     while ((ch = string[stringPos++]))
  409.                     {
  410.                         setarg(paramPos, i++, ch);
  411.                     }
  412.                 }
  413.                 stringPos--;
  414.                 setarg(paramPos, i, '\0');
  415.             }
  416.             default:
  417.             {
  418.                 continue;
  419.             }
  420.         }
  421.         while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
  422.         {
  423.             stringPos++;
  424.         }
  425.         while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
  426.         {
  427.             stringPos++;
  428.         }
  429.         paramPos++;
  430.     }
  431.     do
  432.     {
  433.         if ((delim = format[formatPos++]) > ' ')
  434.         {
  435.             if (delim == '\'')
  436.             {
  437.                 while ((delim = format[formatPos++]) && delim != '\'') {}
  438.             }
  439.             else if (delim != 'z')
  440.             {
  441.                 return delim;
  442.             }
  443.         }
  444.     }
  445.     while (delim > ' ');
  446.     return 0;
  447. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement