unguru2009

Sistem Crash car!

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