Advertisement
Guest User

digging script

a guest
Apr 9th, 2020
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.88 KB | None | 0 0
  1. CraftTimer = {};
  2.  
  3. function init_CraftTimer()
  4.  
  5. --    local textureid = CreateTexture(2900, 200, 6000, 8000, "BAR_BACK.TGA");
  6.     for i = 0, GetMaxPlayers() - 1 do
  7.         CraftTimer[i] = {};
  8.         CraftTimer[i].DigOre = 0;
  9.     end
  10. end
  11.  
  12.  
  13.  
  14. function getCraftTimer(playerid, id)
  15.     if id == 0 then
  16.     return CraftTimer[playerid].DigOre;
  17.     end
  18. end
  19.  
  20. function setCraftTimer(playerid, id, value)
  21.     if id == 0 then
  22.     CraftTimer[playerid].DigOre = value;
  23.     end
  24. end
  25. function resetCraftTimer(playerid)
  26.     CraftTimer[playerid].DigOre = 0;
  27.    
  28. end
  29.  
  30. function StartDigging(playerid)
  31. local ani = GetPlayerAnimationID(playerid);
  32. if getCraftTimer(playerid, 0) == 0 then
  33. if ani == 305 then
  34. setCraftTimer(playerid,0,1);
  35. FreezePlayer(playerid, 1);
  36. GameTextForPlayer(playerid, 2600, 3000, "Started Digging.", "Font_Old_20_White_Hi.TGA", 20, 20, 200, 1500);  
  37.  
  38.  SetTimerEx("StartDigging2",4000,0,playerid);
  39. else
  40. GameTextForPlayer(playerid, 2600, 3000, "You're not digging.", "Font_Old_20_White_Hi.TGA", 200, 20, 20, 1500);  
  41. end
  42. else
  43. GameTextForPlayer(playerid, 2600, 3000, "You're already digging!", "Font_Old_20_White_Hi.TGA", 200, 20, 20, 1500);  
  44. end
  45. end
  46. function StartDigging2(playerid)
  47. local ani = GetPlayerAnimationID(playerid);
  48. if getCraftTimer(playerid, 0) == 1 then
  49. if ani == 305 then
  50. setCraftTimer(playerid,0,2);
  51. FreezePlayer(playerid, 1);
  52. GameTextForPlayer(playerid, 2600, 3000, "Digging 20% done", "Font_Old_20_White_Hi.TGA", 20, 20, 200, 1500);  
  53.  
  54.  SetTimerEx("StartDigging3",4000,0,playerid);
  55.  else
  56. GameTextForPlayer(playerid, 2600, 3000, "You stopped digging.", "Font_Old_20_White_Hi.TGA", 200, 20, 20, 1500);  
  57. setCraftTimer(playerid,0,0);
  58. FreezePlayer(playerid, 0);
  59. end
  60. end
  61. end
  62. function StartDigging3(playerid)
  63. local ani = GetPlayerAnimationID(playerid);
  64. if getCraftTimer(playerid, 0) == 2 then
  65. if ani == 305 then
  66. setCraftTimer(playerid,0,3);
  67. FreezePlayer(playerid, 1);
  68. GameTextForPlayer(playerid, 2600, 3000, "Digging 40% done", "Font_Old_20_White_Hi.TGA", 20, 20, 200, 1500);  
  69.  
  70.  SetTimerEx("StartDigging4",4000,0,playerid);
  71.  else
  72. GameTextForPlayer(playerid, 2600, 3000, "You stopped digging.", "Font_Old_20_White_Hi.TGA", 200, 20, 20, 1500);  
  73. setCraftTimer(playerid,0,0);
  74. FreezePlayer(playerid, 0);
  75.  
  76. end
  77. end
  78. end
  79. function StartDigging4(playerid)
  80. local ani = GetPlayerAnimationID(playerid);
  81. if getCraftTimer(playerid, 0) == 3 then
  82. if ani == 305 then
  83. setCraftTimer(playerid,0,4);
  84. FreezePlayer(playerid, 1);
  85. GameTextForPlayer(playerid, 2600, 3000, "Digging 60% done", "Font_Old_20_White_Hi.TGA", 20, 20, 200, 1500);  
  86.  
  87.  SetTimerEx("StartDigging5",4000,0,playerid);
  88.  else
  89. GameTextForPlayer(playerid, 2600, 3000, "You stopped digging.", "Font_Old_20_White_Hi.TGA", 200, 20, 20, 1500);  
  90. setCraftTimer(playerid,0,0);
  91. FreezePlayer(playerid, 0);
  92. end
  93. end
  94. end
  95. function StartDigging5(playerid)
  96. local ani = GetPlayerAnimationID(playerid);
  97. if getCraftTimer(playerid, 0) == 4 then
  98. if ani == 305 then
  99. setCraftTimer(playerid,0,5);
  100. FreezePlayer(playerid, 1);
  101. GameTextForPlayer(playerid, 2600, 3000, "Digging 80% done", "Font_Old_20_White_Hi.TGA", 20, 20, 200, 1500);  
  102.  
  103.  SetTimerEx("FinishDigging",4000,0,playerid);
  104.  else
  105. GameTextForPlayer(playerid, 2600, 3000, "You stopped digging.", "Font_Old_20_White_Hi.TGA", 200, 20, 20, 1500);  
  106. setCraftTimer(playerid,0,0);
  107. FreezePlayer(playerid, 0);
  108. end
  109. end
  110. end
  111. function FinishDigging(playerid)
  112. local ani = GetPlayerAnimationID(playerid);
  113. if getCraftTimer(playerid, 0) == 5 then
  114. if ani == 305 then
  115. resetCraftTimer(playerid);
  116. FreezePlayer(playerid, 0);
  117. local job = getJob(playerid, 6);
  118. local number0 = random(3);
  119. local amount0 = number0+1;
  120. local number1 = random(8);
  121. local amount1 = number1+1;
  122. local number2 = random(14);
  123. local amount2 = number2+2;
  124. local number3 = random(19);
  125. local amount3 = number3+4;
  126. local number4 = random(28);
  127. local amount4 = number4+6;
  128. local number5 = random(31);
  129. local amount5 = number5+10;
  130. if job <= 50 then
  131. local amountexp = (amount0)*5;
  132. --GameTextForPlayer(playerid, 2600, 3000, "Dug "..amount0.." ore nuggets.", "Font_Old_20_White_Hi.TGA", 20, 20, 200, 1500);  
  133. --GameTextForPlayer(playerid, 2600, 3500, "+"..amount0.." digging experience.", "Font_Old_10_White_Hi.TGA", 150, 150, 200, 1500);
  134. diggerexp = CreateDraw( 2600, 3000, "Dug "..amount0.." ore nuggets.", "Font_Old_20_White_Hi.TGA", 20, 20, 200);
  135. diggerexp2 = CreateDraw( 2600, 3500, "+"..amountexp.." digging experience.", "Font_Old_10_White_Hi.TGA", 150, 150, 200);  
  136. GiveItem(playerid, "itmi_nugget", amount0);
  137. setJob(playerid, 6, job+amountexp);
  138. elseif job <= 300 then
  139. local amountexp = amount1*5;
  140. --GameTextForPlayer(playerid, 2600, 3000, "Dug "..amount1.." ore nuggets.", "Font_Old_20_White_Hi.TGA", 20, 20, 200, 1500);  
  141. --GameTextForPlayer(playerid, 2600, 3500, "+"..amount1.." digging experience.", "Font_Old_10_White_Hi.TGA", 150, 150, 200, 1500);  
  142. diggerexp = CreateDraw( 2600, 3000, "Dug "..amount1.." ore nuggets.", "Font_Old_20_White_Hi.TGA", 20, 20, 200);
  143. diggerexp2 = CreateDraw( 2600, 3500, "+"..amountexp.." digging experience.", "Font_Old_10_White_Hi.TGA", 150, 150, 200);  
  144. GiveItem(playerid, "itmi_nugget", amount1);
  145. setJob(playerid, 6, job+amountexp);
  146. elseif job <= 800 then
  147. local amountexp = amount2*5;
  148. --GameTextForPlayer(playerid, 2600, 3000, "Dug "..amount2.." ore nuggets.", "Font_Old_20_White_Hi.TGA", 20, 20, 200, 1500);
  149. --GameTextForPlayer(playerid, 2600, 3500, "+"..amount2.." digging experience.", "Font_Old_10_White_Hi.TGA", 150, 150, 200, 1500);  
  150. diggerexp = CreateDraw( 2600, 3000, "Dug "..amount2.." ore nuggets.", "Font_Old_20_White_Hi.TGA", 20, 20, 200);
  151. diggerexp2 = CreateDraw( 2600, 3500, "+"..amountexp.." digging experience.", "Font_Old_10_White_Hi.TGA", 150, 150, 200);    
  152. GiveItem(playerid, "itmi_nugget", amount2);
  153. setJob(playerid, 6, job+amountexp);
  154. elseif job <= 2500 then
  155. local amountexp = amount3*5;
  156. --GameTextForPlayer(playerid, 2600, 3000, "Dug "..amount3.." ore nuggets.", "Font_Old_20_White_Hi.TGA", 20, 20, 200, 1500);
  157. --GameTextForPlayer(playerid, 2600, 3500, "+"..amount3.." digging experience.", "Font_Old_10_White_Hi.TGA", 150, 150, 200, 1500);  
  158. diggerexp = CreateDraw( 2600, 3000, "Dug "..amount3.." ore nuggets.", "Font_Old_20_White_Hi.TGA", 20, 20, 200);
  159. diggerexp2 = CreateDraw( 2600, 3500, "+"..amountexp.." digging experience.", "Font_Old_10_White_Hi.TGA", 150, 150, 200);    
  160. GiveItem(playerid, "itmi_nugget", amount3);
  161. setJob(playerid, 6, job+amountexp);
  162. elseif job <= 5000 then
  163. local amountexp = amount4*5;
  164. --GameTextForPlayer(playerid, 2600, 3000, "Dug "..amount4.." ore nuggets.", "Font_Old_20_White_Hi.TGA", 20, 20, 200, 1500);
  165. --GameTextForPlayer(playerid, 2600, 3500, "+"..amount4.." digging experience.", "Font_Old_10_White_Hi.TGA", 150, 150, 200, 1500);  
  166. diggerexp = CreateDraw( 2600, 3000, "Dug "..amount4.." ore nuggets.", "Font_Old_20_White_Hi.TGA", 20, 20, 200);
  167. diggerexp2 = CreateDraw( 2600, 3500, "+"..amountexp.." digging experience.", "Font_Old_10_White_Hi.TGA", 150, 150, 200);  
  168. GiveItem(playerid, "itmi_nugget", amount4);
  169. setJob(playerid, 6, job+amountexp);
  170. else
  171. --GameTextForPlayer(playerid, 2600, 3000, "Dug "..amount5.." ore nuggets.", "Font_Old_20_White_Hi.TGA", 20, 20, 200, 1500);  
  172. diggerexp = CreateDraw( 2600, 3000, "Dug "..amount5.." ore nuggets.", "Font_Old_20_White_Hi.TGA", 20, 20, 200);
  173. diggerexp2 = CreateDraw( 2600, 3500, "Maximum digging level reached.", "Font_Old_10_White_Hi.TGA", 150, 150, 200);
  174.  
  175. GiveItem(playerid, "itmi_nugget", amount5);
  176. --setJob(playerid, 6, job+amount5);
  177. end
  178. ShowDraw(playerid,diggerexp);
  179. ShowDraw(playerid,diggerexp2);
  180. SetTimerEx("FinishDigging2",1500,0,playerid);
  181.  else
  182. GameTextForPlayer(playerid, 2600, 3000, "You stopped digging.", "Font_Old_20_White_Hi.TGA", 200, 20, 20, 1500);  
  183. setCraftTimer(playerid,0,0);
  184. FreezePlayer(playerid, 0);
  185. end
  186. end
  187. end
  188. function FinishDigging2(playerid)
  189. HideDraw(playerid,diggerexp);
  190. DestroyDraw(diggerexp);
  191. HideDraw(playerid,diggerexp2);
  192. DestroyDraw(diggerexp2);
  193. end
  194. --addCommandHandler("/digore", StartDigging);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement