Advertisement
dh240473

[Filterscript] Boost System V1.0

Sep 26th, 2015
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.51 KB | None | 0 0
  1. //============================================================================//
  2. //                            [BoostSystem By DH240473]                       //
  3. // Thanks To Zeex For ZCMD Include                                            //
  4. //============================================================================//
  5. #include <a_samp>
  6. #include <zcmd>
  7. //Colors
  8. #define  Yellow            0xFFDD00AA
  9. //New Stuff
  10. new Float:Boost[MAX_PLAYERS];
  11.  
  12. public OnFilterScriptInit()
  13. {
  14.         for (new i = 0; i < MAX_PLAYERS; i++)
  15.         {
  16.             if (IsPlayerConnected(i) && !IsPlayerNPC(i))//Detect A Connected And Non Npc Player ! Means False
  17.             {
  18.                 Boost[i] = 1.5;//Set The Boost Amount
  19.             }
  20.         }
  21.         return 1;
  22. }
  23. public OnFilterScriptExit()
  24. {
  25.         return 1;
  26. }
  27.  
  28. public OnPlayerConnect(playerid)
  29. {
  30.         Boost[playerid] = 1.5;//Set The Boost Amount
  31.         return 1;
  32. }
  33.  
  34. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  35. {
  36.         if (IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
  37.         {
  38.                 if (newkeys & KEY_FIRE)
  39.                 {
  40.                     new Float:x, Float:y, Float:z;
  41.                     GetVehicleVelocity(GetPlayerVehicleID(playerid), x, y, z);
  42.                     if (floatabs(x) < 3 && floatabs(y) < 3 && floatabs(z) < 3)
  43.                     {
  44.                         SetVehicleVelocity(GetPlayerVehicleID(playerid), x * Boost[playerid], y * Boost[playerid], z * Boost[playerid]);
  45.                     }
  46.                     return 1;
  47.                 }
  48.         }
  49.         return 1;
  50. }
  51.  
  52. CMD:ssb(playerid, params[])
  53. {
  54.         new strBoostMultiplier[256],idx = 0;
  55.         new strTempString[256];
  56.         strBoostMultiplier = strtok(params, idx);
  57.         if (!strlen(strBoostMultiplier))
  58.         {
  59.                 SendClientMessage(playerid, Yellow, "++ Usage: /ssb [Amount]");
  60.                 SendClientMessage(playerid, Yellow, "+  Allows You To Set The Boost Amount That Is Applied When You Press KEY FIRE");
  61.                 SendClientMessage(playerid, Yellow, "+  Accepted Boost Amount That Are Values Between 1.0 And  3.0");
  62.                 format(strTempString,sizeof(strTempString), "+  Your current Boost Amount is: %0.2f", Boost[playerid]);
  63.                 SendClientMessage(playerid, Yellow, strTempString);
  64.                 return 1;
  65.         }
  66.         if (!IsNumeric2(strBoostMultiplier))
  67.         {
  68.                 SendClientMessage(playerid, Yellow, "++ Usage: /ssb [Amount]");
  69.                 SendClientMessage(playerid, Yellow, "+  Allows You To Set The Boost Amount That Is Applied When You Press KEY FIRE");
  70.                 SendClientMessage(playerid, Yellow, "+  Accepted Boost Amount That Are Values Between 1.0 And  3.0");
  71.                 format(strTempString,sizeof(strTempString), "+  Your current Boost Amount is: %0.2f", Boost[playerid]);
  72.                 SendClientMessage(playerid, Yellow, strTempString);
  73.                 return 1;
  74.         }
  75.         new Float:BoostMultiplier = floatstr(strBoostMultiplier);
  76.         if (BoostMultiplier < 1.0 || BoostMultiplier > 3.0)
  77.         {
  78.                 SendClientMessage(playerid, Yellow, "+ Sorry, you must enter a Boost Amount Between 1.0 and 3.0");
  79.                 return 1;
  80.         }
  81.         Boost[playerid] = BoostMultiplier;
  82.         format(strTempString,sizeof(strTempString), "+You Set Your Boost Amount To %0.2f", Boost[playerid]);
  83.         SendClientMessage(playerid, Yellow, strTempString);
  84.         return 1;
  85. }
  86.  
  87. stock strtok(const string[], &index)
  88. {
  89.  
  90.         new length = strlen(string);
  91.         while ((index < length) && (string[index] <= ' '))
  92.         {
  93.                 index++;
  94.         }
  95.         new offset = index;
  96.         new result[20];
  97.         while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  98.         {
  99.                 result[index - offset] = string[index];
  100.                 index++;
  101.         }
  102.         result[index - offset] = EOS;
  103.         return result;
  104. }
  105.  
  106. IsNumeric2(const string[])
  107. {
  108.         new length=strlen(string);
  109.         if (length==0) return false;
  110.         for (new i = 0; i < length; i++)
  111.         {
  112.           if((string[i] > '9' || string[i] < '0' && string[i]!='-' && string[i]!='+' && string[i]!='.')
  113.                  || (string[i]=='-' && i!=0)
  114.                  || (string[i]=='+' && i!=0)
  115.            ) return false;
  116.         }
  117.         if (length==1 && (string[0]=='-' || string[0]=='+' || string[0]=='.')) return false;
  118.         return true;
  119. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement