Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2015
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.01 KB | None | 0 0
  1. /*
  2.  
  3. Main configuration for non-persistent market system
  4. Will need triggers to hook into vanilla pricing methods
  5. Edited by: Lukas "Alduin86"
  6.  
  7. */
  8.  
  9. ////////////MAIN CONFIG
  10.  
  11. private["_silberPrice","_goldPrice","_queryResult","_query","_item","_itemprice","_oilpPrice","_coalrPrice","_iron_rPrice","_diamondcPrice","_copper_rPrice","_salt_rPrice","_glassPrice","_cementPrice","_turtlePrice","_marijuanaPrice","_cocainepPrice","_heroinpPrice","_goldbarPrice","_methb_Price","_methn_Price"];
  12.  
  13.  
  14. _query = format["SELECT resource, price FROM resources"];
  15. waitUntil{sleep (random 0.3); !DB_Async_Active};
  16. _queryResult = [_query,2,true] call DB_fnc_asyncCall;
  17. _rows = call compile format["%1",_queryResult]; //compile data
  18. diag_log "------------- Market Query Request -------------";
  19. diag_log format["Query: %1",_query];
  20. diag_log format["Result: %1",_rows];
  21. diag_log "------------------------------------------------";
  22.  
  23. //* _rows should look like this now: [["oilp","1000"],["diamond","2000"]];
  24.  
  25. {
  26. _item = (_x select 0); //on the first run = "oilp", second run = "diamond")
  27. _itemprice = (_x select 1); //on the first run = "1000", second run = "2000") //* Note: _price is a STRING now!
  28.  
  29. diag_log format["%1-price %2 generated",_item,_itemprice];
  30. if(_item == "oilp") then {_oilpPrice = _itemprice}; // The right price should be assigned
  31. if(_item == "iron_r") then {_iron_rPrice = _itemprice}; // The right price should be assigned
  32. if(_item == "diamondc") then {_diamondcPrice = _itemprice}; // The right price should be assigned
  33. if(_item == "copper_r") then {_copper_rPrice = _itemprice}; // The right price should be assigned
  34. if(_item == "salt_r") then {_salt_rPrice = _itemprice}; // The right price should be assigned
  35. if(_item == "glass") then {_glassPrice = _itemprice}; // The right price should be assigned
  36. if(_item == "cement") then {_cementPrice = _itemprice}; // The right price should be assigned
  37. if(_item == "turtle") then {_turtlePrice = _itemprice}; // The right price should be assigned
  38. if(_item == "marijuana") then {_marijuanaPrice = _itemprice}; // The right price should be assigned
  39. if(_item == "cocainep") then {_cocainepPrice = _itemprice}; // The right price should be assigned
  40. if(_item == "heroinp") then {_heroinpPrice = _itemprice}; // The right price should be assigned
  41. if(_item == "goldbar") then {_goldbarPrice = _itemprice}; // The right price should be assigned
  42. if(_item == "coalr") then {_coalrPrice = _itemprice}; // The right price should be assigned
  43. if(_item == "gold") then {_goldPrice = _itemprice}; // The right price should be assigned
  44. if(_item == "silber") then {_silberPrice = _itemprice}; // The right price should be assigned
  45. if(_item == "methb") then {_methb_Price = _itemprice}; // The right price should be assigned
  46. if(_item == "methn") then {_methn_Price = _itemprice}; // The right price should be assigned
  47. } forEach _rows;
  48.  
  49.  
  50. life_market_resources = [
  51.  
  52. //Schema: SHORTNAME, DEFAULT-WERT, MIN-WERT, MAX-WERT, VERÄNDERUNG BEI AKTION [VERKAUF Multipliziert mit 1, Kauf multipliziert um -1
  53.  
  54. ///////////////////////////////////
  55. //Edel
  56. ///////////////////////////////////
  57.  
  58. ["diamondc", _diamondcPrice, 2678, 5357, 3, 1,
  59. [
  60. ["gold",1],
  61. ["silber",1]
  62. ]
  63. ],
  64.  
  65. ["gold", _goldPrice, 1200, 6300, 2, 2,
  66. [
  67. ["diamondc",1],
  68. ["silber",1]
  69. ]
  70. ],
  71.  
  72. ["silber", _silberPrice, 1200, 6300, 2, 2,
  73. [
  74. ["diamondc",1],
  75. ["gold",1]
  76. ]
  77. ],
  78.  
  79. ///////////////////////////////////
  80. //Metalle
  81. ///////////////////////////////////
  82.  
  83. ["coalr", _coalrPrice, 1000, 2000, 3, 1,
  84. [
  85. ["copper_r",1],
  86. ["iron_r",1]
  87. ]
  88. ],
  89.  
  90. ["iron_r", _iron_rPrice, 3333, 6666, 3, 1,
  91. [
  92. ["copper_r",1],
  93. ["coalr",1]
  94. ]
  95. ],
  96.  
  97. ["copper_r", _copper_rPrice, 1339, 3571, 3, 1,
  98. [
  99. ["iron_r",1],
  100. ["coalr",1]
  101. ]
  102. ],
  103.  
  104. ///////////////////////////////////
  105. //Bank
  106. ///////////////////////////////////
  107.  
  108. ["goldbar", _goldbarPrice, 95000, 95000, 0, 0,
  109. [
  110. ]
  111. ],
  112.  
  113. ///////////////////////////////////
  114. //Bla
  115. ///////////////////////////////////
  116.  
  117. ["oilp", _oilpPrice, 500, 6300, 3, 1,
  118. [
  119. ["salt_r",1],
  120. ["cement",1],
  121. ["glass",1]
  122. ]
  123. ],
  124.  
  125. ["salt_r", _salt_rPrice, 1200, 3350, 3, 1,
  126. [
  127. ["oilp",1],
  128. ["cement",1],
  129. ["glass",1]
  130. ]
  131. ],
  132.  
  133. ["glass", _glassPrice, 1785, 4464, 3, 1,
  134. [
  135. ["oilp",1],
  136. ["salt_r",1],
  137. ["cement",1]
  138. ]
  139. ],
  140.  
  141. ["cement", _cementPrice, 2666, 6666, 3, 1,
  142. [
  143. ["oilp",1],
  144. ["salt_r",1],
  145. ["glass",1]
  146. ]
  147. ],
  148.  
  149. ///////////////////////////////////
  150. //Illegal
  151. ///////////////////////////////////
  152.  
  153.  
  154. ["turtle", _turtlePrice, 10000, 10000, 0, 0,
  155. [
  156. ]
  157. ],
  158.  
  159. ["marijuana", _marijuanaPrice, 4464, 8035,4, 2,
  160. [
  161. ["methn",1],
  162. ["methb",1],
  163. ["cocainep",1],
  164. ["heroinp",1]
  165. ]
  166. ],
  167.  
  168. ["cocainep", _cocainepPrice, 4464, 8928, 4, 2,
  169. [
  170. ["methn",1],
  171. ["methb",1],
  172. ["marijuana",1],
  173. ["heroinp",1]
  174. ]
  175. ],
  176. ["methb", _methb_Price, 6400, 10028, 4, 2,
  177. [
  178. ["methn",1],
  179. ["marijuana",1],
  180. ["heroinp",1],
  181. ["cocainep",1]
  182. ]
  183. ],
  184. ["methn", _methn_Price, 4244, 9299, 4, 2,
  185. [
  186. ["methb",1],
  187. ["marijuana",1],
  188. ["heroinp",1],
  189. ["cocainep",1]
  190. ]
  191. ],
  192.  
  193. ["heroinp", _heroinpPrice, 3571, 7142, 4, 2,
  194. [
  195. ["methn",1],
  196. ["methb",1],
  197. ["marijuana",1],
  198. ["cocainep",1]
  199. ]
  200. ]
  201. ];
  202.  
  203.  
  204. publicVariable "life_market_resources";
  205.  
  206. diag_log "------------- Life Market Resources -------------";
  207. diag_log format["Result: %1",life_market_resources];
  208. diag_log "------------------------------------------------";
  209.  
  210. life_market_shortnames = [];
  211.  
  212. {
  213. life_market_shortnames set [count life_market_shortnames, _x select 0];
  214. }
  215. foreach life_market_resources;
  216.  
  217. publicVariable "life_market_shortnames";
  218.  
  219. life_market_prices = [];
  220. {
  221. life_market_prices set [count life_market_prices, [_x select 0, _x select 1, 0, 0] ];
  222. }
  223. foreach life_market_resources;
  224.  
  225. publicVariable "life_market_prices";
  226.  
  227. systemChat "Market Prices Generated!";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement