Advertisement
Guest User

Tannz0rz

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