Advertisement
Guest User

Untitled

a guest
May 21st, 2016
1,670
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.48 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,
  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. VehicleTrash[MAX_VEHICLES];
  27.  
  28.  
  29. forward Float:GetTrashPrice();
  30. forward ChangeTrashPrice();
  31. forward UpdateTrashcans();
  32. forward Float:frandomEx(Float:min, Float:max);
  33.  
  34. #if defined FILTERSCRIPT
  35.  
  36. public OnFilterScriptInit()
  37. {
  38. print("\n--------------------------------------");
  39. print(" Trashmaster by Twinki");
  40. print("--------------------------------------\n");
  41.  
  42. TRASH_PRICE = frandomEx(1.0,5.0);
  43.  
  44. CreateTrashcan(0,0,1236, 1832.65869, -1878.72766, 13.08714, 0.00000, 0.00000, 0.00000);
  45. CreateTrashcan(0,1,1236, 1808.64380, -1882.34753, 13.22466, 0.00000, 0.00000, 0.00000);
  46. CreateTrashcan(0,2,1236, 1972.82422, -1782.74658, 13.17289, 0.00000, 0.00000, 0.00000);
  47. CreateTrashcan(0,3,1236, 2045.69812, -1740.98816, 13.15423, 0.00000, 0.00000, 90.00000);
  48. CreateTrashcan(0,4,1236, 2112.68066, -1790.14978, 13.12404, 0.00000, 0.00000, 0.00000);
  49. CreateTrashcan(0,5,1236, 2232.01758, -1688.12073, 13.63301, 0.00000, 0.00000, 0.00000);
  50. CreateTrashcan(0,6,1236, 1970.78918, -1970.21753, 13.15715, 0.00000, 0.00000, 90.00000);
  51. CreateTrashcan(0,7,1236, 1931.81104, -2096.23999, 13.12531, 0.00000, 0.00000, 0.00000);
  52. CreateTrashcan(0,8,1236, 2284.95874, -2066.20703, 13.14678, 0.00000, 0.00000, 45.00000);
  53. CreateTrashcan(0,9,1236, 2723.42236, -2005.76831, 13.11397, 0.00000, 0.00000, 90.00000);
  54. CreateTrashcan(0,10,1236, 2516.59814, -1774.16284, 13.15267, 0.00000, 0.00000, 0.00000);
  55. CreateTrashcan(0,11,1236, 1421.72192, -1043.13342, 23.37464, 0.00000, 0.00000, 0.00000);
  56. CreateTrashcan(0,12,1236, 1227.62195, -1271.63403, 13.18324, 0.00000, 0.00000, 0.00000);
  57. CreateTrashcan(0,13,1236, 1083.30225, -1384.33569, 13.39849, 0.00000, 0.00000, 90.00000);
  58. CreateTrashcan(0,14,1236, 615.13269, -1522.93030, 14.65041, 0.00000, 0.00000, 0.00000);
  59. CreateTrashcan(0,15,1236, 657.12463, -1766.36340, 13.20883, 0.00000, 0.00000, 77.00000);
  60. CreateTrashcan(0,16,1236, 1072.77515, -1883.04297, 13.12016, 0.00000, 0.00000, 0.00000);
  61. CreateTrashcan(0,17,1236, 1378.96277, -1889.41687, 13.08524, 0.00000, 0.00000, 90.00000);
  62. CreateTrashcan(0,18,1236, 1337.37939, -1760.76477, 13.05930, 0.00000, 0.00000, 90.00000);
  63. CreateTrashcan(0,19,1236, 858.76263, -1359.91516, 13.37865, 0.00000, 0.00000, 0.00000);
  64.  
  65. Create3DTextLabel("{FFFF9F}Type {00FF00}/loadtrash {FFFF9F}to load the trashmaster with trash",COLOR_GREEN,2163.0125,-1971.2373,13.5533, 20.0, 0, 0);
  66.  
  67. new string[128];
  68. format(string,sizeof(string),"{FFFFFF}Resources; {2FFF9F}%i/%i{FFFFFF}\nCurrent Price: {2FFF9F}%.2f$",GetFactoryResources(),GetMaxFactoryResources(),GetTrashPrice());
  69. TrashFactoryText = Create3DTextLabel(string,COLOR_GREEN,2194.0925, -1973.0626, 13.3654, 20.0, 0, 0);
  70.  
  71. Create3DTextLabel("{FFFF9F}Type {00FF00}/droptrash {FFFF9F}to unload the trashmaster",COLOR_GREEN,2547.5715,-2221.8047,13.2977,20.0,0,0);
  72.  
  73.  
  74.  
  75. for(new i = 0; i < sizeof(TrashcanObject); i++) {
  76. new rr = randomEx(1,100);
  77. TrashcanResources[i] = rr;
  78. format(string,sizeof(string),"{007BFF}%i{00FF00}/{FFFF00}100",TrashcanResources[i]);
  79. Update3DTextLabelText(TrashcanText[i],COLOR_GREEN,string);
  80. printf("Trashcan %i filled with %i resources",i,TrashcanResources[i]);
  81.  
  82. }
  83.  
  84. AddStaticVehicle(408,2189.6274,-1983.0913,14.0977,82.3771,0,0); // v1
  85. AddStaticVehicle(408,2188.6338,-1987.3062,14.0867,80.9790,0,0); // v2
  86. AddStaticVehicle(408,2189.2195,-1994.7833,14.0882,74.2583,0,0); // v3
  87.  
  88. SetTimer("UpdateTrashcans",240000,true);
  89. SetTimer("ChangeTrashPrice",300000,true);
  90. return 1;
  91. }
  92.  
  93.  
  94.  
  95. public OnFilterScriptExit()
  96. {
  97. for(new i = 0; i < sizeof(TrashcanObject); i++) {
  98. Delete3DTextLabel(TrashcanText[i]);
  99. DestroyDynamicObject(TrashcanObject[i]);
  100. }
  101. Delete3DTextLabel(TrashFactoryText);
  102. return 1;
  103. }
  104.  
  105. #else
  106.  
  107. main()
  108. {
  109. print("\n----------------------------------");
  110. print(" Blank Gamemode by your name here");
  111. print("----------------------------------\n");
  112. }
  113.  
  114. #endif
  115.  
  116. /* Commands for normal players */
  117. CMD:collecttrash(playerid,params[]) {
  118. if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,COLOR_RED,"You cannot do this while inside vehicle");
  119. new Float:x, Float:y, Float:z;
  120. for(new i = 0; i < sizeof(TrashcanObject); i++) {
  121. GetDynamicObjectPos(TrashcanObject[i],x,y,z);
  122. if(IsPlayerInRangeOfPoint(playerid, 10.0, x,y,z)) {
  123. if(TrashcanResources[i] <= 0) return SendClientMessage(playerid,COLOR_RED,"This trash can is empty");
  124. if(GetPlayerTrash(playerid) >= 200) return SendClientMessage(playerid,COLOR_RED,"You already have too much trash on you");
  125. new string[64];
  126. TotalTrashCollected[playerid] += TrashcanResources[i];
  127. format(string,sizeof(string),"You took %i trash from this can",TrashcanResources[i]);
  128. SendClientMessage(playerid,COLOR_RED,string);
  129. GivePlayerTrash(playerid,TrashcanResources[i]);
  130. UpdateTrashcanResources(i, 0);
  131. UpdatePlayerTrashSkill(playerid);
  132. printf("Player trash skill %i",GetPlayerTrashSkill(playerid));
  133. break;
  134. }
  135. }
  136. return true;
  137. }
  138.  
  139. CMD:selltrash(playerid,params[]) {
  140. if(TrashOnPlayer[playerid] <= 0) return SendClientMessage(playerid,COLOR_RED,"You dont have any trash on you to sell!");
  141. if(!IsPlayerInRangeOfPoint(playerid,10.0,2194.0925, -1973.0626, 13.3654)) return SendClientMessage(playerid,COLOR_RED,"You are not near the dumpyard in LS");
  142. if(GetFactoryResources() >= MAX_FACTORY_RESOURCES) return SendClientMessage(playerid,COLOR_RED,"Factory is already full!");
  143. PayByResources(playerid,TrashOnPlayer[playerid]);
  144. GivePlayerTrash(playerid,-TrashOnPlayer[playerid]);
  145. UpdateResources(TrashOnPlayer[playerid]);
  146. GivePlayerMoney(playerid,-GetTrashTax(playerid));
  147. new string[128];
  148. format(string,sizeof(string),"You have paid %i$ as a state tax",GetTrashTax(playerid));
  149. SendClientMessage(playerid,COLOR_RED,string);
  150. return true;
  151. }
  152.  
  153.  
  154. CMD:mytrash(playerid,params[]) {
  155. new string[128];
  156. 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]);
  157. SendClientMessage(playerid,COLOR_GREEN,string);
  158. return true;
  159. }
  160.  
  161.  
  162. CMD:loadtrash(playerid,params[]) {
  163. if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,COLOR_RED,"You are not inside any vehicles");
  164. if(!IsPlayerInTrashmaster(playerid)) return SendClientMessage(playerid,COLOR_RED,"You are not inside trashmaster");
  165. if(!IsPlayerInRangeOfPoint(playerid,10.0,2163.0125,-1971.2373,13.5533)) return SendClientMessage(playerid,COLOR_RED,"You are not at the LS dumpyard");
  166. if(GetFactoryResources() <= 999) return SendClientMessage(playerid,COLOR_RED,"There are not enough materials inside the factory!");
  167.  
  168. new vid = GetPlayerVehicleID(playerid);
  169. if(VehicleTrash[vid] >= 999) return SendClientMessage(playerid,COLOR_RED,"This vehicle is already full");
  170. VehicleTrash[vid] = 1000;
  171. UpdateResources(-1000);
  172. SendClientMessage(playerid,COLOR_RED,"You have loaded your truck with 1000 trash. Go to LS dumpyard and type /droptrash");
  173. return true;
  174. }
  175.  
  176. CMD:droptrash(playerid,params[]) {
  177. if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,COLOR_RED,"You are not inside any vehicles");
  178. if(!IsPlayerInTrashmaster(playerid)) return SendClientMessage(playerid,COLOR_RED,"You are not inside trashmaster");
  179. if(!IsPlayerInRangeOfPoint(playerid,10.0,2547.5715,-2221.8047,13.2977)) return SendClientMessage(playerid,COLOR_RED,"You are not at the drop point!");
  180. new vid = GetPlayerVehicleID(playerid);
  181. if(VehicleTrash[vid] <= 999) return SendClientMessage(playerid,COLOR_RED,"This truck doesnt have any trash!");
  182. GivePlayerMoney(playerid,GetPaymentBasedOnSkill(playerid));
  183. VehicleTrash[vid] = 0;
  184. new string[128];
  185. format(string,sizeof(string),"You have delivered 1000 trash and received %i$",GetPaymentBasedOnSkill(playerid));
  186. SendClientMessage(playerid,COLOR_GREEN,string);
  187. return true;
  188. }
  189.  
  190.  
  191. /* Functions */
  192. GetPlayerTrash(playerid) return TrashOnPlayer[playerid];
  193. GivePlayerTrash(playerid, amount) { TrashOnPlayer[playerid] += amount; }
  194. Float:GetTrashPrice() return TRASH_PRICE;
  195. GetFactoryResources() return TrashFactoryResources;
  196. UpdateFactoryResources(amount) { TrashFactoryResources += amount; }
  197. GetMaxFactoryResources() return MAX_FACTORY_RESOURCES;
  198. UpdatePlayerTrashSkill(playerid) { TrashSkill[playerid] += 1; }
  199. GetPlayerTrashSkill(playerid) return TrashSkill[playerid];
  200.  
  201.  
  202. stock CreateTrashcan(ResourceAmount,UniqueID,ID, Float:X,Float:Y,Float:Z,Float:RX,Float:RY,Float:RZ) {
  203. TrashcanObject[UniqueID] = CreateDynamicObject(ID,X,Y,Z,RX,RY,RZ);
  204. TrashcanText[UniqueID] = Create3DTextLabel("{007BFF}0{00FF00}/{FFFF00}100",0x008080FF,X,Y,Z,20.0,0,0);
  205. TrashcanResources[UniqueID] = ResourceAmount;
  206. }
  207.  
  208. stock IsPlayerInTrashmaster(playerid) {
  209. if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 408) return true;
  210. return false;
  211. }
  212.  
  213. UpdateResources(amount) {
  214. UpdateFactoryResources(amount);
  215. new string[128];
  216. format(string,sizeof(string),"{FFFFFF}Resources; {2FFF9F}%i/%i{FFFFFF}\nCurrent Price: {2FFF9F}%.2f$",GetFactoryResources(),GetMaxFactoryResources(),GetTrashPrice());
  217. Update3DTextLabelText(TrashFactoryText,COLOR_GREEN,string);
  218. }
  219.  
  220. PayByResources(playerid,Float:amount) {
  221. new Float:calc = GetTrashPrice()*amount;
  222. printf("%.2f*%.2f",GetTrashPrice(),amount);
  223. new pp = floatround(calc, floatround_round);
  224. new calc2 = floatround(amount,floatround_round);
  225. GivePlayerMoney(playerid,pp);
  226.  
  227. new string[128];
  228. format(string,sizeof(string),"You have received %i$ for %i trash. Current trash price %.2f$",pp, calc2, GetTrashPrice());
  229. SendClientMessage(playerid,COLOR_GREEN,string);
  230.  
  231. TotalEarnedFromTrash[playerid] += pp;
  232. return true;
  233. }
  234.  
  235. stock UpdateTrashcanResources(tID, ress) {
  236. TrashcanResources[tID] = ress;
  237. new string[64];
  238. format(string,sizeof(string),"{007BFF}%i{00FF00}/{FFFF00}100",TrashcanResources[tID]);
  239. Update3DTextLabelText(TrashcanText[tID],COLOR_GREEN,string);
  240. }
  241.  
  242. stock GetTrashTax(playerid) {
  243. new current_tax_price;
  244. switch(GetPlayerTrashSkill(playerid)) {
  245. case 0 .. 100: current_tax_price = 20;
  246. case 101 .. 250: current_tax_price = 15;
  247. case 251 .. 500: current_tax_price = 10;
  248. case 501 .. 1000: current_tax_price = 5;
  249. case 1001 .. 9999: current_tax_price = 0;
  250. }
  251. return current_tax_price;
  252. }
  253.  
  254. stock GetPaymentBasedOnSkill(playerid) {
  255. new earnings_Now;
  256. switch(GetPlayerTrashSkill(playerid)) {
  257. case 0 .. 100: earnings_Now = 100;
  258. case 101 .. 250: earnings_Now = 120;
  259. case 251 .. 500: earnings_Now = 150;
  260. case 501 .. 1000: earnings_Now = 200;
  261. case 1001 .. 9999: earnings_Now = 250;
  262. }
  263. return earnings_Now;
  264. }
  265.  
  266. stock randomEx(minnum = cellmin, maxnum = cellmax) return random(maxnum - minnum + 1) + minnum; //Y_Less
  267. stock Float:frandomEx(Float:min, Float:max) return min + (max - min) * random(32768) / 32768.0; // Y_Less
  268.  
  269.  
  270. /* Timers */
  271. public UpdateTrashcans() {
  272. new rrX = randomEx(1,10);
  273. for(new i = 0; i < sizeof(TrashcanObject); i++) {
  274. if(TrashcanResources[i] <= 95) {
  275. TrashcanResources[i] += rrX;
  276. new string[128];
  277. format(string,sizeof(string),"{007BFF}%i{00FF00}/{FFFF00}100",TrashcanResources[i]);
  278. Update3DTextLabelText(TrashcanText[i],COLOR_GREEN,string);
  279. printf("Trash can ID: %i now has %i resources",i,TrashcanResources[i]);
  280.  
  281. if(TrashcanResources[i] >= 101) {
  282. TrashcanResources[i] = 100;
  283. }
  284. }
  285. }
  286. return true;
  287. }
  288.  
  289.  
  290.  
  291. public ChangeTrashPrice() {
  292. new Float:rr = frandomEx(1,5), string[128];
  293. TRASH_PRICE = rr;
  294. format(string,sizeof(string),"{FFFFFF}Resources; {2FFF9F}%i/%i{FFFFFF}\nCurrent Price: {2FFF9F}%.2f$",GetFactoryResources(),GetMaxFactoryResources(),GetTrashPrice());
  295. Update3DTextLabelText(TrashFactoryText,COLOR_GREEN,string);
  296. return true;
  297. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement