Advertisement
Guest User

Untitled

a guest
May 21st, 2016
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.58 KB | None | 0 0
  1. #include <a_samp>
  2. #include <zcmd>
  3. #include <streamer>
  4.  
  5. #define FILTERSCRIPT
  6.  
  7. #define COLOR_GREEN 0x33AA33AA
  8. #define COLOR_RED 0xAA3333AA
  9. #define MAX_TRASH_CANS 20
  10.  
  11.  
  12. new TrashSkill[MAX_PLAYERS]; //Save this in SQL/yini/dini w/e if u want
  13.  
  14.  
  15. new Float:TRASH_PRICE = 2.0,
  16. MAX_FACTORY_RESOURCES = 10000;
  17.  
  18. new TrashcanObject[MAX_TRASH_CANS],
  19. TrashcanResources[MAX_TRASH_CANS],
  20. Text3D:TrashcanText[MAX_TRASH_CANS],
  21. TrashOnPlayer[MAX_PLAYERS], //Save this in SQL/yini/dini w/e if u want
  22. Text3D:TrashFactoryText,
  23. TrashFactoryResources,
  24. TotalEarnedFromTrash[MAX_PLAYERS], //Save this in SQL/yini/dini w/e if u want
  25. TotalTrashCollected[MAX_PLAYERS]; //Save this in SQL/yini/dini w/e if u want
  26.  
  27.  
  28. forward Float:GetTrashPrice();
  29. forward ChangeTrashPrice();
  30. forward UpdateTrashcans();
  31.  
  32. #if defined FILTERSCRIPT
  33.  
  34. public OnFilterScriptInit()
  35. {
  36. print("\n--------------------------------------");
  37. print(" Trashmaster by Twinki");
  38. print("--------------------------------------\n");
  39.  
  40.  
  41. CreateTrashcan(0,0,1236, 1832.65869, -1878.72766, 13.08714, 0.00000, 0.00000, 0.00000);
  42. CreateTrashcan(0,1,1236, 1808.64380, -1882.34753, 13.22466, 0.00000, 0.00000, 0.00000);
  43. CreateTrashcan(0,2,1236, 1972.82422, -1782.74658, 13.17289, 0.00000, 0.00000, 0.00000);
  44. CreateTrashcan(0,3,1236, 2045.69812, -1740.98816, 13.15423, 0.00000, 0.00000, 90.00000);
  45. CreateTrashcan(0,4,1236, 2112.68066, -1790.14978, 13.12404, 0.00000, 0.00000, 0.00000);
  46. CreateTrashcan(0,5,1236, 2232.01758, -1688.12073, 13.63301, 0.00000, 0.00000, 0.00000);
  47. CreateTrashcan(0,6,1236, 1970.78918, -1970.21753, 13.15715, 0.00000, 0.00000, 90.00000);
  48. CreateTrashcan(0,7,1236, 1931.81104, -2096.23999, 13.12531, 0.00000, 0.00000, 0.00000);
  49. CreateTrashcan(0,8,1236, 2284.95874, -2066.20703, 13.14678, 0.00000, 0.00000, 45.00000);
  50. CreateTrashcan(0,9,1236, 2723.42236, -2005.76831, 13.11397, 0.00000, 0.00000, 90.00000);
  51. CreateTrashcan(0,10,1236, 2516.59814, -1774.16284, 13.15267, 0.00000, 0.00000, 0.00000);
  52. CreateTrashcan(0,11,1236, 1421.72192, -1043.13342, 23.37464, 0.00000, 0.00000, 0.00000);
  53. CreateTrashcan(0,12,1236, 1227.62195, -1271.63403, 13.18324, 0.00000, 0.00000, 0.00000);
  54. CreateTrashcan(0,13,1236, 1083.30225, -1384.33569, 13.39849, 0.00000, 0.00000, 90.00000);
  55. CreateTrashcan(0,14,1236, 615.13269, -1522.93030, 14.65041, 0.00000, 0.00000, 0.00000);
  56. CreateTrashcan(0,15,1236, 657.12463, -1766.36340, 13.20883, 0.00000, 0.00000, 77.00000);
  57. CreateTrashcan(0,16,1236, 1072.77515, -1883.04297, 13.12016, 0.00000, 0.00000, 0.00000);
  58. CreateTrashcan(0,17,1236, 1378.96277, -1889.41687, 13.08524, 0.00000, 0.00000, 90.00000);
  59. CreateTrashcan(0,18,1236, 1337.37939, -1760.76477, 13.05930, 0.00000, 0.00000, 90.00000);
  60. CreateTrashcan(0,19,1236, 858.76263, -1359.91516, 13.37865, 0.00000, 0.00000, 0.00000);
  61.  
  62. new string[128];
  63. format(string,sizeof(string),"{FFFFFF}Resources; {2FFF9F}%i/%i{FFFFFF}\nCurrent Price: {2FFF9F}%.2f$",GetFactoryResources(),GetMaxFactoryResources(),GetTrashPrice());
  64. TrashFactoryText = Create3DTextLabel(string,COLOR_GREEN,2194.0925, -1973.0626, 13.3654, 20.0, 0, 0);
  65.  
  66.  
  67. for(new i = 0; i < sizeof(TrashcanObject); i++) {
  68. new rr = randomEx(1,100);
  69. TrashcanResources[i] = rr;
  70. format(string,sizeof(string),"{007BFF}%i{00FF00}/{FFFF00}100",TrashcanResources[i]);
  71. Update3DTextLabelText(TrashcanText[i],COLOR_GREEN,string);
  72. printf("Trashcan %i filled with %i resources",i,TrashcanResources[i]);
  73.  
  74. }
  75.  
  76. SetTimer("UpdateTrashcans",240000,true);
  77. SetTimer("ChangeTrashPrice",300000,true);
  78. return 1;
  79. }
  80.  
  81.  
  82.  
  83. public OnFilterScriptExit()
  84. {
  85. for(new i = 0; i < sizeof(TrashcanObject); i++) {
  86. Delete3DTextLabel(TrashcanText[i]);
  87. DestroyDynamicObject(TrashcanObject[i]);
  88. }
  89. return 1;
  90. }
  91.  
  92. #else
  93.  
  94. main()
  95. {
  96. print("\n----------------------------------");
  97. print(" Blank Gamemode by your name here");
  98. print("----------------------------------\n");
  99. }
  100.  
  101. #endif
  102.  
  103. /* Commands for normal players */
  104. CMD:collecttrash(playerid,params[]) {
  105. if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,COLOR_RED,"You cannot do this while inside vehicle");
  106. new Float:x, Float:y, Float:z;
  107. for(new i = 0; i < sizeof(TrashcanObject); i++) {
  108. GetDynamicObjectPos(TrashcanObject[i],x,y,z);
  109. if(IsPlayerInRangeOfPoint(playerid, 10.0, x,y,z)) {
  110. if(TrashcanResources[i] <= 0) return SendClientMessage(playerid,COLOR_RED,"This trash can is empty");
  111. if(GetPlayerTrash(playerid) >= 200) return SendClientMessage(playerid,COLOR_RED,"You already have too much trash on you");
  112. new string[64];
  113. TotalTrashCollected[playerid] += TrashcanResources[i];
  114. format(string,sizeof(string),"You took %i trash from this can",TrashcanResources[i]);
  115. SendClientMessage(playerid,COLOR_RED,string);
  116. GivePlayerTrash(playerid,TrashcanResources[i]);
  117. UpdateTrashcanResources(i, 0);
  118. UpdatePlayerTrashSkill(playerid);
  119. printf("Player trash skill %i",GetPlayerTrashSkill(playerid));
  120. break;
  121. }
  122. }
  123. return true;
  124. }
  125.  
  126. CMD:selltrash(playerid,params[]) {
  127. if(TrashOnPlayer[playerid] <= 0) return SendClientMessage(playerid,COLOR_RED,"You dont have any trash on you to sell!");
  128. if(!IsPlayerInRangeOfPoint(playerid,10.0,2194.0925, -1973.0626, 13.3654)) return SendClientMessage(playerid,COLOR_RED,"You are not near the dumpyard in LS");
  129. if(GetFactoryResources() >= MAX_FACTORY_RESOURCES) return SendClientMessage(playerid,COLOR_RED,"Factory is already full!");
  130. PayByResources(playerid,TrashOnPlayer[playerid]);
  131. GivePlayerTrash(playerid,-TrashOnPlayer[playerid]);
  132. UpdateResources(TrashOnPlayer[playerid]);
  133. GivePlayerMoney(playerid,-GetTrashTax(playerid));
  134. new string[128];
  135. format(string,sizeof(string),"You have paid %i$ as a state tax",GetTrashTax(playerid));
  136. SendClientMessage(playerid,COLOR_RED,string);
  137. return true;
  138. }
  139.  
  140.  
  141. CMD:mytrash(playerid,params[]) {
  142. new string[128];
  143. format(string,sizeof(string),"{00AAFF}Total Earned: {FFFF00}%i$ {00AAFF}Current Tax: {FFFF00}%i$ {00AAFF}Total Trash: {FFFF00}%i ",TotalEarnedFromTrash[playerid],GetTrashTax(playerid),TotalTrashCollected[playerid]);
  144. SendClientMessage(playerid,COLOR_GREEN,string);
  145. return true;
  146. }
  147.  
  148.  
  149. /* Functions */
  150. GetPlayerTrash(playerid) return TrashOnPlayer[playerid];
  151. GivePlayerTrash(playerid, amount) { TrashOnPlayer[playerid] += amount; }
  152. Float:GetTrashPrice() return TRASH_PRICE;
  153. GetFactoryResources() return TrashFactoryResources;
  154. UpdateFactoryResources(amount) { TrashFactoryResources += amount; }
  155. GetMaxFactoryResources() return MAX_FACTORY_RESOURCES;
  156. UpdatePlayerTrashSkill(playerid) { TrashSkill[playerid] += 1; }
  157. GetPlayerTrashSkill(playerid) return TrashSkill[playerid];
  158.  
  159.  
  160. stock CreateTrashcan(ResourceAmount,UniqueID,ID, Float:X,Float:Y,Float:Z,Float:RX,Float:RY,Float:RZ) {
  161. TrashcanObject[UniqueID] = CreateDynamicObject(ID,X,Y,Z,RX,RY,RZ);
  162. TrashcanText[UniqueID] = Create3DTextLabel("{007BFF}0{00FF00}/{FFFF00}100",0x008080FF,X,Y,Z,20.0,0,0);
  163. TrashcanResources[UniqueID] = ResourceAmount;
  164. }
  165.  
  166. UpdateResources(amount) {
  167. UpdateFactoryResources(amount);
  168. new string[128];
  169. format(string,sizeof(string),"{FFFFFF}Resources; {2FFF9F}%i/%i{FFFFFF}\nCurrent Price: {2FFF9F}%.2f$",GetFactoryResources(),GetMaxFactoryResources(),GetTrashPrice());
  170. Update3DTextLabelText(TrashFactoryText,COLOR_GREEN,string);
  171. }
  172.  
  173. PayByResources(playerid,Float:amount) {
  174. new Float:calc = GetTrashPrice()*amount;
  175. printf("%.2f*%.2f",GetTrashPrice(),amount);
  176. new pp = floatround(calc, floatround_round);
  177. new calc2 = floatround(amount,floatround_round);
  178. GivePlayerMoney(playerid,pp);
  179.  
  180. new string[128];
  181. format(string,sizeof(string),"You have received %i$ for %i trash. Current trash price %.2f$",pp, calc2, GetTrashPrice());
  182. SendClientMessage(playerid,COLOR_GREEN,string);
  183.  
  184. TotalEarnedFromTrash[playerid] += pp;
  185. return true;
  186. }
  187.  
  188. stock UpdateTrashcanResources(tID, ress) {
  189. TrashcanResources[tID] = ress;
  190. new string[64];
  191. format(string,sizeof(string),"{007BFF}%i{00FF00}/{FFFF00}100",TrashcanResources[tID]);
  192. Update3DTextLabelText(TrashcanText[tID],COLOR_GREEN,string);
  193. }
  194.  
  195. stock GetTrashTax(playerid) {
  196. new current_tax_price;
  197. switch(GetPlayerTrashSkill(playerid)) {
  198. case 0 .. 100: current_tax_price = 20;
  199. case 101 .. 250: current_tax_price = 15;
  200. case 251 .. 500: current_tax_price = 10;
  201. case 501 .. 1000: current_tax_price = 5;
  202. case 1001 .. 9999: current_tax_price = 0;
  203. }
  204. return current_tax_price;
  205. }
  206.  
  207. stock randomEx(minnum = cellmin, maxnum = cellmax) return random(maxnum - minnum + 1) + minnum; //Y_Less
  208. stock Float:frandomEx(Float:min, Float:max) return min + (max - min) * random(32768) / 32768.0; // Y_Less
  209.  
  210.  
  211. /* Timers */
  212. public UpdateTrashcans() {
  213. new rrX = randomEx(1,10);
  214. for(new i = 0; i < sizeof(TrashcanObject); i++) {
  215. if(TrashcanResources[i] <= 95) {
  216. TrashcanResources[i] += rrX;
  217. new string[128];
  218. format(string,sizeof(string),"{007BFF}%i{00FF00}/{FFFF00}100",TrashcanResources[i]);
  219. Update3DTextLabelText(TrashcanText[i],COLOR_GREEN,string);
  220. printf("Trash can ID: %i now has %i resources",i,TrashcanResources[i]);
  221.  
  222. if(TrashcanResources[i] >= 101) {
  223. TrashcanResources[i] = 100;
  224. }
  225. }
  226. }
  227. return true;
  228. }
  229.  
  230.  
  231.  
  232. public ChangeTrashPrice() {
  233. new Float:rr = frandomEx(1,5), string[128];
  234. TRASH_PRICE = rr;
  235. format(string,sizeof(string),"{FFFFFF}Resources; {2FFF9F}%i/%i{FFFFFF}\nCurrent Price: {2FFF9F}%.2f$",GetFactoryResources(),GetMaxFactoryResources(),GetTrashPrice());
  236. Update3DTextLabelText(TrashFactoryText,COLOR_GREEN,string);
  237. return true;
  238. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement