Guest User

Untitled

a guest
Aug 13th, 2013
406
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.39 KB | None | 0 0
  1. #include <a_samp>
  2. #include <ZCMD>
  3. #include <sscanf2>
  4. #include <streamer>
  5.  
  6. #define COLOR_LIGHTRED 0xFF6347AA
  7. #define COLOR_ORANGE 0xFF8000FF
  8. #define COLOR_LIGHTBLUE 0x33CCFFAA
  9. #define COLOR_WHITE 0xFFFFFFAA
  10. #define COLOR_GRAD1 0xB4B5B7FF
  11. #define COLOR_GREY 0xAFAFAFAA
  12. #define COLOR_PURPLE 0xC2A2DAAA
  13.  
  14. #define CRATEGUN 1
  15.  
  16. new dynamiccrate;
  17. new Text3D:dynamiccrate3DText;
  18.  
  19. public OnGameModeExit()
  20. {
  21. print("Crate System Shutting Down.");
  22. print("Spawned crates removed.");
  23. DestroyDynamicObject(dynamiccrate);
  24. dynamiccrate = 0;
  25. DestroyDynamic3DTextLabel( Text3D:dynamiccrate3DText );
  26. return 1;
  27. }
  28. forward ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5);
  29. public ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5)
  30. {
  31. if(IsPlayerConnected(playerid))
  32. {
  33. new Float:posx, Float:posy, Float:posz;
  34. new Float:oldposx, Float:oldposy, Float:oldposz;
  35. new Float:tempposx, Float:tempposy, Float:tempposz;
  36. GetPlayerPos(playerid, oldposx, oldposy, oldposz);
  37. for(new i = 0; i < MAX_PLAYERS; i++)
  38. {
  39. if(IsPlayerConnected(i))
  40. {
  41. GetPlayerPos(i, posx, posy, posz);
  42. tempposx = (oldposx -posx);
  43. tempposy = (oldposy -posy);
  44. tempposz = (oldposz -posz);
  45. if(GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(i))
  46. {
  47. if (((tempposx < radi/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16)))
  48. {
  49. SendClientMessage(i, col1, string);
  50. }
  51. else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8)))
  52. {
  53. SendClientMessage(i, col2, string);
  54. }
  55. else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4)))
  56. {
  57. SendClientMessage(i, col3, string);
  58. }
  59. else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2)))
  60. {
  61. SendClientMessage(i, col4, string);
  62. }
  63. else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
  64. {
  65. SendClientMessage(i, col5, string);
  66. }
  67. }
  68. }
  69. }
  70. }
  71. }
  72.  
  73. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  74. {
  75. if(dialogid == CRATEGUN)
  76. {
  77. if(response) // If they clicked 'Yes' or pressed enter
  78. {
  79. if(listitem == 0) // Shotgun
  80. {
  81. GivePlayerWeapon(playerid, 25, 99999);
  82. SendClientMessage(playerid, COLOR_LIGHTBLUE," You have taken a Shotgun!");
  83. }
  84. if(listitem == 1) // MP5
  85. {
  86. GivePlayerWeapon(playerid, 29, 99999);
  87. SendClientMessage(playerid, COLOR_LIGHTBLUE," You have taken a MP5!");
  88. }
  89. if(listitem == 2) // Rifle
  90. {
  91. GivePlayerWeapon(playerid, 33, 99999);
  92. SendClientMessage(playerid, COLOR_LIGHTBLUE," You have taken a Rifle!");
  93. }
  94. if(listitem == 3) // Desert Eagle
  95. {
  96. GivePlayerWeapon(playerid, 24, 99999);
  97. SendClientMessage(playerid, COLOR_LIGHTBLUE," You have taken a Desert Eagle!");
  98. }
  99. if(listitem == 4) // AK-47
  100. {
  101. GivePlayerWeapon(playerid, 30, 99999);
  102. SendClientMessage(playerid, COLOR_LIGHTBLUE," You have taken an AK-47!");
  103. }
  104. if(listitem == 5) // M4
  105. {
  106. GivePlayerWeapon(playerid, 31, 99999);
  107. SendClientMessage(playerid, COLOR_LIGHTBLUE," You have taken an M4!");
  108. }
  109. if(listitem == 6) // SPAS-12
  110. {
  111. GivePlayerWeapon(playerid, 27, 99999);
  112. SendClientMessage(playerid, COLOR_LIGHTBLUE," You have taken a SPAS-12!");
  113. }
  114. if(listitem == 7) // Sniper
  115. {
  116. GivePlayerWeapon(playerid, 34, 99999);
  117. SendClientMessage(playerid, COLOR_LIGHTBLUE," You have taken a Sniper!");
  118. }
  119. if(listitem == 8) // Kevlar vest
  120. {
  121. SetPlayerArmour(playerid, 100.0);
  122. SendClientMessage(playerid, COLOR_LIGHTBLUE," You have taken a Kevlar vest!");
  123. }
  124. if(listitem == 9)
  125. {
  126. SetPlayerHealth(playerid, 100);
  127. }
  128. }
  129. return 1; // We handled a dialog, so return 1. Just like OnPlayerCommandText.
  130. }
  131.  
  132. return 0; // You MUST return 0 here! Just like OnPlayerCommandText.
  133. }
  134.  
  135. CMD:opencrate(playerid, params[])
  136. {
  137. if(dynamiccrate != 0)
  138. {
  139. new Float:Position[3];
  140. GetDynamicObjectPos(dynamiccrate, Position[0], Position[1], Position[2]);
  141.  
  142. if(IsPlayerInRangeOfPoint(playerid, 5.0, Position[0], Position[1], Position[2]))
  143. {
  144. ShowPlayerDialog(playerid, CRATEGUN, DIALOG_STYLE_LIST, "Crate Equipment","Shotgun\nMP5\nRifle\nDesert Eagle\nAK-47\nM4\nSPAS-12\nSniper\nKevlar vest\nFirst Aid Kit", "Take", "Cancel");
  145. }
  146. else
  147. {
  148. SendClientMessage(playerid, COLOR_WHITE, "* You're not near the crate!");
  149. }
  150. }
  151. return 1;
  152. }
  153.  
  154. CMD:spawncrate(playerid, params[])
  155. {
  156. if (IsPlayerAdmin(playerid))
  157. {
  158. if(IsPlayerInAnyVehicle(playerid))
  159. {
  160. SendClientMessage(playerid, COLOR_GREY, "You must be on foot to use this command.");
  161. return 1;
  162. }
  163.  
  164. new Float:Position[4];
  165. if(dynamiccrate == 0)
  166. {
  167. GetPlayerPos(playerid, Position[0], Position[1], Position[2]);
  168. GetPlayerFacingAngle(playerid, Position[3]);
  169. dynamiccrate = CreateDynamicObject(964, Position[0], Position[1], Position[2]-1.28, 0.0, 0.0, Position[3], -1, -1, -1, 200.0);
  170. dynamiccrate3DText = CreateDynamic3DTextLabel("/opencrate\nTo open the crate.",COLOR_ORANGE,Position[0], Position[1], Position[2]+0.0,8.0);
  171. SetPlayerPos(playerid, Position[0], Position[1], Position[2]+3);
  172. SendClientMessageToAll(COLOR_LIGHTRED, "Crate: The crate has been placed!");
  173. }
  174. else
  175. {
  176. DestroyDynamicObject(dynamiccrate);
  177. dynamiccrate = 0;
  178. DestroyDynamic3DTextLabel( Text3D:dynamiccrate3DText );
  179. SendClientMessageToAll(COLOR_LIGHTRED, "Crate: The crate has been destroyed!");
  180. }
  181. }
  182. return 1;
  183. }
Advertisement
Add Comment
Please, Sign In to add comment