Guest User

Untitled

a guest
Jun 4th, 2011
112
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. local nograv = {
  3. "shot_beanbag",
  4. "shot_tankshell",
  5. "shot_rocket",
  6. "shot_tranq",
  7. "auto_turret_gun",
  8. "shot_glround",
  9. "svehicle_part_nophysics",
  10. "svehicle_part",
  11. "shot_glround",
  12. "worldslayer",
  13. "shot_energy"
  14. }
  15.  
  16. // not local so that it can be used in all the rest of the game.
  17. physgunables = {
  18. "gmod_cameraprop",
  19. "gmod_rtcameraprop",
  20. "gmod_balloon",
  21. "gmod_button",
  22. "gmod_lamp",
  23. "gmod_light",
  24. "gmod_anchor",
  25. "func_physbox",
  26. "prop_physics",
  27. "prop_physics_multiplayer",
  28. "spawned_weapon",
  29. "microwave",
  30. "drug_lab",
  31. "gunlab",
  32. "dispenser",
  33. "phys_magnet",
  34. "m_crate",
  35. "prop_ragdoll",
  36. "gmod_thruster",
  37. "gmod_wheel",
  38. "item_drug",
  39. "item_steroid",
  40. "item_painkiller",
  41. "item_magicbullet",
  42. "item_antidote",
  43. "item_amp",
  44. "item_helmet",
  45. "item_random",
  46. "item_buyhealth",
  47. "item_superdrug",
  48. "item_booze",
  49. "item_scanner",
  50. "item_toolkit",
  51. "item_regen",
  52. "item_reflect",
  53. "item_focus",
  54. "item_snipeshield",
  55. "item_armor",
  56. "item_food",
  57. "item_leech",
  58. "item_shockwave",
  59. "item_doubletap",
  60. "item_uberdrug",
  61. "item_knockback",
  62. "item_doublejump",
  63. "item_armorpiercer",
  64. "item_superdrugoffense",
  65. "item_superdrugdefense",
  66. "item_superdrugweapmod",
  67. "pillbox",
  68. "drugfactory",
  69. "powerplant",
  70. "weedplant",
  71. "meth_lab",
  72. "prop_effect",
  73. "money_printer",
  74. "still",
  75. "gunvault",
  76. "radartower",
  77. "gunfactory",
  78. "bigbomb",
  79. "keypad",
  80. "sign"
  81. }
  82.  
  83. function ccWithdrawGun( ply, cmd, args )
  84. // in case of jackasses trying to exploit the game, or any other wierd shit that could happen.
  85. if (args[1]==nil || args[2] == nil) then
  86. return
  87. end
  88. gnum = tonumber(args[2])
  89. if (!ents.GetByIndex(args[1]):IsValid() || gnum>10 || gnum<1) then
  90. return
  91. end
  92. local vault = ents.GetByIndex(args[1])
  93. if (vault:GetClass()!="gunvault" || ply:GetPos():Distance(vault:GetPos())>200) then return end
  94. if (vault:IsLocked() && ply!=vault.Owner && !ply:IsAllied(vault.Owner)) then return end
  95. if (vault:CanDropGun(gnum)) then
  96. vault:DropGun(gnum, ply, 25, false)
  97. else
  98. Notify(ply,4,3, "This gun does not exist!")
  99. umsg.Start( "killgunvaultgui", ply );
  100. umsg.Short( args[1] )
  101. umsg.End()
  102. end
  103. end
  104. concommand.Add( "withdrawgun", ccWithdrawGun );
  105.  
  106. function ccWithdrawItem( ply, cmd, args )
  107. // in case of jackasses trying to exploit the game, or any other wierd shit that could happen.
  108. if (args[1]==nil || args[2] == nil) then
  109. return
  110. end
  111. gnum = tonumber(args[2])
  112. if (!ents.GetByIndex(args[1]):IsValid() || gnum>20 || gnum<1) then
  113. return
  114. end
  115. local vault = ents.GetByIndex(args[1])
  116. if (vault:GetClass()!="pillbox" || ply:GetPos():Distance(vault:GetPos())>200) then return end
  117. if (vault:IsLocked() && ply!=vault.Owner && !ply:IsAllied(vault.Owner)) then return end
  118. if (vault:CanDropGun(gnum)) then
  119. vault:DropGun(gnum, ply, 35, false)
  120. else
  121. Notify(ply,4,3, "This item does not exist!")
  122. umsg.Start( "killpillboxgui", ply );
  123. umsg.Short( args[1] )
  124. umsg.End()
  125. end
  126. end
  127. concommand.Add( "withdrawitem", ccWithdrawItem );
  128.  
  129. function ccSetWeapon( ply, cmd, args )
  130. if (args[1]==nil || args[2] == nil) then
  131. return
  132. end
  133. guntype = tostring(args[2])
  134. if !ValidEntity(ents.GetByIndex(args[1])) || (guntype!="laserbeam" && guntype!="laserrifle" && guntype!="grenadegun" && guntype!="plasma" && guntype!="worldslayer" && guntype!="resetbutton") then
  135. return
  136. end
  137. local vault = ents.GetByIndex(args[1])
  138. if (vault:GetClass()!="gunfactory" || ply:GetPos():Distance(vault:GetPos())>300) then return end
  139. if (vault:CanProduce(guntype, ply)) then
  140. vault:StartProduction(guntype, ply)
  141. else
  142. if guntype=="resetbutton" then
  143. Notify(ply,4,3, "Only Gun Factory owner can cancel weapon production.")
  144. else
  145. Notify(ply,4,3, "Cant make weapon.")
  146. end
  147. umsg.Start( "killgunfactorygui", ply );
  148. umsg.Short( args[1] )
  149. umsg.End()
  150. end
  151. end
  152. concommand.Add( "setgunfactoryweapon", ccSetWeapon );
  153.  
  154. function WeldControl(ent,ply)
  155. if (ValidEntity(ply)) then
  156. if ValidEntity(ent) then
  157. ent:SetNWInt("welddamage", 150)
  158. end
  159. ply:GetTable().shitweldcount=ply:GetTable().shitweldcount-1
  160. if (ply:GetTable().shitweldcount<=0) then
  161. ply:GetTable().shitweldcount=0
  162. ply:SetNWBool("shitwelding", false)
  163. end
  164. end
  165. end
  166.  
  167. function ccSetRefineryMode( ply, cmd, args )
  168. if (args[1]==nil || args[2] == nil) then
  169. return
  170. end
  171. mode = tostring(args[2])
  172. if !ValidEntity(ents.GetByIndex(args[1])) || (mode!="money" && mode!="offense" && mode!="defense" && mode!="weapmod" && mode!="eject" && mode!="uber") then
  173. return
  174. end
  175. local vault = ents.GetByIndex(args[1])
  176. if (vault:GetClass()!="drugfactory" || ply:GetPos():Distance(vault:GetPos())>300) then return end
  177.  
  178. local ref = vault:CanRefine(mode, ply)
  179. if (ref==true) then
  180. vault:SetMode(mode)
  181. else
  182. Notify(ply,4,3,ref)
  183. end
  184. umsg.Start( "killdrugfactorygui", ply );
  185. umsg.Short( args[1] )
  186. umsg.End()
  187. end
  188. concommand.Add( "setrefinerymode", ccSetRefineryMode );
  189.  
  190.  
  191. local function GetEntOwner(ent)
  192. if !ValidEntity(ent) then return false end
  193. local owner = ent
  194. if ent:GetVar("PropProtection")==nil then return false end
  195. if ValidEntity(player.GetByUniqueID(ent:GetVar("PropProtection"))) then
  196. owner = player.GetByUniqueID(ent:GetVar("PropProtection"))
  197. end
  198. if owner!=ent then
  199. return owner
  200. else
  201. return false
  202. end
  203. end
  204.  
  205. --function NotifyPlayer( ply, msg )
  206. -- if (!timer.IsTimer(ply:SteamID() .. msg)) then
  207. -- timer.Create(ply:SteamID() .. msg, 5, 1, timer.Remove, ply:SteamID() .. msg)
  208. -- ply:PrintMessage( 2, msg );
  209. -- ply:SendLua( "GAMEMODE:AddNotify(\"" .. msg .. "\", " .. 1 .. ", " .. 3 .. ")" );
  210. -- end
  211. --end
  212.  
  213. local function SetOwner(ent, ply)
  214. // take no chances, check it here too.
  215. if (ValidEntity(ent) && ValidEntity(ply) && ply:IsPlayer()) then
  216. ent:SetVar("PropProtection", ply:UniqueID() )
  217. return true
  218. else
  219. return false
  220. end
  221. end
  222.  
  223. local originalCleanup = cleanup.Add
  224. function cleanup.Add(ply,type,ent)
  225. if (ValidEntity(ply) && ply:IsPlayer() && ValidEntity(ent)) then
  226. SetOwner(ent, ply)
  227. end
  228. originalCleanup(ply,type,ent)
  229. end
  230.  
  231. function SpawnedProp(ply, model, ent)
  232. SetOwner(ent, ply)
  233. end
  234.  
  235. hook.Add("PlayerSpawnedProp", "playerSpawnedProp", SpawnedProp)
RAW Paste Data