Advertisement
Guest User

SpeedBoost

a guest
Mar 6th, 2011
434
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 10.49 KB | None | 0 0
  1. /*
  2.                                    Copyright(c), Roach™
  3. .___________________________________________________________________________________________.
  4. |                                                                                           |
  5. |                    ____                                      __    __                     |
  6. |                   |  _ \                                    |  |  |  |                    |
  7. |                   | |_| |    _____     _______     _____    |  |__|  |                    |
  8. |                   |    /    |  _  |   |  ___  |   |  ___|   |   __   |                    |
  9. |                   | |\ \  _ | |_| | _ | |___| | _ | |___  _ |  |  |  | _                  |
  10. |                   |_| \_\|_||_____||_||_|   |_||_||_____||_||__|  |__||_|                 |
  11. |                                                                                           |
  12. |._________________________________________________________________________________________.|
  13.                                                                                    R.O.A.C.H.
  14. //==============================================================================
  15. /--> Details/Questions/Updates:
  16.  
  17. [TOPIC]: http://sa-mp.ro/forum/index.php
  18. */
  19. //==============================================================================
  20. // Includes
  21. //==============================================================================
  22. #include <a_samp>
  23. #include  <zcmd>
  24. //==============================================================================
  25. //|----------------------------------------------------------------------------|
  26. //                                 Config
  27. //==============================================================================
  28. //==============================================================================
  29. //                                Defines
  30. //==============================================================================
  31. #define FILTERSCRIPT    true
  32. //==============================================================================
  33. //                              Speed-Boost
  34. //==============================================================================
  35. #define SB      2013
  36. #define SB2     2014
  37. #define SBK     2015
  38. //==============================================================================
  39. //                               Colors
  40. //==============================================================================
  41. #define COLOR_RED       0xAA3333AA
  42. #define COLOR_INFO      0x4077F7FF
  43. //==============================================================================
  44. //                             End Config
  45. //|----------------------------------------------------------------------------|
  46. //==============================================================================
  47. new SbK[MAX_PLAYERS], Sb[MAX_PLAYERS], Velocity[MAX_PLAYERS];
  48.  
  49. #if FILTERSCRIPT == true
  50. public OnFilterScriptInit()
  51. {
  52.     new h, mins, y, m, d;
  53.     gettime(h,mins);
  54.     getdate(y,m,d);
  55.     print("\n ___________________________________________________");
  56.     print("                                                      ");
  57.     print("                   Speed-Boost                        ");
  58.     print("                 ---------------                      ");
  59.     print("                       B.Y.                           ");
  60.     print("                     R.O.A.C.H                        ");
  61.     print(" ___________________________________________________\n");
  62.     print("                                                      ");
  63.     print(" |-> Loaded Successfully!\n                           ");
  64.     printf(" Today: %d/%d/%d - Hour: %d:%d", d, m, y, h, mins);
  65.     print(" ___________________________________________________\n");
  66.     return 1;
  67. }
  68. public OnFilterScriptExit()
  69. {
  70.     print("\n ___________________________________________________");
  71.     print("                                                      ");
  72.     print("                   Speed-Boost                        ");
  73.     print("                 ---------------                      ");
  74.     print("                       B.Y.                           ");
  75.     print("                     R.O.A.C.H                        ");
  76.     print(" ___________________________________________________\n");
  77.     print(" |-> Unloaded!");
  78.     return 1;
  79. }
  80. #endif
  81.  
  82. public OnPlayerConnect(playerid)
  83. {
  84.     SbK[playerid] = 0;  Sb[playerid] = 0;   Velocity[playerid] = 0;
  85.     return 1;
  86. }
  87.  
  88. public OnPlayerDisconnect(playerid, reason)
  89. {
  90.     SbK[playerid] = 0;  Sb[playerid] = 0;   Velocity[playerid] = 0;
  91.     return 1;
  92. }
  93.  
  94. //==============================================================================
  95. //                              Commands
  96. //==============================================================================
  97. CMD:speedboost(playerid, params[])
  98. {
  99.     if(IsPlayerInAnyVehicle(playerid)) ShowPlayerDialog(playerid, SB, DIALOG_STYLE_INPUT, " ", "\t\t    {4077F7}[SIZE]\n\n{FFFFFF}Please insert the height for your car velocity!\nValues are: {7F7F7F}1{FFFFFF} - {7F7F7F}3","Ok","Exit");
  100.     else SendClientMessage(playerid, COLOR_RED, "[ERROR]: {FFFFFF}You are not in a vehicle.");
  101.     return 1;
  102. }
  103. CMD:sb(playerid, params[]) return cmd_speedboost(playerid, params);
  104.  
  105. CMD:sboff(playerid, params[])
  106. {
  107.     if(Sb[playerid] == 0) return ShowPlayerDialog(playerid, SB2, DIALOG_STYLE_MSGBOX, "[ERROR]:", "{F40900}/speedboost {FFFFFF}is currently OFF! \nTo enable it type {F40900}/speedboost {FFFFFF}and type the requested numbers.","Ok","");
  108.     Sb[playerid] = 0;
  109.     Velocity[playerid] = 0;
  110.     return ShowPlayerDialog(playerid, SB2, DIALOG_STYLE_MSGBOX, " ", "\t\t{4077F7}[INFO]\n\n{FFFFFF}You stopped from using {F40900}/speedboost{FFFFFF}.\nType {F40900}/speedboost {FFFFFF}again FOR SPEED!\n  Current value: {7F7F7F}0","Ok","");
  111. }
  112. CMD:speedboostoff(playerid, params[]) return cmd_sboff(playerid, params);
  113.  
  114.  
  115. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  116. {
  117.     new Float:vx, Float:vy, Float:vz;
  118.     GetVehicleVelocity(GetPlayerVehicleID(playerid), vx, vy, vz);
  119.     if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER && Sb[playerid] == 1)
  120.     {
  121.         if (newkeys & KEY_ACTION && SbK[playerid] == 2)
  122.         {
  123.             if(Velocity[playerid] == 1) return SetVehicleVelocity(GetPlayerVehicleID(playerid), vx * 1.4, vy * 1.4, vz);
  124.             if(Velocity[playerid] == 2) return SetVehicleVelocity(GetPlayerVehicleID(playerid), vx * 1.8, vy * 1.8, vz);
  125.             if(Velocity[playerid] == 3) return SetVehicleVelocity(GetPlayerVehicleID(playerid), vx * 2.0, vy * 2.0, vz);
  126.             return 1;
  127.         }
  128.         if (newkeys & KEY_CROUCH && SbK[playerid] == 1)
  129.         {
  130.             if(Velocity[playerid] == 1) return SetVehicleVelocity(GetPlayerVehicleID(playerid), vx * 1.4, vy * 1.4, vz);
  131.             if(Velocity[playerid] == 2) return SetVehicleVelocity(GetPlayerVehicleID(playerid), vx * 1.8, vy * 1.8, vz);
  132.             if(Velocity[playerid] == 3) return SetVehicleVelocity(GetPlayerVehicleID(playerid), vx * 2.0, vy * 2.0, vz);
  133.             return 1;
  134.         }
  135.         if (newkeys & KEY_FIRE && SbK[playerid] == 3)
  136.         {
  137.             if(Velocity[playerid] == 1) return SetVehicleVelocity(GetPlayerVehicleID(playerid), vx * 1.4, vy * 1.4, vz);
  138.             if(Velocity[playerid] == 2) return SetVehicleVelocity(GetPlayerVehicleID(playerid), vx * 1.8, vy * 1.8, vz);
  139.             if(Velocity[playerid] == 3) return SetVehicleVelocity(GetPlayerVehicleID(playerid), vx * 2.0, vy * 2.0, vz);
  140.             return 1;
  141.         }
  142.     }
  143.     return 1;
  144. }
  145.  
  146. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  147. {
  148.     new VS[500], KS1[300], KS2[35];
  149.     if(dialogid == SB)
  150.     {
  151.         if(response == 1)
  152.         {
  153.             new VValue = strval(inputtext);
  154.             if(!inputtext[0]) return ShowPlayerDialog(playerid, SB, DIALOG_STYLE_INPUT, " ", "\t\t     {4077F7}[SIZE]\n\n{FFFFFF}Please insert the value for your car velocity!\nValues are: {7F7F7F}1{FFFFFF} - {7F7F7F}3","Ok","Exit");
  155.             if(!IsNumeric(inputtext[0])) return ShowPlayerDialog(playerid, SB, DIALOG_STYLE_INPUT, " ", "\t\t   {AA3333}[ERROR]\n\n{FFFFFF}Only numbers allowed!\nPlease insert the height for your car velocity!\nValues are: {7F7F7F}1{FFFFFF} - {7F7F7F}3","Ok","Exit");
  156.             if(inputtext[0] > '3') return ShowPlayerDialog(playerid, SB, DIALOG_STYLE_INPUT, " ", "\t           {AA3333}[ERROR]\n\n{FFFFFF}Invalid value!\nPlease insert again!\nValues are: {7F7F7F}1{FFFFFF} - {7F7F7F}3","Ok","Exit");
  157.             if(inputtext[0] == '0') return ShowPlayerDialog(playerid, SB, DIALOG_STYLE_INPUT, " ", "\t           {AA3333}[ERROR]\n\n{FFFFFF}Value 0 is incorrect!\nPlease insert again!\nValues are: {7F7F7F}1{FFFFFF} - {7F7F7F}3","Ok","Exit");
  158.            
  159.             Sb[playerid] = 1;
  160.             Velocity[playerid] = VValue;
  161.             format(VS, sizeof(VS), "\t\t       {4077F7}[KEY's]\n\n{FFFFFF}You selected value {7F7F7F}%d{FFFFFF}!\nNow, select the number to select the button with wich\nyou will have to press to jump\nWrite:\n\t{7F7F7F}1 {FFFFFF}- {67A9F7}Horn Key(H)\n\t{7F7F7F}2 {FFFFFF}- {67A9F7}Left CTRL(CTRL)\n\t{7F7F7F}3 {FFFFFF}- {67A9F7}Left Click(FIRE)",Velocity[playerid]);
  162.             return ShowPlayerDialog(playerid, SBK, DIALOG_STYLE_INPUT, " ", VS,"Ok","Exit");
  163.         }
  164.     }
  165.     if(dialogid == SBK)
  166.     {
  167.         if(response == 1)
  168.         {
  169.             if(!inputtext[0]) return format(VS, sizeof(VS), "\t\t   {AA3333}[ERROR]\n\n{FFFFFF}No number found in the input!\nWrite:\n\t{7F7F7F}1 {FFFFFF}- {67A9F7}Horn Key(H)\n\t{7F7F7F}2 {FFFFFF}- {67A9F7}Left CTRL(CTRL)\n\t{7F7F7F}3 {FFFFFF}- {67A9F7}Left Click(FIRE)",Velocity[playerid]), ShowPlayerDialog(playerid, SBK, DIALOG_STYLE_INPUT, " ", VS,"Ok","Exit");
  170.             if(!IsNumeric(inputtext[0])) return ShowPlayerDialog(playerid, SBK, DIALOG_STYLE_INPUT, " ", "\t\t   {AA3333}[ERROR]\n\n{FFFFFF}Only numbers allowed!\nSelect a number to select the button with wich\nyou will have to press to jump\nWrite:\n\t{7F7F7F}1 {FFFFFF}- {67A9F7}Horn Key(H)\n\t{7F7F7F}2 {FFFFFF}- {67A9F7}Left CTRL(CTRL)\n\t{7F7F7F}3 {FFFFFF}- {67A9F7}Left Click(FIRE)","Ok","Exit");
  171.             if(inputtext[0] > '3') return format(KS1, sizeof(KS1), "\t           {AA3333}[ERROR]\n\n{FFFFFF}There is no number %d in the list below!\nWrite:\n\t{7F7F7F}1 {FFFFFF}- {67A9F7}Horn Key(H)\n\t{7F7F7F}2 {FFFFFF}- {67A9F7}Left CTRL(CTRL)\n\t{7F7F7F}3 {FFFFFF}- {67A9F7}Left Click(FIRE)",inputtext,Velocity[playerid]), ShowPlayerDialog(playerid, SBK, DIALOG_STYLE_INPUT, " ", KS1,"Ok","Exit");
  172.             if(inputtext[0] == '1') SbK[playerid] = 1, KS2 = "{67A9F7}Horn Key(H){FFFFFF}";
  173.             if(inputtext[0] == '2') SbK[playerid] = 2, KS2 = "{67A9F7}Left CTRL(CTRL){FFFFFF}";
  174.             if(inputtext[0] == '3') SbK[playerid] = 3, KS2 = "{67A9F7}Left Click(Fire){FFFFFF}";
  175.             format(KS1, sizeof(KS1), "\t\t        {4077F7}[INFO]\n\n{FFFFFF}You selected %s{FFFFFF}, now press it for SPEED!\nType {F40900}/sboff {FFFFFF}to disable it!",KS2);
  176.             return ShowPlayerDialog(playerid, SB2, DIALOG_STYLE_MSGBOX," ", KS1,"Ok","");
  177.         }
  178.     }
  179.     return 1;
  180. }
  181.  
  182.  
  183. stock IsNumeric(nstring[])
  184. {
  185.     for (new i = 0, j = strlen(nstring);
  186.     i < j; i++)
  187.     {
  188.         if (nstring[i] > '9' || nstring[i] < '0')
  189.         return 0;
  190.     }
  191.     return 1;
  192. }
  193. // © R.O.A.C.H. 2010 - 2011 -- All rights Reserved
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement