Guest User

High-jump

a guest
Dec 5th, 2010
390
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 9.60 KB | None | 0 0
  1. /*
  2. *   High-jump Filterscript
  3. *   (c) 2010 by TheHoodRat
  4. */
  5.  
  6. #include <a_samp>
  7. #include <zcmd>
  8.  
  9. #define MAX_AMOUNT (100)
  10.  
  11. new BoostAmount[MAX_PLAYERS];
  12. new IsBoostEnabled[MAX_PLAYERS];
  13.  
  14. public OnFilterScriptInit()
  15. {
  16.     print("===================================");
  17.     print("High Jump by TheHoodRat Enabled");
  18.     print("===================================");
  19.     return 1;
  20. }
  21.  
  22. public OnFilterScriptExit()
  23. {
  24.     print("===================================");
  25.     print("High Jump by TheHoodRat Disabled");
  26.     print("===================================");
  27.     for(new i; i < MAX_PLAYERS; i++) {
  28.         BoostAmount[i] = 0;
  29.         IsBoostEnabled[i] = 0;
  30.     }
  31.     return 1;
  32. }
  33.  
  34. public OnPlayerConnect(playerid)
  35. {
  36.     IsBoostEnabled[playerid] = 1;
  37.     BoostAmount[playerid] = 0;
  38.     SendClientMessage(playerid, 0xFFFFFFAA, "Welcome, set your boost amount now by typing /setboostamount!");
  39.     return 1;
  40. }
  41.  
  42. COMMAND:helpme(playerid, params[])
  43. {
  44.     if(!IsPlayerAdmin(playerid)) {
  45.         SendClientMessage(playerid, 0xFFFFFFAA, "/enable: Enable high jump.");
  46.         SendClientMessage(playerid, 0xFFFFFFAA, "/disable: Disable high jump.");
  47.         SendClientMessage(playerid, 0xFFFFFFAA, "/setboostamount: Set the boost amount.");
  48.         return 1;
  49.     }
  50.     SendClientMessage(playerid, 0xFFFFFFAA, "/enable: Enable high jump.");
  51.     SendClientMessage(playerid, 0xFFFFFFAA, "/disable: Disable high jump.");
  52.     SendClientMessage(playerid, 0xFFFFFFAA, "/setboostamount: Set the boost amount.");
  53.     SendClientMessage(playerid, 0xFFFFFFAA, "/setboostamountforall: Set the boost amount for everyone.");
  54.     return 1;
  55. }
  56. COMMAND:setboostamount(playerid, params[])
  57. {
  58.     new amount, string[128];
  59.     if(sscanf(params, "i", amount)) {
  60.         format(string, 128, "USAGE: /setboostamount <1-%d>",MAX_AMOUNT);
  61.         SendClientMessage(playerid, 0xFFFFFFAA, string);
  62.         return 1;
  63.     }
  64.     if(amount < 1 || amount > MAX_AMOUNT) {
  65.         format(string, 128, "The minimum amount is one and the maximum amount is %d.",MAX_AMOUNT);
  66.         SendClientMessage(playerid, 0xFFFFFFAA, string);
  67.         return 1;
  68.     }
  69.     if(IsBoostEnabled[playerid] == 0)
  70.     {
  71.         SendClientMessage(playerid, 0xFFFFFFAA, "You have high jump disabled (/enable to enable it!)");
  72.         return 1;
  73.     }
  74.     BoostAmount[playerid] = amount;
  75.     format(string, 128, "You have set your boost amount to %i.",amount);
  76.     SendClientMessage(playerid, 0xFFFFFFAA, string);
  77.     return 1;
  78. }
  79.  
  80. COMMAND:enable(playerid, params[])
  81. {
  82.     if(IsBoostEnabled[playerid] == 1)
  83.     {
  84.         SendClientMessage(playerid, 0xFFFFFFAA, "You can't enabled high jump if it's already enabled.");
  85.         return 1;
  86.     }
  87.     IsBoostEnabled[playerid] = 1;
  88.     SendClientMessage(playerid, 0xFFFFFFAA, "You enabled High Jump.");
  89.     return 1;
  90. }
  91.  
  92. COMMAND:disable(playerid, params[])
  93. {
  94.     if(IsBoostEnabled[playerid] == 0)
  95.     {
  96.         SendClientMessage(playerid, 0xFFFFFFAA, "You can't disable high jump if it's already disabled.");
  97.         return 1;
  98.     }
  99.     IsBoostEnabled[playerid] = 0;
  100.     SendClientMessage(playerid, 0xFFFFFFAA, "You disabled High Jump.");
  101.     return 1;
  102. }
  103.  
  104. COMMAND:setboostamountforall(playerid, params[])
  105. {
  106.     if(!IsPlayerAdmin(playerid)) {
  107.         SendClientMessage(playerid, 0xFFFFFFAA, "SERVER: Unknown command.");
  108.         return 1;
  109.     }
  110.     new amount, string[128];
  111.     if(sscanf(params, "i", amount)) {
  112.         format(string, 128, "USAGE: /setboostamountforall <1-%d>",MAX_AMOUNT);
  113.         SendClientMessage(playerid, 0xFFFFFFAA, string);
  114.         return 1;
  115.     }
  116.     if(amount < 1 && amount > MAX_AMOUNT) {
  117.         format(string, 128, "The minimum amount is one and the maximum amount is %d.",MAX_AMOUNT);
  118.         SendClientMessage(playerid, 0xFFFFFFAA, string);
  119.         return 1;
  120.     }
  121.     for(new i; i < MAX_PLAYERS; i++) {
  122.         BoostAmount[i] = amount;
  123.     }
  124.     format(string, 128, "You have set everyone's boost amount to %i.",amount);
  125.     SendClientMessage(playerid, 0xFFFFFFAA, string);
  126.     return 1;
  127. }
  128.  
  129. COMMAND:enablefs(playerid, params[])
  130. {
  131.     if(!IsPlayerAdmin(playerid)) {
  132.         SendClientMessage(playerid, 0xFFFFFFAA, "SERVER: Unknown command.");
  133.         return 1;
  134.     }
  135.     SendRconCommand("loadfs enablefs");
  136.     SendClientMessage(playerid, 0xFFFFFFAA, "Filterscript enabled.");
  137.     return 1;
  138. }
  139.  
  140. COMMAND:disablefs(playerid, params[])
  141. {
  142.     if(!IsPlayerAdmin(playerid)) {
  143.         SendClientMessage(playerid, 0xFFFFFFAA, "SERVER: Unknown command.");
  144.         return 1;
  145.     }
  146.     SendRconCommand("unloadfs enablefs");
  147.     SendClientMessage(playerid, 0xFFFFFFAA, "Filterscript disabled.");
  148.     return 1;
  149. }
  150.  
  151. COMMAND:para(playerid, params[])
  152. {
  153.     GivePlayerWeapon(playerid, 46, 1);
  154.     return true;
  155. }
  156.  
  157. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  158. {
  159.     if(newkeys == KEY_JUMP) {
  160.         if(GetPlayerState(playerid == PLAYER_STATE_ONFOOT)) {
  161.             if(IsBoostEnabled[playerid] == 1) {
  162.                 if(IsPlayerConnected(playerid)) {
  163.                     JumpPlayerFromPosition(playerid);
  164.                     return 1;
  165.                 }
  166.             }
  167.         }
  168.     }
  169.     return 1;
  170. }
  171.  
  172. stock JumpPlayerFromPosition(playerid)
  173. {
  174.     new Float:X, Float:Y, Float:Z;
  175.     GetPlayerPos(playerid, X, Y, Z);
  176.     if(Z > 75) {
  177.         GivePlayerWeapon(playerid, 46, 1);
  178.     }
  179.     SetPlayerPos(playerid, X, Y, Z + BoostAmount[playerid]);
  180.     return 1;
  181. }
  182.  
  183. stock sscanf(string[], format[], {Float,_}:...)
  184. {
  185.     #if defined isnull
  186.         if (isnull(string))
  187.     #else
  188.         if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
  189.     #endif
  190.         {
  191.             return format[0];
  192.         }
  193.     #pragma tabsize 4
  194.     new
  195.         formatPos = 0,
  196.         stringPos = 0,
  197.         paramPos = 2,
  198.         paramCount = numargs(),
  199.         delim = ' ';
  200.     while (string[stringPos] && string[stringPos] <= ' ')
  201.     {
  202.         stringPos++;
  203.     }
  204.     while (paramPos < paramCount && string[stringPos])
  205.     {
  206.         switch (format[formatPos++])
  207.         {
  208.             case '\0':
  209.             {
  210.                 return 0;
  211.             }
  212.             case 'i', 'd':
  213.             {
  214.                 new
  215.                     neg = 1,
  216.                     num = 0,
  217.                     ch = string[stringPos];
  218.                 if (ch == '-')
  219.                 {
  220.                     neg = -1;
  221.                     ch = string[++stringPos];
  222.                 }
  223.                 do
  224.                 {
  225.                     stringPos++;
  226.                     if ('0' <= ch <= '9')
  227.                     {
  228.                         num = (num * 10) + (ch - '0');
  229.                     }
  230.                     else
  231.                     {
  232.                         return -1;
  233.                     }
  234.                 }
  235.                 while ((ch = string[stringPos]) > ' ' && ch != delim);
  236.                 setarg(paramPos, 0, num * neg);
  237.             }
  238.             case 'h', 'x':
  239.             {
  240.                 new
  241.                     num = 0,
  242.                     ch = string[stringPos];
  243.                 do
  244.                 {
  245.                     stringPos++;
  246.                     switch (ch)
  247.                     {
  248.                         case 'x', 'X':
  249.                         {
  250.                             num = 0;
  251.                             continue;
  252.                         }
  253.                         case '0' .. '9':
  254.                         {
  255.                             num = (num << 4) | (ch - '0');
  256.                         }
  257.                         case 'a' .. 'f':
  258.                         {
  259.                             num = (num << 4) | (ch - ('a' - 10));
  260.                         }
  261.                         case 'A' .. 'F':
  262.                         {
  263.                             num = (num << 4) | (ch - ('A' - 10));
  264.                         }
  265.                         default:
  266.                         {
  267.                             return -1;
  268.                         }
  269.                     }
  270.                 }
  271.                 while ((ch = string[stringPos]) > ' ' && ch != delim);
  272.                 setarg(paramPos, 0, num);
  273.             }
  274.             case 'c':
  275.             {
  276.                 setarg(paramPos, 0, string[stringPos++]);
  277.             }
  278.             case 'f':
  279.             {
  280.  
  281.                 new changestr[16], changepos = 0, strpos = stringPos;
  282.                 while(changepos < 16 && string[strpos] && string[strpos] != delim)
  283.                 {
  284.                     changestr[changepos++] = string[strpos++];
  285.                     }
  286.                 changestr[changepos] = '\0';
  287.                 setarg(paramPos,0,_:floatstr(changestr));
  288.             }
  289.             case 'p':
  290.             {
  291.                 delim = format[formatPos++];
  292.                 continue;
  293.             }
  294.             case '\'':
  295.             {
  296.                 new
  297.                     end = formatPos - 1,
  298.                     ch;
  299.                 while ((ch = format[++end]) && ch != '\'') {}
  300.                 if (!ch)
  301.                 {
  302.                     return -1;
  303.                 }
  304.                 format[end] = '\0';
  305.                 if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
  306.                 {
  307.                     if (format[end + 1])
  308.                     {
  309.                         return -1;
  310.                     }
  311.                     return 0;
  312.                 }
  313.                 format[end] = '\'';
  314.                 stringPos = ch + (end - formatPos);
  315.                 formatPos = end + 1;
  316.             }
  317.             case 'u':
  318.             {
  319.                 new
  320.                     end = stringPos - 1,
  321.                     id = 0,
  322.                     bool:num = true,
  323.                     ch;
  324.                 while ((ch = string[++end]) && ch != delim)
  325.                 {
  326.                     if (num)
  327.                     {
  328.                         if ('0' <= ch <= '9')
  329.                         {
  330.                             id = (id * 10) + (ch - '0');
  331.                         }
  332.                         else
  333.                         {
  334.                             num = false;
  335.                         }
  336.                     }
  337.                 }
  338.                 if (num && IsPlayerConnected(id))
  339.                 {
  340.                     setarg(paramPos, 0, id);
  341.                 }
  342.                 else
  343.                 {
  344.                     #if !defined foreach
  345.                         #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
  346.                         #define __SSCANF_FOREACH__
  347.                     #endif
  348.                     string[end] = '\0';
  349.                     num = false;
  350.                     new
  351.                         name[MAX_PLAYER_NAME];
  352.                     id = end - stringPos;
  353.                     foreach (Player, playerid)
  354.                     {
  355.                         GetPlayerName(playerid, name, sizeof (name));
  356.                         if (!strcmp(name, string[stringPos], true, id))
  357.                         {
  358.                             setarg(paramPos, 0, playerid);
  359.                             num = true;
  360.                             break;
  361.                         }
  362.                     }
  363.                     if (!num)
  364.                     {
  365.                         setarg(paramPos, 0, INVALID_PLAYER_ID);
  366.                     }
  367.                     string[end] = ch;
  368.                     #if defined __SSCANF_FOREACH__
  369.                         #undef foreach
  370.                         #undef __SSCANF_FOREACH__
  371.                     #endif
  372.                 }
  373.                 stringPos = end;
  374.             }
  375.             case 's', 'z':
  376.             {
  377.                 new
  378.                     i = 0,
  379.                     ch;
  380.                 if (format[formatPos])
  381.                 {
  382.                     while ((ch = string[stringPos++]) && ch != delim)
  383.                     {
  384.                         setarg(paramPos, i++, ch);
  385.                     }
  386.                     if (!i)
  387.                     {
  388.                         return -1;
  389.                     }
  390.                 }
  391.                 else
  392.                 {
  393.                     while ((ch = string[stringPos++]))
  394.                     {
  395.                         setarg(paramPos, i++, ch);
  396.                     }
  397.                 }
  398.                 stringPos--;
  399.                 setarg(paramPos, i, '\0');
  400.             }
  401.             default:
  402.             {
  403.                 continue;
  404.             }
  405.         }
  406.         while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
  407.         {
  408.             stringPos++;
  409.         }
  410.         while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
  411.         {
  412.             stringPos++;
  413.         }
  414.         paramPos++;
  415.     }
  416.     do
  417.     {
  418.         if ((delim = format[formatPos++]) > ' ')
  419.         {
  420.             if (delim == '\'')
  421.             {
  422.                 while ((delim = format[formatPos++]) && delim != '\'') {}
  423.             }
  424.             else if (delim != 'z')
  425.             {
  426.                 return delim;
  427.             }
  428.         }
  429.     }
  430.     while (delim > ' ');
  431.     return 0;
  432. }
Advertisement
Add Comment
Please, Sign In to add comment