Advertisement
Guest User

Untitled

a guest
Apr 29th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.29 KB | None | 0 0
  1. function Purify ( strng )
  2. if (string.find(tostring(strng), [[%"]])) then
  3. strng = " "
  4. end
  5. if (string.find(tostring(strng), [[\n]])) then
  6. strng = " "
  7. end
  8. return strng
  9. end
  10.  
  11. function Upgrade(ply, args)
  12. args = Purify(args)
  13. if( args != "" ) then return ""; end
  14. local trace = { }
  15.  
  16. trace.start = ply:EyePos();
  17. trace.endpos = trace.start + ply:GetAimVector() * 150;
  18. trace.filter = ply;
  19.  
  20. local tr = util.TraceLine( trace );
  21. if (!IsValid(tr.Entity)) then
  22. return "";
  23. end
  24. local targent = tr.Entity
  25. if (targent:GetClass()!="auto_turret" && targent:GetClass()!="money_printer_admin" && targent:GetClass()!="money_printer_superquantum" && targent:GetClass()!="dispenser" && targent:GetClass()!="supplytable" && targent:GetClass()!="drugfactory" && targent:GetClass()!="drug_lab" && targent:GetClass()!="still_average" && targent:GetClass()!="money_printer_tin" && targent:GetClass()!="money_printer_bronze" && targent:GetClass()!="money_printer_iron" && targent:GetClass()!="money_printer_copper" && targent:GetClass()!="money_printer_silver" && targent:GetClass()!="money_printer_gold" && targent:GetClass()!="money_printer_sapphire" && targent:GetClass()!="money_printer_emerald" && targent:GetClass()!="money_printer_pearl" && targent:GetClass()!="money_printer_ruby" && targent:GetClass()!="money_printer_platinum" && targent:GetClass()!="money_printer_diamond" && targent:GetClass()!="money_printer_depleteduranium" && targent:GetClass()!="money_printer_nuclear" && targent:GetClass()!="money_printer_nova" && targent:GetClass()!="money_printer_supernova" && targent:GetClass()!="radartower" && targent:GetClass()!="gunfactory" && targent:GetClass()!="weedplant" && targent:GetClass()!="meth_lab" && targent:GetClass()!="meth_lab_stable" && targent:GetClass()!="microwave") && targent:GetClass()!="money_printer_nextgeneration" && targent:GetClass()!="money_printer_quantum" && targent:GetClass()!="money_printer_tridium" && targent:GetClass()!="money_printer_antimatter"then
  26. Notify(ply,4,3,"This cannot be upgraded.")
  27. ply:ConCommand( "play buttons/button10.wav" )
  28. return "" ;
  29. end
  30.  
  31. if not (targent.Owner) then
  32. Notify( ply, 4, 3, "You do not own this Structure!" );
  33. ply:ConCommand( "play buttons/button10.wav" )
  34. return "" ;
  35. end
  36. local lvl = targent:GetNWInt("upgrade") + 1
  37. if (lvl>2 and targent:GetClass()!="supplytable" and targent:GetClass()!="drug_lab" and targent:GetClass()!="drugfactory" and targent:GetClass()!="money_printer_tin" and targent:GetClass()!="money_printer_copper" and targent:GetClass()!="money_printer_bronze" and targent:GetClass()!="money_printer_iron" and targent:GetClass()!="money_printer_silver" and targent:GetClass()!="money_printer_gold" and targent:GetClass()!="money_printer_sapphire" and targent:GetClass()!="money_printer_emerald" and targent:GetClass()!="money_printer_pearl" and targent:GetClass()!="money_printer_ruby" and targent:GetClass()!="money_printer_platinum" and targent:GetClass()!="money_printer_diamond" and targent:GetClass()!="money_printer_depleteduranium" and targent:GetClass()!="money_printer_nuclear" and targent:GetClass()!="money_printer_nova" and targent:GetClass()!="auto_turret" and targent:GetClass()!="gunfactory" and targent:GetClass()!="dispenser" and targent:GetClass()!="weedplant" and targent:GetClass()!="microwave" and targent:GetClass()!="money_printer_supernova" and targent:GetClass()!="meth_lab_stable" and targent:GetClass()!="meth_lab" and targent:GetClass()!="money_printer_superquantum" and targent:GetClass()!="money_printer_nextgeneration" and targent:GetClass()!="money_printer_quantum" and targent:GetClass()!="money_printer_tridium" and targent:GetClass()!="money_printer_antimatter") then Notify(ply, 4, 3, "This is already fully upgraded.")
  38. return "" ;
  39. end
  40. if (lvl>2 and targent:GetClass()=="weedplant" ) then
  41. Notify(ply, 4, 3, "This is already fully upgraded.")
  42. return "" ;
  43. end
  44. if (lvl>3 and targent:GetClass()=="drugfactory" ) then
  45. Notify(ply, 4, 3, "This is already fully upgraded.")
  46. return "" ;
  47. end
  48. if (lvl>3 and targent:GetClass()=="supplytable" ) then
  49. Notify(ply, 4, 3, "This is already fully upgraded.")
  50. return "" ;
  51. end
  52. if (lvl>4 and targent:GetClass()=="gunfactory" ) then
  53. Notify(ply, 4, 3, "This is already fully upgraded.")
  54. return "" ;
  55. end
  56. if (lvl>10 and targent:GetClass()=="money_printer_tin") then
  57. Notify(ply, 4, 3, "This is already fully upgraded.")
  58. return "" ;
  59. end
  60. if (lvl>10 and targent:GetClass()=="money_printer_copper") then
  61. Notify(ply, 4, 3, "This is already fully upgraded.")
  62. return "" ;
  63. end
  64. if (lvl>10 and targent:GetClass()=="money_printer_bronze") then
  65. Notify(ply, 4, 3, "This is already fully upgraded.")
  66. return "" ;
  67. end
  68. if (lvl>10 and targent:GetClass()=="money_printer_iron") then
  69. Notify(ply, 4, 3, "This is already fully upgraded.")
  70. return "" ;
  71. end
  72. if (lvl>10 and targent:GetClass()=="money_printer_silver") then
  73. Notify(ply, 4, 3, "This is already fully upgraded.")
  74. return "" ;
  75. end
  76. if (lvl>10 and targent:GetClass()=="money_printer_gold") then
  77. Notify(ply, 4, 3, "This is already fully upgraded.")
  78. return "" ;
  79. end
  80. if (lvl>10 and targent:GetClass()=="money_printer_sapphire") then
  81. Notify(ply, 4, 3, "This is already fully upgraded.")
  82. return "" ;
  83. end
  84. if (lvl>10 and targent:GetClass()=="money_printer_emerald") then
  85. Notify(ply, 4, 3, "This is already fully upgraded.")
  86. return "" ;
  87. end
  88. if (lvl>10 and targent:GetClass()=="money_printer_pearl") then
  89. Notify(ply, 4, 3, "This is already fully upgraded.")
  90. return "" ;
  91. end
  92. if (lvl>10 and targent:GetClass()=="money_printer_ruby") then
  93. Notify(ply, 4, 3, "This is already fully upgraded.")
  94. return "" ;
  95. end
  96. if (lvl>10 and targent:GetClass()=="money_printer_platinum") then
  97. Notify(ply, 4, 3, "This is already fully upgraded.")
  98. return "" ;
  99. end
  100. if (lvl>10 and targent:GetClass()=="money_printer_diamond") then
  101. Notify(ply, 4, 3, "This is already fully upgraded.")
  102. return "" ;
  103. end
  104. if (lvl>10 and targent:GetClass()=="money_printer_depleteduranium") then
  105. Notify(ply, 4, 3, "This is already fully upgraded.")
  106. return "" ;
  107. end
  108. if (lvl>10 and targent:GetClass()=="money_printer_nuclear") then
  109. Notify(ply, 4, 3, "This is already fully upgraded.")
  110. return "" ;
  111. end
  112. if (lvl>10 and targent:GetClass()=="money_printer_nova") then
  113. Notify(ply, 4, 3, "This is already fully upgraded.")
  114. return "" ;
  115. end
  116. if (lvl>10 and targent:GetClass()=="money_printer_supernova") then
  117. Notify(ply, 4, 3, "This is already fully upgraded.")
  118. return "" ;
  119. end
  120. if (lvl>10 and targent:GetClass()=="money_printer_quantum") then
  121. Notify(ply, 4, 3, "This is already fully upgraded.")
  122. return "" ;
  123. end
  124. if (lvl>10 and targent:GetClass()=="money_printer_superquantum") then
  125. Notify(ply, 4, 3, "This is already fully upgraded.")
  126. return "" ;
  127. end
  128. if (lvl>10 and targent:GetClass()=="money_printer_nextgeneration") then
  129. Notify(ply, 4, 3, "This is already fully upgraded.")
  130. return "" ;
  131. end
  132. if (lvl>10 and targent:GetClass()=="money_printer_tridium") then
  133. Notify(ply, 4, 3, "This is already fully upgraded.")
  134. return "" ;
  135. end
  136. if (lvl>10 and targent:GetClass()=="money_printer_antimatter") then
  137. Notify(ply, 4, 3, "This is already fully upgraded.")
  138. return "" ;
  139. end
  140. if (lvl>10 and targent:GetClass()=="money_printer_admin") then
  141. Notify(ply, 4, 3, "This is already fully upgraded.")
  142. return "" ;
  143. end
  144. if (lvl>5 and targent:GetClass()=="auto_turret") then
  145. Notify(ply, 4, 3, "This is already fully upgraded.")
  146. return "" ;
  147. end
  148. if (lvl>5 and targent:GetClass()=="meth_lab_stable") then
  149. Notify(ply, 4, 3, "This is already fully upgraded.")
  150. return "" ;
  151. end
  152. if (lvl>5 and targent:GetClass()=="meth_lab") then
  153. Notify(ply, 4, 3, "This is already fully upgraded.")
  154. return "" ;
  155. end
  156. if (lvl>7 and targent:GetClass()=="dispenser") then
  157. Notify(ply, 4, 3, "This is already fully upgraded.")
  158. return "" ;
  159. end
  160. if (lvl>7 and targent:GetClass()=="drug_lab") then
  161. Notify(ply, 4, 3, "This is already fully upgraded.")
  162. return "" ;
  163. end
  164. if (lvl>8 and targent:GetClass()=="microwave") then
  165. Notify(ply, 4, 3, "This is already fully upgraded.")
  166. return "" ;
  167. end
  168.  
  169. local price = 0
  170. if targent:GetClass()== "auto_turret" then price = CfgVars["turretcost"]
  171. elseif targent:GetClass()== "health_dispenser" then price = CfgVars["healthdispensercost"]
  172. elseif targent:GetClass()== "dispenser" then price = CfgVars["dispensercost"]
  173. elseif targent:GetClass()== "microwave" then price = CfgVars["microwavecost"]
  174. elseif targent:GetClass()== "drugfactory" then price = CfgVars["drugfactorycost"]
  175. elseif targent:GetClass()== "drug_lab" then price = CfgVars["druglabcost"]
  176. elseif targent:GetClass()== "still_average" then price = CfgVars["stillcost"]
  177. elseif targent:GetClass()== "money_printer_tin" then price = CfgVars["tinprintercost"]
  178. elseif targent:GetClass()== "money_printer_copper" then price = CfgVars["copperprintercost"]
  179. elseif targent:GetClass()== "money_printer_bronze" then price = CfgVars["bronzeprintercost"]
  180. elseif targent:GetClass()== "money_printer_iron" then price = CfgVars["bronzeprintercost"]
  181. elseif targent:GetClass()== "money_printer_silver" then price = CfgVars["silverprintercost"]
  182. elseif targent:GetClass()== "money_printer_gold" then price = CfgVars["goldprintercost"]
  183. elseif targent:GetClass()== "money_printer_sapphire" then price = CfgVars["sapphireprintercost"]
  184. elseif targent:GetClass()== "money_printer_emerald" then price = CfgVars["emeraldprintercost"]
  185. elseif targent:GetClass()== "money_printer_pearl" then price = CfgVars["pearlprintercost"]
  186. elseif targent:GetClass()== "money_printer_ruby" then price = CfgVars["rubyprintercost"]
  187. elseif targent:GetClass()== "money_printer_platinum" then price = CfgVars["platinumprintercost"]
  188. elseif targent:GetClass()== "money_printer_depleteduranium" then price = CfgVars["duprintercost"]
  189. elseif targent:GetClass()== "money_printer_nuclear" then price = CfgVars["nukeprintercost"]
  190. elseif targent:GetClass()== "money_printer_nova" then price = CfgVars["novaprintercost"]
  191. elseif targent:GetClass()== "money_printer_supernova" then price = CfgVars["supernovaprintercost"]
  192. elseif targent:GetClass()== "money_printer_diamond" then price = CfgVars["diamondprintercost"]
  193. elseif targent:GetClass()== "money_printer_quantum" then price = CfgVars["quantumprintercost"]
  194. elseif targent:GetClass()== "money_printer_superquantum" then price = CfgVars["superquantumprintercost"]
  195. elseif targent:GetClass()== "money_printer_nextgeneration" then price = CfgVars["nextgenerationprintercost"]
  196. elseif targent:GetClass()== "money_printer_tridium" then price = CfgVars["tridiumprintercost"]
  197. elseif targent:GetClass()== "money_printer_antimatter" then price = CfgVars["antimatterprintercost"]
  198. elseif targent:GetClass()== "money_printer_admin" then price = CfgVars["adminprintercost"]
  199. elseif targent:GetClass()== "meth_lab" then price = CfgVars["methlabcost"]
  200. elseif targent:GetClass()== "meth_lab_stable" then price = CfgVars["metlabstable"]
  201. elseif targent:GetClass()== "radartower" then price = CfgVars["radartowercost"]
  202. elseif targent:GetClass()== "weedplant" then price = CfgVars["weedplantcost"]
  203. elseif targent:GetClass()== "gunfactory" then price = CfgVars["gunfactorycost"]
  204. elseif targent:GetClass()== "supplytable" then price = CfgVars["supplytablecost"]
  205. end
  206. price = price*CfgVars["upgradecost"]
  207. if (lvl==10) then price = price*960 end
  208. if (lvl==9) then price = price*480 end
  209. if (lvl==8) then price = price*240 end
  210. if (lvl==7) then price = price*120 end
  211. if (lvl==6) then price = price*60 end
  212. if (lvl==5) then price = price*30 end
  213. if (lvl==4) then price = price*12 end
  214. if (lvl==3) then price = price*6 end
  215. if (lvl==2) then price = price*3 end
  216. if ply:GetUserGroup() == "silver_donor" then
  217. price = price * 0.9
  218. elseif ply:GetUserGroup() == "gold_donor" then
  219. price = price * 0.8
  220. elseif ply:GetUserGroup() == "diamond_donor" then
  221. price = price * 0.7
  222. elseif ply:GetUserGroup() == "superadmin" then
  223. price = price * 0.6
  224. end
  225.  
  226. if GetMoney( ply ) <=(price) then
  227. Notify(ply, 4, 3, "Cannot afford this. Cost is $" .. price)
  228. ply:ConCommand( "play buttons/button10.wav" )
  229. return "" ;
  230. end
  231. AddMoney( ply, price*-1)
  232. Notify( ply, 0, 3, "Applying level " .. lvl .. " upgrade.")
  233. targent:SetNWInt("upgrade", lvl)
  234. ply:ConCommand( "play buttons/button4.wav" )
  235. return "";
  236. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement