Advertisement
Guest User

Untitled

a guest
Feb 16th, 2010
408
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.52 KB | None | 0 0
  1. /*
  2. *------------------------------------------------------------------------------*
  3. | |
  4. | Engine System by Razvann |
  5. | www.sa-mp.ro |
  6. | |
  7. *------------------------------------------------------------------------------*
  8. */
  9. #include <a_samp>
  10. //------------------------------------------------------------------------------
  11. new Engine[MAX_PLAYERS];
  12. //------------------------------------------------------------------------------
  13. #define COLOR_LIGHTRED 0xFF6347AA
  14. #define COLOR_PURPLE 0xC2A2DAAA
  15. //------------------------------------------------------------------------------
  16. forward OnPlayerKeyStateChange(playerid, newkeys, oldkeys);
  17. forward ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5);
  18. forward OnPlayerStateChange(playerid, newstate, oldstate);
  19. //------------------------------------------------------------------------------
  20. public OnFilterScriptInit()
  21. {
  22. print(" Engine System Loaded");
  23. print("_____________________");
  24. print(" By: Razvann");
  25. return 1;
  26. }
  27. //------------------------------------------------------------------------------
  28. public OnFilterScriptExit()
  29. {
  30. print(" Engine System Unloaded");
  31. print("_____________________");
  32. print(" By: Razvann");
  33. return 1;
  34. }
  35. //------------------------------------------------------------------------------
  36. public ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5)
  37. {
  38. if(IsPlayerConnected(playerid))
  39. {
  40. new Float:posx, Float:posy, Float:posz;
  41. new Float:oldposx, Float:oldposy, Float:oldposz;
  42. new Float:tempposx, Float:tempposy, Float:tempposz;
  43. GetPlayerPos(playerid, oldposx, oldposy, oldposz);
  44. //radi = 2.0; //Trigger Radius
  45. for(new i = 0; i < MAX_PLAYERS; i++)
  46. {
  47. if(IsPlayerConnected(i))
  48. {
  49. GetPlayerPos(i, posx, posy, posz);
  50. tempposx = (oldposx -posx);
  51. tempposy = (oldposy -posy);
  52. tempposz = (oldposz -posz);
  53. //printf("DEBUG: X:%f Y:%f Z:%f",posx,posy,posz);
  54. if (((tempposx < radi/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16)))
  55. {
  56. SendClientMessage(i, col1, string);
  57. }
  58. else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8)))
  59. {
  60. SendClientMessage(i, col2, string);
  61. }
  62. else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4)))
  63. {
  64. SendClientMessage(i, col3, string);
  65. }
  66. else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2)))
  67. {
  68. SendClientMessage(i, col4, string);
  69. }
  70. else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
  71. {
  72. SendClientMessage(i, col5, string);
  73. }
  74. }
  75. else
  76. {
  77. SendClientMessage(i, col1, string);
  78. }
  79. }
  80. }
  81. return 1;
  82. }
  83. //------------------------------------------------------------------------------
  84. public OnPlayerConnect(playerid)
  85. {
  86. Engine[playerid] = 0;
  87. }
  88. //------------------------------------------------------------------------------
  89. public OnPlayerStateChange(playerid, newstate, oldstate)
  90. {
  91. if(IsPlayerInAnyVehicle(playerid))
  92. {
  93. if(newstate == PLAYER_STATE_DRIVER)
  94. {
  95. TogglePlayerControllable(playerid, 0);
  96. SendClientMessage(playerid, COLOR_LIGHTRED, "The engine isn't started, use the SHIFT/SPACE key to start it!");
  97. }
  98. }
  99. }
  100. //------------------------------------------------------------------------------
  101. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  102. {
  103. if (newkeys==KEY_FIRE)
  104. {
  105. if(IsPlayerInAnyVehicle(playerid))
  106. {
  107. if(Engine[playerid] == 0)
  108. {
  109. new string[128];
  110. Engine[playerid] = 1;
  111. new sendername[MAX_PLAYER_NAME];
  112. GetPlayerName(playerid, sendername,sizeof(sendername));
  113. TogglePlayerControllable(playerid, 1);
  114. SendClientMessage(playerid, COLOR_LIGHTRED, "Starting engine...");
  115. format(string, sizeof(string), "* %s attempts to start his engine.", sendername);
  116. ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  117. }
  118. else
  119. {
  120. new sendername[MAX_PLAYER_NAME];
  121. GetPlayerName(playerid, sendername,sizeof(sendername));
  122. new string[128];
  123. Engine[playerid] = 0;
  124. TogglePlayerControllable(playerid, 0);
  125. format(string, sizeof(string), "* %s has stopped his engine.", sendername);
  126. ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  127. }
  128. }
  129. }
  130. }
  131. /*
  132. *------------------------------------------------------------------------------*
  133. | |
  134. | Engine System by Razvann |
  135. | www.sa-mp.ro |
  136. | |
  137. *------------------------------------------------------------------------------*
  138. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement