Guest User

Kinetic

a guest
Apr 8th, 2009
1,685
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.25 KB | None | 0 0
  1. //AI Blinkers by Kinetic
  2. #include <a_samp>
  3. #include <a_players>
  4.  
  5. //----[Quick Stats]-------------------------------------------------------------
  6. #define timerspeed 500 //Speed of the timer in milliseconds (1000 = 1 second)
  7. #define blinkerduration 10 //Length of the duration that the blinker will stay on in seconds.
  8. #define rightkey KEY_LOOK_RIGHT //The key you press to turn the right blinker on
  9. #define leftkey KEY_LOOK_LEFT //The key you press to turn the left blinker on
  10. //------------------------------------------------------------------------------
  11.  
  12. // PRESSED(newkeys, oldkeys, keys)
  13. #define PRESSED(%0,%1,%2) \
  14. ((((%0) & (%2)) == (%2)) && (((%1) & (%2)) != (%2)))
  15.  
  16. new tmpcar;
  17. new arrow[MAX_PLAYERS];
  18. new Step[MAX_PLAYERS];
  19. new blinks[MAX_PLAYERS];
  20. new duration[MAX_PLAYERS];
  21. new blinker[MAX_PLAYERS];
  22. new Float:tmpx[MAX_PLAYERS],Float:tmpy[MAX_PLAYERS],Float:tmpz[MAX_PLAYERS],Float:tmpang[MAX_PLAYERS];
  23. new Float:startang[MAX_PLAYERS];
  24.  
  25. forward Blinker(playerid);
  26.  
  27. public OnFilterScriptExit()
  28. {
  29. for(new i=0; i<=GetMaxPlayers(); i++)
  30. {
  31. KillTimer(blinks[i]);
  32. DestroyObject(arrow[i]);
  33. }
  34. }
  35.  
  36. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  37. {
  38. if(PRESSED(newkeys, oldkeys, rightkey))
  39. {
  40. if(blinker[playerid] != 1)
  41. {
  42. KillTimer(blinks[playerid]);
  43. blinks[playerid] = SetTimerEx("Blinker", timerspeed, true,"%i",playerid);
  44. //blinks[playerid] = SetTimer("Blinker", timerspeed, true);
  45. GetPlayerFacingAngle(playerid, startang[playerid]);
  46. blinker[playerid] = 1;
  47. return 1;
  48. }
  49. if(blinker[playerid] == 1)
  50. {
  51. KillTimer(blinks[playerid]);
  52. DestroyObject(arrow[playerid]);
  53. blinker[playerid] = 0;
  54. GetPlayerFacingAngle(playerid, startang[playerid]);
  55. duration[playerid] = 0;
  56. return 1;
  57. }
  58. }
  59. if(PRESSED(newkeys, oldkeys, leftkey))
  60. {
  61. if(blinker[playerid] != 2)
  62. {
  63. KillTimer(blinks[playerid]);
  64. blinks[playerid] = SetTimerEx("Blinker", timerspeed, true,"%i",playerid);
  65. //blinks[playerid] = SetTimer("Blinker", timerspeed, true);
  66. blinker[playerid] = 2;
  67. return 1;
  68. }
  69. if(blinker[playerid] == 2)
  70. {
  71. KillTimer(blinks[playerid]);
  72. DestroyObject(arrow[playerid]);
  73. blinker[playerid] = 0;
  74. duration[playerid] = 0;
  75. return 1;
  76. }
  77. }
  78. return 1;
  79. }
  80.  
  81. public Blinker(playerid)
  82. {
  83. if(duration[playerid] >= blinkerduration)
  84. {
  85. KillTimer(blinks[playerid]);
  86. DestroyObject(arrow[playerid]);
  87. duration[playerid] = 0;
  88. return 1;
  89. }
  90. if(blinker[playerid] == 0)
  91. {
  92. KillTimer(blinks[playerid]);
  93. DestroyObject(arrow[playerid]);
  94. duration[playerid] = 0;
  95. return 1;
  96. }
  97. if(blinker[playerid] == 1)
  98. {
  99. if(IsPlayerInAnyVehicle(playerid))
  100. {
  101. tmpcar = GetPlayerVehicleID(playerid);
  102. GetVehiclePos(tmpcar, tmpx[playerid], tmpy[playerid], tmpz[playerid]);
  103. GetVehicleZAngle(tmpcar, tmpang[playerid]);
  104. if(Step[playerid] == 0)
  105. {
  106. arrow[playerid] = CreateObject(1318, tmpx[playerid], tmpy[playerid], tmpz[playerid]+0.7, 90, tmpang[playerid]+89, 180);
  107. AttachObjectToPlayer(arrow[playerid], playerid, 0, 0, 1.7, 90, 89, 180);
  108. // GameTextForPlayer(playerid, "~g~>>>", 300, 4);
  109. Step[playerid] = 1;
  110. return 1;
  111. }
  112. if(Step[playerid] == 1)
  113. {
  114. duration[playerid]++;
  115. DestroyObject(arrow[playerid]);
  116. Step[playerid] = 0;
  117. return 1;
  118. }
  119. }
  120. }
  121. if(blinker[playerid] == 2)
  122. {
  123. if(IsPlayerInAnyVehicle(playerid))
  124. {
  125. tmpcar = GetPlayerVehicleID(playerid);
  126. GetVehiclePos(tmpcar, tmpx[playerid], tmpy[playerid], tmpz[playerid]);
  127. GetVehicleZAngle(tmpcar, tmpang[playerid]);
  128. if(Step[playerid] == 0)
  129. {
  130. arrow[playerid] = CreateObject(1318, tmpx[playerid], tmpy[playerid], tmpz[playerid]+0.7, 90, tmpang[playerid]-89, 180);
  131. AttachObjectToPlayer(arrow[playerid], playerid, 0, 0, 1.7, 90, 269, 180);
  132. // GameTextForPlayer(playerid, "~g~<<<", 300, 4);
  133. Step[playerid] = 1;
  134. return 1;
  135. }
  136. if(Step[playerid] == 1)
  137. {
  138. duration[playerid]++;
  139. DestroyObject(arrow[playerid]);
  140. Step[playerid] = 0;
  141. return 1;
  142. }
  143. }
  144. }
  145. return 1;
  146. }
Advertisement
Add Comment
Please, Sign In to add comment