Advertisement
Guest User

Vehicle Breakdancing

a guest
Sep 17th, 2011
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.07 KB | None | 0 0
  1. // ----------------------[Vehicle Breakdancing System]---------------------- //
  2. // //
  3. // Author: Libra | Margi First Release: 21.08.2011 //
  4. // Last Update: 21.08.2011 Version: v1.0 //
  5. // Lines: 127 All Rights Reserved //
  6. // Created for SA-MP 0.3c //
  7. // //
  8. // ------------------------------------------------------------------------- //
  9.  
  10. #include <a_samp>
  11. #include <sscanf2>
  12.  
  13. #define yellow 0xFFFF00FF
  14. #define red 0xFF0000FF
  15.  
  16. #define BreakdanceMultipier 0.01 //Multipier of vehicle breakdancing system
  17. #define BreakdanceTime 100 //Number of miliseconds that updates velocity
  18.  
  19. #define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
  20.  
  21. new BreakdanceStyle[MAX_PLAYERS]; //To check which breakdance style does player use
  22. new Float:BreakdanceVelocity[MAX_PLAYERS]; //To check current velocity of vehicle
  23.  
  24. public OnFilterScriptInit()
  25. {
  26. SetTimer("OnBreakdanceUpdate",BreakdanceTime,1);
  27. }
  28.  
  29. public OnPlayerConnect(playerid)
  30. {
  31. BreakdanceStyle[playerid] = 0;
  32. BreakdanceVelocity[playerid] = 0.00;
  33. return 1;
  34. }
  35.  
  36. public OnPlayerCommandText(playerid, cmdtext[])
  37. {
  38. dcmd(breakdance,10,cmdtext);
  39. return 0;
  40. }
  41.  
  42. dcmd_breakdance(playerid,params[])
  43. {
  44. new string[200], Style;
  45.  
  46. if(!sscanf(params,"d",Style))
  47. {
  48. if(Style >= 0 && Style <= 6)
  49. {
  50. if(Style == 0)
  51. {
  52. SendClientMessage(playerid,yellow,"[INFO]{C0C0C0} You have disabled Vehicle Breakdancing!");
  53. }
  54. else
  55. {
  56. format(string,sizeof(string),"[INFO]{C0C0C0} You have set your Vehicle Breakdance style to %d!", Style);
  57. SendClientMessage(playerid,yellow,string);
  58. }
  59.  
  60. BreakdanceStyle[playerid] = Style;
  61. }
  62. else return SendClientMessage(playerid,red,"[ERROR]{C0C0C0} Invaild style - vaild styles are between 1 and 6! Use 0 to disable Vehicle Breakdancing!");
  63. }
  64. else return SendClientMessage(playerid,red,"[USAGE]{C0C0C0} /breakdance [style 1-6]");
  65. return 1;
  66. }
  67.  
  68. forward OnBreakdanceUpdate();
  69. public OnBreakdanceUpdate()
  70. {
  71. for(new i = 0; i < MAX_PLAYERS; i++)
  72. {
  73. if(IsPlayerConnected(i) && !IsPlayerNPC(i))
  74. {
  75. new Keys,Up,Down;
  76. GetPlayerKeys(i,Keys,Up,Down);
  77.  
  78. if(Keys &= KEY_SUBMISSION)
  79. {
  80. if(GetPlayerState(i) == PLAYER_STATE_DRIVER && BreakdanceStyle[i] >= 1)
  81. {
  82. new Float:X, Float:Y, Float:Z;
  83. GetVehicleVelocity(GetPlayerVehicleID(i),X,Y,Z);
  84. SetVehicleVelocity(GetPlayerVehicleID(i),X,Y,Z);
  85. BreakdanceVelocity[i]+=Float:BreakdanceMultipier;
  86.  
  87. if(X == 0 && Y == 0 && Z == 0)
  88. {
  89. SetVehicleVelocity(GetPlayerVehicleID(i),X,Y,Z+0.05); //If X, Y and Z is 0, breakdance wouldn't work
  90. }
  91.  
  92. if(BreakdanceStyle[i] == 1)
  93. {
  94. SetVehicleAngularVelocity(GetPlayerVehicleID(i),BreakdanceVelocity[i],0,0);
  95. }
  96. else if(BreakdanceStyle[i] == 2)
  97. {
  98. SetVehicleAngularVelocity(GetPlayerVehicleID(i),-BreakdanceVelocity[i],0,0);
  99. }
  100. else if(BreakdanceStyle[i] == 3)
  101. {
  102. SetVehicleAngularVelocity(GetPlayerVehicleID(i),0,BreakdanceVelocity[i],0);
  103. }
  104. else if(BreakdanceStyle[i] == 4)
  105. {
  106. SetVehicleAngularVelocity(GetPlayerVehicleID(i),0,-BreakdanceVelocity[i],0);
  107. }
  108. else if(BreakdanceStyle[i] == 5)
  109. {
  110. SetVehicleAngularVelocity(GetPlayerVehicleID(i),0,0,BreakdanceVelocity[i]);
  111. }
  112. else if(BreakdanceStyle[i] == 6)
  113. {
  114. SetVehicleAngularVelocity(GetPlayerVehicleID(i),0,0,-BreakdanceVelocity[i]);
  115. }
  116. }
  117. }
  118. else
  119. {
  120. BreakdanceVelocity[i] = 0.00;
  121. }
  122. }
  123. }
  124. return 1;
  125. }
  126.  
  127. // -----------------------------------[EOF]--------------------------------- //
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement