Guest User

for Pro-Pawn.Ru

a guest
Jan 9th, 2016
504
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <a_samp>
  2.  
  3. #define green 0x0AFF0AAA
  4. #define red 0xFF0000FF
  5.  
  6. new fly[MAX_PLAYERS] = {0, 1};
  7. new Float:x, Float:y, Float:z, Float:angle;
  8.  
  9. forward Float:GetXYInFrontOfPlayer(playerid, &Float:q, &Float:w, Float:distance);
  10. forward Float:GetXYBehindPlayer(playerid, &Float:q, &Float:w, Float:distance);
  11. forward FlyTimer();
  12.  
  13. public OnFilterScriptInit()
  14. {
  15. print("\n--------------------------------------");
  16. print("    Flying Command ");
  17. print("    Made by: xXSPRITEXx ");
  18. print("--------------------------------------\n");
  19. SetTimer("FlyTimer",100,1);
  20. return 1;
  21. }
  22.  
  23. public OnPlayerConnect(playerid)
  24. {
  25.     fly[playerid] = 0;
  26.     return 1;
  27. }
  28.  
  29. public OnPlayerSpawn(playerid)
  30. {
  31. fly[playerid] = 0;
  32. return 1;
  33. }
  34.  
  35. public OnPlayerDeath(playerid, killerid, reason)
  36. {
  37. fly[playerid] = 0;
  38. return 1;
  39. }
  40.  
  41. public OnPlayerCommandText(playerid, cmdtext[])
  42. {
  43. new cmd[256];
  44. new idx;
  45. cmd = strtok(cmdtext, idx);
  46.  
  47. if(strcmp(cmd, "/fly", true) == 0 && IsPlayerAdmin(playerid)) {
  48. new tmp[256];
  49. tmp = strtok(cmdtext, idx);
  50. if(!strlen(tmp)) { if(fly[playerid] == 1) { fly[playerid] = 0; SendClientMessage(playerid,red,"Fly mode offline."); TogglePlayerControllable(playerid,true); return 1; } else if(fly[playerid] == 0) { fly[playerid] = 1; SendClientMessage(playerid,green,"Fly mode online."); TogglePlayerControllable(playerid,false); return 1; } }
  51. if(strcmp(tmp, "on", true) == 0) { fly[playerid] = 1; SendClientMessage(playerid,green,"Fly mode online."); TogglePlayerControllable(playerid,false); return 1; }
  52. else if(strcmp(tmp, "off", true) == 0) { fly[playerid] = 0; SendClientMessage(playerid,red,"Fly mode offline."); TogglePlayerControllable(playerid,true); return 1; }
  53. }
  54. return 0;
  55. }
  56.  
  57. Float:GetXYInFrontOfPlayer(playerid, &Float:q, &Float:w, Float:distance)
  58. {
  59. new Float:a;
  60. GetPlayerPos(playerid, q, w, a);
  61. if (GetPlayerState(playerid) == PLAYER_STATE_DRIVER) GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
  62. else GetPlayerFacingAngle(playerid, a);
  63. q += (distance * floatsin(-a, degrees));
  64. w += (distance * floatcos(-a, degrees));
  65. return a;
  66. }
  67.  
  68. Float:GetXYBehindPlayer(playerid, &Float:q, &Float:w, Float:distance)
  69. {
  70. new Float:a;
  71. GetPlayerPos(playerid, q, w, a);
  72. if (GetPlayerState(playerid) == PLAYER_STATE_DRIVER) GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
  73. else GetPlayerFacingAngle(playerid, a);
  74. q += (distance * -floatsin(-a, degrees));
  75. w += (distance * -floatcos(-a, degrees));
  76. return a;
  77. }
  78.  
  79. strtok(const string[], &index)
  80. {
  81. new length = strlen(string);
  82. while ((index < length) && (string[index] <= ' '))
  83. {
  84. index++;
  85. }
  86.  
  87. new offset = index;
  88. new result[20];
  89. while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  90. {
  91. result[index - offset] = string[index];
  92. index++;
  93. }
  94. result[index - offset] = EOS;
  95. return result;
  96. }
  97.  
  98. public FlyTimer()
  99. {
  100. new keys, updown, leftright;
  101. for(new playerid=0;playerid<MAX_PLAYERS;playerid++) {
  102. if(IsPlayerConnected(playerid)) {
  103. if(fly[playerid] == 1) {
  104. GetPlayerKeys(playerid,keys,updown,leftright);
  105. if(updown == KEY_UP) {
  106. if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT) {
  107. GetPlayerPos(playerid, x, y, z);
  108. GetXYInFrontOfPlayer(playerid, x, y, 5.0);
  109. SetPlayerPos(playerid, x, y, z);
  110. SetCameraBehindPlayer(playerid);
  111. }
  112. else if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) {
  113. new playercar = GetPlayerVehicleID(playerid);
  114. GetVehiclePos(playercar, x, y, z);
  115. GetXYInFrontOfPlayer(playerid, x, y, 5.0);
  116. SetVehiclePos(playercar, x, y, z);
  117. }
  118. }
  119. else if(updown == KEY_DOWN) {
  120. if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT) {
  121. GetPlayerPos(playerid, x, y, z);
  122. GetXYBehindPlayer(playerid, x, y, 5.0);
  123. SetPlayerPos(playerid, x, y, z);
  124. SetCameraBehindPlayer(playerid);
  125. }
  126. else if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) {
  127. new playercar = GetPlayerVehicleID(playerid);
  128. GetVehiclePos(playercar, x, y, z);
  129. GetXYBehindPlayer(playerid, x, y, 5.0);
  130. SetVehiclePos(playercar, x, y, z);
  131. }
  132. }
  133. if(leftright == KEY_LEFT) {
  134. if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT) {
  135. GetPlayerFacingAngle(playerid, angle);
  136. SetPlayerFacingAngle(playerid, angle+10);
  137. SetCameraBehindPlayer(playerid);
  138. }
  139. else if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) {
  140. new playercar = GetPlayerVehicleID(playerid);
  141. GetVehicleZAngle(playercar, angle);
  142. SetVehicleZAngle(playercar, angle+10);
  143. }
  144. }
  145. else if(leftright == KEY_RIGHT) {
  146. if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT) {
  147. GetPlayerFacingAngle(playerid, angle);
  148. SetPlayerFacingAngle(playerid, angle-10);
  149. SetCameraBehindPlayer(playerid);
  150. }
  151. else if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) {
  152. new playercar = GetPlayerVehicleID(playerid);
  153. GetVehicleZAngle(playercar, angle);
  154. SetVehicleZAngle(playercar, angle-10);
  155. }
  156. }
  157. if(keys == KEY_JUMP) {
  158. if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT) {
  159. GetPlayerPos(playerid, x, y, z);
  160. SetPlayerPos(playerid, x, y, z+5);
  161. SetCameraBehindPlayer(playerid);
  162. }
  163. else if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) {
  164. new playercar = GetPlayerVehicleID(playerid);
  165. GetVehiclePos(playercar, x, y, z);
  166. SetVehiclePos(playercar, x, y, z+5);
  167. }
  168. }
  169. else if(keys == KEY_SPRINT) {
  170. if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT) {
  171. GetPlayerPos(playerid, x, y, z);
  172. SetPlayerPos(playerid, x, y, z-5);
  173. SetCameraBehindPlayer(playerid);
  174. }
  175. else if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) {
  176. new playercar = GetPlayerVehicleID(playerid);
  177. GetVehiclePos(playercar, x, y, z);
  178. SetVehiclePos(playercar, x, y, z-5);
  179. }
  180. }
  181. }
  182. }
  183. }
  184. }
RAW Paste Data