Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.82 KB | None | 0 0
  1. //=================================================================
  2. // Forwards
  3. forward WeedTimer();
  4.  
  5.  
  6. //Global Variables
  7. new Weed[MAX_PLAYERS];
  8. new Float: Weed_x[MAX_PLAYERS], Float: Weed_y[MAX_PLAYERS], Float: Weed_z[MAX_PLAYERS];
  9. new HasPlantWeed[MAX_PLAYERS];
  10. new WeedGrams[MAX_PLAYERS];
  11. new WeedForPlayer[MAX_PLAYERS];
  12. new WeedTime[MAX_PLAYERS];
  13. new WeedMin[MAX_PLAYERS];
  14. new WeedIsPicked[MAX_PLAYERS];
  15. new Float:WeedStopPos[MAX_PLAYERS][3];
  16.  
  17. // OnGameModeInit
  18. SetTimer("WeedTimer", 1000, 1);
  19.  
  20.  
  21. //Custom Function
  22. public WeedTimer()
  23. {
  24. for(new i = 0; i < MAX_PLAYERS; i++)
  25. {
  26. if(HasPlantWeed[i] != 0)
  27. {
  28. WeedTime[i] ++;
  29. if(WeedTime[i] == 60)
  30. {
  31. WeedGrams[i] ++;
  32. WeedTime[i] = 0;
  33. WeedMin[i] ++;
  34. }
  35. if(WeedMin[i] == 70)
  36. {
  37. DestroyObject(Weed[i]);
  38. HasPlantWeed[i] = 0;
  39. WeedGrams[i] = 0;
  40. WeedTime[i] = 0;
  41. }
  42. }
  43. }
  44. return 1;
  45. }
  46. // at the pinfo enum:
  47. pSeeds
  48.  
  49. // at OnPlayerConnectFunction
  50. WeedIsPicked[playerid] = 0;
  51. WeedTime[playerid] = 0;
  52. WeedMin[playerid] = 0;
  53. WeedTime[playerid] = 0;
  54. WeedGrams[playerid] = 0;
  55. WeedForPlayer[playerid] = 999;
  56. WeedIsPicked[playerid] = 0;
  57. HasPlantWeed[playerid] = 0;
  58. PlayerInfo[playerid][pSeeds] = 0;
  59.  
  60. // OnPlayerDisconnect
  61. if(HasPlantWeed[playerid] != 0) DestroyObject(Weed[playerid]);
  62.  
  63. // Make it savable (OnPlayerRegister, OnPlayerLogin and your custom save function SavePlayer or whatever you use)
  64.  
  65. // Also change the /getcrate /getpot (to /getseeds) and the other cmds in order to replace pot with seeds
  66.  
  67.  
  68. // The commands
  69.  
  70. if(strcmp(cmd,"/plantweed",true)==0)
  71. {
  72. if(IsPlayerConnected(playerid))
  73. {
  74. if (PlayerInfo[playerid][pJob] != 4)
  75. {
  76. SendClientMessage(playerid,COLOR_GREY, "You are not a Drug Dealer !");
  77. return 1;
  78. }
  79. new name[MAX_PLAYER_NAME];
  80. GetPlayerName(playerid, name, sizeof(name));
  81. if(GetPlayerState(playerid) != 1) return SendClientMessage(playerid, COLOR_GREY, " You must be on foot !");
  82. if(GetPlayerInterior(playerid) > 0) return SendClientMessage(playerid, COLOR_GREY, " You must be outside to plant your seeds.");
  83. if(PlayerInfo[playerid][pSeeds] == 0) return SendClientMessage(playerid, COLOR_GREY, " You don't have any Seeds!");
  84. if(PlayerInfo[playerid][pSeeds] < 10) return SendClientMessage(playerid, COLOR_GREY, " You don't have enough Seeds!");
  85. if(HasPlantWeed[playerid] == 1) return SendClientMessage(playerid, COLOR_GRAD2, "* You have already planted a weed !");
  86. new Float:X, Float:Y, Float:Z;
  87. ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0);
  88. GetPlayerPos(playerid, X, Y, Z);
  89. Weed_x[playerid] = X;
  90. Weed_y[playerid] = Y;
  91. Weed_z[playerid] = Z;
  92. Weed[playerid] = CreateObject(3409, X, Y, Z-1.8, 0, 0, 0);
  93. HasPlantWeed[playerid] = 1;
  94. PlayerInfo[playerid][pSeeds] -= 10;
  95. format(string, sizeof(string), "* %s plants some seeds.", name);
  96. ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  97. SendClientMessage(playerid, COLOR_GREEN, "You have planted your seeds! Every minute, your plant will make one gram of weed.");
  98. SendClientMessage(playerid, COLOR_GREEN, "If your plant won't picked within 70 minutes, it will rot and you will lose it.");
  99. SendClientMessage(playerid, COLOR_GREEN, "Also remember that anyone can /pickweed if they find your plant, so be careful.");
  100. }
  101. return 1;
  102. }
  103. //==============================================================================
  104. if(strcmp(cmd,"/checkweed",true)==0)
  105. {
  106. if(IsPlayerConnected(playerid))
  107. {
  108. new count = 0;
  109. if(GetPlayerState(playerid) != 1) return SendClientMessage(playerid, COLOR_GREY, " You must be on foot !");
  110. new name[MAX_PLAYER_NAME];
  111. GetPlayerName(playerid, name, sizeof(name));
  112. for(new i = 0; i < MAX_PLAYERS; i++)
  113. {
  114. if(IsPlayerInRangeOfPoint(playerid, 3.0, Weed_x[i], Weed_y[i], Weed_z[i]))
  115. {
  116. WeedForPlayer[playerid] = i;
  117. ApplyAnimation(playerid, "BOMBER", "BOM_Plant_2Idle", 4.0, 0, 0, 0, 0, 0);
  118. format(string, sizeof(string), "* %s inspects the weed plant.", name);
  119. ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  120. format(string, sizeof(string), "This plant has %d weed grams.", WeedGrams[i]);
  121. SendClientMessage(playerid, COLOR_GREEN, string);
  122. WeedForPlayer[playerid] = 999;
  123. count ++;
  124. return 1;
  125. }
  126. }
  127. if(count == 0) SendClientMessage(playerid, COLOR_GREY, " You are not near any plants !");
  128. }
  129. return 1;
  130. }
  131. //==============================================================================
  132. if(strcmp(cmd,"/pickweed",true)==0)
  133. {
  134. if(IsPlayerConnected(playerid))
  135. {
  136. new count = 0;
  137. new Error = 0;
  138. new name[MAX_PLAYER_NAME];
  139. GetPlayerName(playerid, name, sizeof(name));
  140. if(GetPlayerState(playerid) != 1) return SendClientMessage(playerid, COLOR_GREY, " You must be on foot !");
  141. if(WeedIsPicked[playerid] > 0) return SendClientMessage(playerid, COLOR_GREY, " You have already started to picking a weed !");
  142. if(GetPlayerSpecialAction(playerid) != SPECIAL_ACTION_DUCK) return SendClientMessage(playerid, COLOR_GREY, " You must be crouched to pick weed.");
  143. for(new i = 0; i < MAX_PLAYERS; i++)
  144. {
  145. if(IsPlayerInRangeOfPoint(playerid, 3.0, Weed_x[i], Weed_y[i], Weed_z[i]))
  146. {
  147. WeedForPlayer[playerid] = i;
  148. if(WeedGrams[i] < 1) { SendClientMessage(playerid, COLOR_GREY, " This plant is not ready to be picked, please wait at least 2 minutes for it to grow."); Error = 1; }
  149. if(Error == 0)
  150. {
  151. format(string, sizeof(string), "* %s begins picking a weed plant.", name);
  152. ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  153. GetPlayerPos(playerid, WeedStopPos[playerid][0], WeedStopPos[playerid][1], WeedStopPos[playerid][2]);
  154. WeedIsPicked[playerid] = 1;
  155. SetTimerEx("WeedPickup", 5000, false, "i", playerid);
  156. }
  157. count ++;
  158. return 1;
  159. }
  160. }
  161. if(count == 0) SendClientMessage(playerid, COLOR_GREY, " You are not near any plants !");
  162. }
  163. return 1;
  164. }
  165.  
  166. // Custom Function
  167. forward WeedPickup(playerid);
  168. public WeedPickup(playerid)
  169. {
  170. new string[256];
  171. new Float: X, Float: Y, Float: Z;
  172. GetPlayerPos(playerid, X, Y, Z);
  173. new name[MAX_PLAYER_NAME];
  174. GetPlayerName(playerid, name, sizeof(name));
  175. if(X == WeedStopPos[playerid][0] && Y == WeedStopPos[playerid][1] && Z == WeedStopPos[playerid][2])
  176. {
  177. if(GetPlayerSpecialAction(playerid) != SPECIAL_ACTION_DUCK) return SendClientMessage(playerid, COLOR_GREY, " You must be crouched to pick weed.");
  178. format(string, sizeof(string), "* %s picks a weed plant.", name);
  179. ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  180. PlayerInfo[playerid][pPot] += WeedGrams[WeedForPlayer[playerid]];
  181. format(string, sizeof(string), "~w~FOUND %d GRAMS OF POT", WeedGrams[WeedForPlayer[playerid]]);
  182. GameTextForPlayer(playerid, string, 3000, 3);
  183. DestroyObject(Weed[WeedForPlayer[playerid]]);
  184. WeedGrams[WeedForPlayer[playerid]] = 0;
  185. WeedTime[WeedForPlayer[playerid]] = 0;
  186. }
  187. else
  188. {
  189. SendClientMessage(playerid, COLOR_GREEN, " You have moved from your weed picking position, picking failed!");
  190. }
  191. HasPlantWeed[WeedForPlayer[playerid]] = 0;
  192. WeedForPlayer[playerid] = 999;
  193. WeedIsPicked[playerid] = 0;
  194. return 1;
  195. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement