Guest User

Tannz0rz

a guest
Dec 15th, 2009
1,266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.04 KB | None | 0 0
  1. #include <a_samp>
  2. #define FILTERSCRIPT
  3.  
  4. #define RED 0xAA3333AA
  5.  
  6. new bool:IsSpeeding[MAX_PLAYERS],
  7.     playerspeedtimer[MAX_PLAYERS],
  8.     CrashTimer[MAX_PLAYERS],
  9.     Float:pSpeed[MAX_PLAYERS];
  10.  
  11. public OnFilterScriptInit()
  12. {
  13.     for(new i=0;i<GetMaxPlayers();i++)
  14.     {
  15.         IsSpeeding[i] = false;
  16.     }
  17.     return 1;
  18. }
  19.  
  20. public OnPlayerConnect(playerid)
  21. {
  22.     playerspeedtimer[playerid] = SetTimerEx("VehicleSpeed", 100, 1, "i", playerid);
  23.     return 1;
  24. }
  25.  
  26. public OnPlayerDisconnect(playerid)
  27. {
  28.     KillTimer(playerspeedtimer[playerid]);
  29.     KillTimer(CrashTimer[playerid]);
  30.     IsSpeeding[playerid] = false;
  31.     return 1;
  32. }
  33.  
  34. forward VehicleSpeed(playerid);
  35. public VehicleSpeed(playerid)
  36. {
  37.     new Float:ovx, Float:ovy, Float:ovz;
  38.     if(IsPlayerInAnyVehicle(playerid))
  39.     {
  40.         GetVehicleVelocity(GetPlayerVehicleID(playerid), ovx, ovy, ovz);
  41.         if(ovx < -0.4 || ovx > 0.4 || ovy < -0.4 || ovy > 0.4 && !IsSpeeding[playerid])
  42.         {
  43.             CrashTimer[playerid] = SetTimerEx("Speeding", 100, 1, "i", playerid);
  44.             ovx = (ovx >= 0) ? ovx : -ovx;
  45.             ovy = (ovy >= 0) ? ovy : -ovy;
  46.             pSpeed[playerid] = ((ovx+ovy)/2);
  47.             IsSpeeding[playerid] = true;
  48.         }
  49.         else
  50.         {
  51.             KillTimer(CrashTimer[playerid]);
  52.             pSpeed[playerid] = 0.0;
  53.             IsSpeeding[playerid] = false;
  54.         }
  55.     }
  56.     return 1;
  57. }
  58.  
  59. forward Speeding(playerid);
  60. public Speeding(playerid)
  61. {
  62.     new Float:nvx, Float:nvy, Float:nvz;
  63.     if(IsPlayerInAnyVehicle(playerid) && IsSpeeding[playerid])
  64.     {
  65.         GetVehicleVelocity(GetPlayerVehicleID(playerid), nvx, nvy, nvz);
  66.         if(nvx > -0.1 && nvx < 0.1 && nvy > -0.1 && nvy < 0.1)
  67.         {
  68.             new Float:crashhealth;
  69.             GetPlayerHealth(playerid, crashhealth);
  70.             crashhealth -= (pSpeed[playerid] * 100.0);
  71.             SetPlayerHealth(playerid, crashhealth);
  72.             SetPlayerDrunkLevel(playerid, 50000);
  73.             SetTimerEx("StopCameraEffect", 5000, 0, "i", playerid);
  74.             IsSpeeding[playerid] = false;
  75.         }
  76.     }
  77.     return 1;
  78. }
  79.  
  80. forward StopCameraEffect(playerid);
  81. public StopCameraEffect(playerid)
  82. {
  83.     SetPlayerDrunkLevel(playerid, 0);
  84.     return 1;
  85. }
Advertisement
Add Comment
Please, Sign In to add comment