Advertisement
Guest User

ServerCore.Lua

a guest
Aug 21st, 2015
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 12.63 KB | None | 0 0
  1. guns = {
  2.     Test = {
  3.         Rate = 0.15,
  4.         Damage = 10,
  5.         Spread = 0,
  6.         Range = 300,
  7.         DefArmPos = {Right=CFrame.new(.5,.8,-1.35)*CFrame.Angles(math.rad(-95),math.rad(25),math.rad(5)),Left=CFrame.new(-.8,0.1,-1.35)*CFrame.Angles(math.rad(-90),math.rad(0),math.rad(-1))},
  8.         DefGunPos = CFrame.new(0,0,-.65),
  9.         RotFix = CFrame.new(math.rad(80),math.rad(2),math.rad(185)),
  10.         Clip = 50,
  11.         Max_Ammo = 250
  12.     },
  13.     MSword = {
  14.         Rate = 0.15,
  15.         Damage = 70,
  16.         Spread = 0,
  17.         Range = 300,
  18.         DefArmPos = {Right=CFrame.new(.5,.8,-1.2)*CFrame.Angles(math.rad(-95),math.rad(25),math.rad(5)),Left=CFrame.new(-.8,0.1,-1)*CFrame.Angles(math.rad(-90),math.rad(0),math.rad(-1))},
  19.         DefGunPos = CFrame.new(-1.3,0,.32),
  20.         RotFix = CFrame.new(math.rad(90),math.rad(0),math.rad(90)),
  21.         Clip = 0,
  22.         Max_Ammo = 0
  23.     }
  24. }
  25.  
  26. --[[Costumes
  27.    
  28.     0=Desert
  29.     1=Green
  30.     2=Snow
  31.     3=Standard
  32.     4=Stealth
  33.    
  34. --]]
  35.  
  36. fire = Instance.new("RemoteEvent",game.Workspace)
  37. fire.Name = "_TestFireFunction"
  38. weldArms = Instance.new("RemoteEvent",game.Workspace)
  39. weldArms.Name = "ArmWeldFunction"
  40. weldGun = Instance.new("RemoteEvent",game.Workspace)
  41. weldGun.Name = "GunWeldFunction"
  42. ADS = Instance.new("RemoteEvent",game.Workspace)
  43. ADS.Name = "servADSFunc"
  44. ADSu = Instance.new("RemoteEvent",game.Workspace)
  45. ADSu.Name = "servADSUp"
  46. swap = Instance.new("RemoteEvent",game.Workspace)
  47. swap.Name = "swap"
  48. reload = Instance.new("RemoteEvent",game.Workspace)
  49. reload.Name = "Reload"
  50. upd = Instance.new("RemoteEvent",game.Workspace)
  51. upd.Name = "upd"
  52. dead = Instance.new("RemoteEvent",game.Workspace)
  53. dead.Name = "Died"
  54. Melee = Instance.new("RemoteEvent",game.Workspace)
  55. Melee.Name = "Melee"
  56. sd = Instance.new("RemoteEvent",game.Workspace)
  57. sd.Name = "SwapDone"
  58.  
  59. game.Players.PlayerAdded:connect(function(plr)
  60.  
  61. table.insert(plrV,plr.Name,{})
  62. table.insert(plrV[plr.Name], "Test")
  63. print(table.concat(plrV[plr.Name]))
  64.  
  65. plr.CharacterAdded:connect(function(pm)
  66.  
  67. local plrTV = Instance.new("NumberValue",pm)
  68. plrTV.Name = "Team"
  69. if game.Workspace.Teams["0"]:FindFirstChild(plr.Name) then
  70.     plrTV.Value = 0
  71. elseif game.Workspace.Teams["1"]:FindFirstChild(plr.Name) then
  72.     plrTV.Value = 1
  73. end
  74.    
  75. local animating = false
  76. local ADSd = false
  77. swapping = false
  78. local pgun
  79. local pnam
  80. local snam
  81. local pg
  82. local g
  83. local sg
  84. local og
  85. local gw
  86. local w1
  87. local w2
  88. local eq
  89. local servArms
  90. local barrel
  91. local costume
  92. local isHero
  93.  
  94. Melee.OnServerEvent:connect(function(player,mhp,pgun,style,sp)
  95.  
  96. if sp == false then
  97. ray = Ray.new(
  98. player.Character.Head.Position,
  99. player.Character.Head.CFrame.lookVector*8) 
  100. elseif sp == true then
  101. ray = Ray.new(
  102. player.Character.Head.Position,
  103. player.Character.Head.CFrame.lookVector*20)
  104. end
  105.  
  106. local hit,position,normal = game.Workspace:FindPartOnRayWithIgnoreList(ray,player.Character:GetChildren())
  107.  
  108. if hit ~= nil then
  109.             if hit.Parent:FindFirstChild("Humanoid") then
  110.                 if game.Workspace[hit.Parent.Name].Team.Value ~= game.Workspace.Teams[player.Name].Team.Value then
  111.                 hit.Parent.Humanoid:TakeDamage(guns[pgun].Damage)
  112.                 if hit.Name == "Head" then
  113.                 hit.Parent.Humanoid:TakeDamage(guns[pgun].Damage)  
  114.                 end
  115.                 end
  116.             elseif hit.Parent.Parent:FindFirstChild("Humanoid") then
  117.                 if game.Workspace[hit.Parent.Parent.Name].Team.Value ~= game.Workspace.Teams[player.Name].Team.Value then
  118.                 hit.Parent.Parent.Humanoid:TakeDamage(guns[pgun].Damage)
  119.                 if hit.Name == "Head" then
  120.                 hit.Parent.Parent.Humanoid:TakeDamage(guns[pgun].Damage)   
  121.                 end
  122.                 end
  123.             end
  124.         end
  125.  
  126. local function DrawDBRay(R)
  127.         local Rp = Instance.new("Part")
  128.         local RayLength = ( (R.Origin + R.Direction) - R.Origin ).magnitude
  129.         Rp.FormFactor = "Custom"   
  130.         Rp.Material = Enum.Material.Neon
  131.         Rp.Size = Vector3.new(0,0,RayLength)
  132.         Rp.CFrame = CFrame.new(R.Origin, R.Origin + R.Direction) * CFrame.new(0,0,RayLength/-2)
  133.         Rp.BrickColor = BrickColor.Gray()
  134.         Rp.Transparency = 0
  135.         Rp.Anchored = true
  136.         Rp.CanCollide = false
  137.         Rp.Name = "Ray"
  138.         Rp.Parent = game.Workspace.bdebris
  139.         Rp.Material = Enum.Material.SmoothPlastic
  140.         for i=0,1, 0.055 do
  141.             Rp.Transparency = i
  142.             wait()
  143.         end                
  144.     Rp:Destroy()
  145. end
  146.  
  147. DrawDBRay(ray)
  148.  
  149. end)
  150.  
  151. upd.OnServerEvent:connect(function(player,mhp,Neck)
  152.    
  153. if not player.Character:FindFirstChild("Head") then return end
  154.     local angle = CFrame.new(player.Character.Head.Position, mhp).lookVector.Y
  155.     Neck.C1 = CFrame.new()
  156.     Neck.C0 = CFrame.new(0, 1.5, 0) * CFrame.Angles(math.asin(angle), 0, 0)
  157. end)
  158.  
  159. reload.OnServerEvent:connect(function(player)
  160.    
  161.     g.Ammo.Value = g.Ammo.Value - g.ClipM.Value + g.Clip.Value
  162.     g.Clip.Value = g.ClipM.Value   
  163.    
  164. end)
  165.  
  166. sd.OnServerEvent:connect(function(player,en)
  167.     if en == true then
  168.     swapping = false
  169.     end
  170. end)
  171.  
  172. swap.OnServerEvent:connect(function(player,eq)
  173.    
  174.     if swapping ~= true then
  175.     if w1 == nil then repeat wait() until w1 ~= nil end
  176.     animating = true   
  177.     swapping = true
  178.    
  179.         w1.C1 = w1.C1:lerp(CFrame.new(0,0.5,0)*CFrame.Angles(math.rad(75),0,0),1)
  180.         w2.C1 = w2.C1:lerp(CFrame.new(0,0.5,0)*CFrame.Angles(math.rad(75),0,0),1)
  181.    
  182.     og.Parent = game.Workspace
  183.     g.Parent = nil
  184.     g = og
  185.     if eq == 1 then
  186.         pgun = snam
  187.        
  188.         gw.Part1 = nil
  189.         gw:Destroy()
  190.         g.Parent = nil 
  191.         g=nil
  192.         g = sg             
  193.         gw = Instance.new("Weld",g)
  194.         gw.Name = "Gun"
  195.        
  196.         gw.Part0 = g.Handle
  197.         gw.Part1 = servArms["LA"]      
  198.        
  199.         w1.C0 = guns[snam].DefArmPos.Left
  200.         w2.C0 = guns[snam].DefArmPos.Right
  201.                
  202.         gw.C0 = guns[snam].DefGunPos*CFrame.Angles(guns[snam].RotFix.X,guns[snam].RotFix.Y,guns[snam].RotFix.Z)
  203.        
  204.         g.Parent = player.Character
  205.     else pgun = pnam
  206.        
  207.         gw.Part1 = nil
  208.         gw:Destroy()
  209.         g.Parent = nil
  210.         g=nil
  211.         g = pg             
  212.         gw = Instance.new("Weld",g)
  213.         gw.Name = "Gun"
  214.        
  215.         gw.Part0 = g.Handle
  216.         gw.Part1 = servArms["LA"]      
  217.        
  218.         w1.C0 = guns[pnam].DefArmPos.Left
  219.         w2.C0 = guns[pnam].DefArmPos.Right
  220.                
  221.         gw.C0 = guns[pnam].DefGunPos*CFrame.Angles(guns[pnam].RotFix.X,guns[pnam].RotFix.Y,guns[pnam].RotFix.Z)
  222.        
  223.         g.Parent = player.Character
  224.     end
  225.         w1.C1 = w1.C1:lerp(CFrame.new(0,0,0)*CFrame.Angles(math.rad(0),0,0),1)
  226.         w2.C1 = w2.C1:lerp(CFrame.new(0,0,0)*CFrame.Angles(math.rad(0),0,0),1)
  227.     animating = false
  228.     end
  229.  
  230. end)
  231.  
  232.  
  233. ADS.OnServerEvent:connect(function(player,w1p,w2p,gp)
  234.         if ADSd == false then
  235.         ADSd = true
  236.         animating = true
  237.         for i=0,1,0.1 do
  238.             if ADSd == false then break end
  239.             w2.C1 = w2.C1:lerp(w1p,i)
  240.             w1.C1 = w1.C1:lerp(w2p,i)
  241.             gw.C1 = gw.C1:lerp(gp,i)
  242.             wait()
  243.         end
  244.         animating = false
  245.         repeat wait() until ADSd == false
  246.     end
  247.    
  248. end)
  249.  
  250. ADSu.OnServerEvent:connect(function(player)
  251.     if ADSd == true then
  252.         ADSd = false
  253.         animating = true
  254.         for i=0,1,0.1 do
  255.             w1.C1 = w1.C1:lerp(CFrame.new(0,0,0),i)
  256.             w2.C1 = w2.C1:lerp(CFrame.new(0,0,0),i)
  257.             gw.C1 = gw.C1:lerp(CFrame.new(0,0,0),i)
  258.             wait()
  259.         end
  260.         animating = false
  261.     end
  262. end)
  263.  
  264. weldGun.OnServerEvent:connect(function(player,prim,sec,Hero)
  265.    
  266.         isHero = Hero
  267.        
  268.         pgun = prim --use the gun in other functions
  269.         pnam = prim
  270.         snam = sec
  271.        
  272.         pg = game.ReplicatedStorage.Engine.Models.Guns[prim][player.Character.Team.Value][game.Workspace.stageType.Value]:Clone()  
  273.         if Hero == false then
  274.         pg.Ammo.Value = guns[prim].Max_Ammo
  275.         pg.Clip.Value = guns[prim].Clip
  276.         pg.ClipM.Value = guns[prim].Clip               
  277.         else pg.Clip.Value = 1     
  278.         end
  279.         og = sg    
  280.        
  281.         g = pg             
  282.         gw = Instance.new("Weld",g)
  283.         gw.Name = "Gun"
  284.        
  285.         w1.C0 = guns[pnam].DefArmPos.Left
  286.         w2.C0 = guns[pnam].DefArmPos.Right
  287.        
  288.         gw.Part0 = g.Handle
  289.         gw.Part1 =servArms["LA"]
  290.                
  291.         gw.C0 = guns[pnam].DefGunPos*CFrame.Angles(guns[pnam].RotFix.X,guns[pnam].RotFix.Y,guns[pnam].RotFix.Z)
  292.        
  293.         g.Parent = player.Character
  294.        
  295.         snam = sec
  296.        
  297.         sg = game.ReplicatedStorage.Engine.Models.Guns[sec][player.Character.Team.Value][game.Workspace.stageType.Value]:Clone()       
  298.         if Hero == false then
  299.         sg.Ammo.Value = guns[sec].Max_Ammo
  300.         sg.Clip.Value = guns[sec].Clip
  301.         sg.ClipM.Value = guns[sec].Clip
  302.         else sg.Clip.Value = 1 
  303.         end
  304.         og = sg
  305.        
  306.         pg.Name = "Gun"
  307.         sg.Name = "Gun"
  308.    
  309. end)
  310.  
  311. weldArms.OnServerEvent:connect(function(player,Arms,Faction)
  312.    
  313.     servArms = game.ReplicatedStorage.Engine.Models.Player.Character.Costumes[Faction][game.Workspace.stageType.Value].Arms:Clone()
  314.    
  315.     w1 = Instance.new("Weld",servArms["LA"])
  316.     w1.Name = "Left"
  317.     w1.Part0=servArms["LA"]
  318.     w1.Part1 = player.Character.Head
  319.     w2 = Instance.new("Weld",servArms["RA"])
  320.     w2.Name = "Right"
  321.     w2.Part0=servArms["RA"]
  322.     w2.Part1 = player.Character.Head   
  323.     servArms.Parent = player.Character
  324.     servArms.Name = ("Arms")   
  325.        
  326.         for i,c in pairs(player.Character:GetChildren()) do
  327.             if c:IsA("Part") then c.Transparency = 1 end
  328.             if c:IsA("CharacterMesh") then c:Destroy() end
  329.             if c:IsA("Hat") then c:Destroy() end
  330.             if c:IsA("ShirtGraphic") then c:Destroy() end
  331.             if c:IsA("TShirt") then c:Destroy() end
  332.             if c:IsA("Pants") then c:Destroy() end
  333.             if player.Character.Torso:FindFirstChild("roblox") then player.Character.Torso.roblox:Destroy() end
  334.         end    
  335.         costume = game.ReplicatedStorage.Engine.Models.Player.Character.Costumes[Faction][game.Workspace.stageType.Value]:Clone()
  336.         costume.Name = "Costume"       
  337.         local hw = Instance.new("Weld",costume)
  338.         local llw = Instance.new("Weld",costume)
  339.         local rlw = Instance.new("Weld",costume)
  340.         local tw = Instance.new("Weld",costume)
  341.         hw.Part0 = costume.Head.Head
  342.         hw.Part1 = player.Character.Head
  343.         llw.Part0 = costume["L Leg"].LL
  344.         llw.Part1 = player.Character["Left Leg"]
  345.         rlw.Part0 = costume["R Leg"].RL
  346.         rlw.Part1 = player.Character["Right Leg"]
  347.         tw.Part0 = costume.Torso.T
  348.         tw.Part1 = player.Character.Torso
  349.         hw.C0 = CFrame.Angles(0,math.rad(0),0)
  350.         llw.C0 = CFrame.Angles(0,math.rad(180),0)
  351.         rlw.C0 = CFrame.Angles(0,math.rad(180),0)
  352.         tw.C0 = CFrame.Angles(0,math.rad(180),0)
  353.         costume.Parent = player.Character
  354. end)
  355.  
  356.  
  357.  
  358. fire.OnServerEvent:connect(function(player,mhp,pgun,style)
  359. repeat wait() until g ~= nil
  360. if not pm:FindFirstChild("Gun") then pm:WaitForChild("Gun") end
  361. if  isHero == true or pm.Gun.Clip.Value > 0 and isHero == false then
  362. if isHero == false then pm.Gun.Clip.Value = pm.Gun.Clip.Value - 1 end
  363. pm:WaitForChild("Gun")
  364. if style ~= "Melee" then barrel = pm.Gun.Barrel end
  365.  
  366. local function DrawDBRay(R)
  367.         local Rp = Instance.new("Part")
  368.         local RayLength = ( (R.Origin + R.Direction) - R.Origin ).magnitude
  369.         Rp.FormFactor = "Custom"   
  370.         Rp.Material = Enum.Material.Neon
  371.         Rp.Size = Vector3.new(0,0,RayLength)
  372.         Rp.CFrame = CFrame.new(R.Origin, R.Origin + R.Direction) * CFrame.new(0,0,RayLength/-2)
  373.         Rp.BrickColor = BrickColor.Gray()
  374.         Rp.Transparency = 0
  375.         Rp.Anchored = true
  376.         Rp.CanCollide = false
  377.         Rp.Name = "Ray"
  378.         Rp.Parent = game.Workspace.bdebris
  379.         Rp.Material = Enum.Material.SmoothPlastic
  380.         for i=0,1, 0.055 do
  381.             Rp.Transparency = i
  382.             wait()
  383.         end                
  384.     Rp:Destroy()
  385. end    
  386.  
  387. if style == "Blaster Rifle" then   
  388.         local f = game.ReplicatedStorage.Engine.Models.Guns[pgun].Effects.Laser:Clone()
  389.         f.CFrame = barrel.CFrame
  390.         local bf = Instance.new("BodyForce",f)
  391.        
  392.         local ray = Ray.new(
  393.         barrel.CFrame.p,
  394.          (mhp - barrel.Position + Vector3.new(math.random(guns[pgun].Spread*-1,guns[pgun].Spread)/(mhp - barrel.CFrame.p).magnitude,math.random(guns[pgun].Spread*-1,guns[pgun].Spread/(mhp- barrel.CFrame.p).magnitude),0)).unit*guns[pgun].Range)
  395.        
  396.         local hit,position,normal = game.Workspace:FindPartOnRayWithIgnoreList(ray,player.Character:GetChildren())
  397.        
  398.         if hit ~= nil then
  399.             if hit.Parent:FindFirstChild("Humanoid") then
  400.                 if game.Workspace[hit.Parent.Name].Team.Value ~= game.Workspace.Teams[player.Name].Team.Value then
  401.                 hit.Parent.Humanoid:TakeDamage(guns[pgun].Damage)
  402.                 if hit.Name == "Head" then
  403.                 hit.Parent.Humanoid:TakeDamage(guns[pgun].Damage)  
  404.                 end
  405.                 end
  406.             elseif hit.Parent.Parent:FindFirstChild("Humanoid") then
  407.                 if game.Workspace[hit.Parent.Parent.Name].Team.Value ~= game.Workspace.Teams[player.Name].Team.Value then
  408.                 hit.Parent.Parent.Humanoid:TakeDamage(guns[pgun].Damage)
  409.                 end
  410.             end
  411.         end    
  412.        
  413.         f.CFrame = CFrame.new(barrel.CFrame.p,ray.Direction)*CFrame.Angles(math.rad(90),0,0)
  414.         f.Parent = game.Workspace
  415.         f.Anchored = false
  416.         local dir = (mhp - barrel.CFrame.p).Unit*50
  417.         bf.force = Vector3.new(0,196.2,0)*f:GetMass()
  418.         f.Velocity = dir*5
  419.  
  420.         --DrawDBRay(ray)   
  421.         wait() 
  422.        
  423.         f.Touched:connect(function()
  424.             f:Destroy()
  425.         end)
  426.         wait(6)
  427.         f:Destroy()
  428. end
  429. end
  430. end)
  431.  
  432. dead.OnServerEvent:connect(function(player)
  433. player.Character.Gun:Destroy()
  434. player.Character.Arms:Destroy()
  435. player.Character.Costume:Destroy()
  436.  
  437. animating = false
  438. ADSd = false
  439. swapping = false
  440. pgun = nil
  441. pnam = nil
  442. snam = nil
  443. pg:Destroy()
  444. pg = nil
  445. sg:Destroy()
  446. sg = nil
  447. og = nil
  448. gw:Destroy()
  449. gw = nil
  450. w1:Destroy()
  451. w1 = nil
  452. w2:Destroy()
  453. w2 = nil
  454. eq = nil
  455. servArms = nil
  456. barrel = nil
  457. costume = nil
  458.  
  459. end)
  460.  
  461. end)
  462.  
  463. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement