Advertisement
Guest User

Roadblock System

a guest
Jul 30th, 2016
578
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.12 KB | None | 0 0
  1. #include <a_samp>
  2. #include <zcmd>
  3. #include <color>
  4. #include <streamer>
  5.  
  6. #define MAX_ROADBLOCKS 25
  7. enum rInfo
  8. {
  9. sCreated,
  10. Float:sX,
  11. Float:sY,
  12. Float:sZ,
  13. sObject,
  14. copid,
  15. Text3D:rbLabel
  16. };
  17.  
  18. new Roadblocks[MAX_ROADBLOCKS][rInfo];
  19. COMMAND:rarb(playerid, params[])
  20. {
  21. if(IsPlayerAdmin(playerid))
  22. {
  23. for(new i = 0; i < sizeof(Roadblocks); i++)
  24. {
  25. Roadblocks[i][sCreated] = 0;
  26. Roadblocks[i][sX] = 0.0;
  27. Roadblocks[i][sY] = 0.0;
  28. Roadblocks[i][sZ] = 0.0;
  29. DestroyDynamicObject(Roadblocks[i][sObject]);
  30. Delete3DTextLabel(Roadblocks[i][rbLabel]);
  31. }
  32. SendClientMessageToAll(-1, "{FFFFFF}An administrator has removed all road blocks.");
  33. }
  34. return 1;
  35. }
  36. COMMAND:placerb(playerid, params[])
  37. {
  38. if(IsPlayerAdmin(playerid))
  39. {
  40. if (GetPlayerInterior(playerid) > 0)
  41. {
  42. new Float:plocx, Float:plocy, Float:plocz, Float:ploca;
  43. GetPlayerPos(playerid, plocx, plocy, plocz);
  44. GetPlayerFacingAngle(playerid, ploca);
  45.  
  46. CreateRoadblock(978, plocx, plocy, plocz + 0.6, ploca, playerid);
  47. }
  48. else
  49. {
  50. Server(playerid, "Road blocks can only be placed out doors.");
  51. }
  52. }
  53. else
  54. {
  55. Server(playerid, "This command can only be used by admin");
  56. }
  57. return 1;
  58. }
  59.  
  60. COMMAND:delrb(playerid, params[])
  61. {
  62. if(IsPlayerAdmin(playerid))
  63. {
  64. DeleteClosestRoadblock(playerid);
  65. }
  66. else
  67. {
  68. Server(playerid, "This command can only be used by admin");
  69. }
  70. return 1;
  71. }
  72.  
  73. stock CreateRoadblock(Object,Float:x,Float:y,Float:z,Float:Angle, playerid)
  74. {
  75. new count = 0;
  76. for(new i = 0; i < sizeof(Roadblocks); i++)
  77. {
  78. if(Roadblocks[i][sCreated] == 0)
  79. {
  80. new creatorString[200];
  81. new name[MAX_PLAYER_NAME];
  82. GetPlayerName(playerid, name, sizeof(name));
  83. Roadblocks[i][sCreated] = 1;
  84. Roadblocks[i][sX] = x;
  85. Roadblocks[i][sY] = y;
  86. Roadblocks[i][sZ] = z - 0.7;
  87. Roadblocks[i][copid] = playerid;
  88. Roadblocks[i][sObject] = CreateDynamicObject(Object, x, y, z - 0.9, 0, 0, Angle);
  89.  
  90. format(creatorString, sizeof(creatorString), CHAT_RED"[ROADBLOCK]"CHAT_WHITE"Placed By: "CHAT_RED"%s", name);
  91. Roadblocks[i][rbLabel] = Create3DTextLabel(creatorString, 0xFF0000FF, x, y, z, 25.0, 0);
  92.  
  93. Server(playerid, "You placed a roadblock. To remove it, type "CHAT_YELLOW"/delrb"CHAT_WHITE" while standing near it.");
  94.  
  95. count++;
  96. return 1;
  97. }
  98. }
  99.  
  100. if (!count)
  101. {
  102. Server(playerid, "Maximum number of roadblocks created. ask an admin to remove some.");
  103. }
  104.  
  105. return 0;
  106. }
  107.  
  108. stock DeleteAllRoadblocks(playerid)
  109. {
  110. for(new i = 0; i < sizeof(Roadblocks); i++)
  111. {
  112. if(IsPlayerInRangeOfPoint(playerid, 100, Roadblocks[i][sX], Roadblocks[i][sY], Roadblocks[i][sZ]))
  113. {
  114. if(Roadblocks[i][sCreated] == 1)
  115. {
  116. Roadblocks[i][sCreated] = 0;
  117. Roadblocks[i][sX] = 0.0;
  118. Roadblocks[i][sY] = 0.0;
  119. Roadblocks[i][sZ] = 0.0;
  120. DestroyDynamicObject(Roadblocks[i][sObject]);
  121. Delete3DTextLabel(Roadblocks[i][rbLabel]);
  122. }
  123. }
  124. }
  125. return 0;
  126. }
  127.  
  128. stock DeleteClosestRoadblock(playerid)
  129. {
  130. for(new i = 0; i < sizeof(Roadblocks); i++)
  131. {
  132. if(IsPlayerInRangeOfPoint(playerid, 5.0, Roadblocks[i][sX], Roadblocks[i][sY], Roadblocks[i][sZ]))
  133. {
  134. if(Roadblocks[i][sCreated] == 1)
  135. {
  136. Roadblocks[i][sCreated] = 0;
  137. Roadblocks[i][sX] = 0.0;
  138. Roadblocks[i][sY] = 0.0;
  139. Roadblocks[i][sZ] = 0.0;
  140. DestroyDynamicObject(Roadblocks[i][sObject]);
  141. Delete3DTextLabel(Roadblocks[i][rbLabel]);
  142.  
  143. Server(playerid, "Succesfully removed a roadblock.");
  144.  
  145. return 1;
  146. }
  147. }
  148. }
  149.  
  150. return 0;
  151. }
  152.  
  153. stock removePlayerRoadblocks(playerid)
  154. {
  155. for(new i = 0; i < sizeof(Roadblocks); i++)
  156. {
  157. if(Roadblocks[i][copid] == playerid)
  158. {
  159. Roadblocks[i][sCreated] = 0;
  160. Roadblocks[i][sX] = 0.0;
  161. Roadblocks[i][sY] = 0.0;
  162. Roadblocks[i][sZ] = 0.0;
  163. DestroyDynamicObject(Roadblocks[i][sObject]);
  164. Delete3DTextLabel(Roadblocks[i][rbLabel]);
  165.  
  166. return 1;
  167. }
  168. else
  169. {
  170. continue;
  171. }
  172. }
  173. return 0;
  174. }
  175. stock Server(playerid, message[])
  176. {
  177. new smg[144];
  178. format(smg, sizeof(smg), ""COLOR_LAWNGREEN"[SERVER]"COLOR_WHITE" %s", message);
  179. SendClientMessage(playerid, -1, smg);
  180. return 1;
  181. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement