Advertisement
Guest User

Untitled

a guest
Feb 13th, 2011
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.26 KB | None | 0 0
  1. //////////////////////////////////////////////CLIENTSIDE/////////////////////////////////
  2.  
  3. usermessage.Hook("zc_usedragdoll", function()
  4. if zc_isopen == nil then
  5. zc_isopen = 1
  6. local DermaPanel = vgui.Create( "DFrame" )
  7. DermaPanel:SetPos( 50,50 )
  8. DermaPanel:SetSize( 450, 450 )
  9. DermaPanel:SetTitle( "Scavenge!" )
  10. DermaPanel:SetVisible( true )
  11. DermaPanel:SetDraggable( true )
  12. DermaPanel:ShowCloseButton( false )
  13. DermaPanel:MakePopup()
  14.  
  15. local DermaList = vgui.Create( "DPanelList", DermaPanel )
  16. DermaList:SetPos( 25,25 )
  17. DermaList:SetSize( 400, 400 )
  18. DermaList:SetSpacing( 5 )
  19. DermaList:EnableHorizontal( true )
  20. DermaList:EnableVerticalScrollbar( true )
  21.  
  22. datastream.Hook( "HolsteredWeapons", function( handler, id, encoded, decoded )
  23. local Icon = vgui.Create("SpawnIcon", DermaList)
  24. Icon:SetModel( decoded.model )
  25. Icon.OnMousePressed = function()
  26. DermaList:RemoveItem( Icon )
  27. datastream.StreamToServer( "SendWeaponClass", decoded )
  28. return false --return false to disable the pressing effect
  29. end
  30. Icon:SetToolTip( decoded.name )
  31. Icon:SizeToContents()
  32. DermaList:AddItem( Icon )
  33. end)
  34.  
  35. local button = vgui.Create( "DButton", DermaList )
  36. button:SetSize( 100, 30 )
  37. button:SetPos( 50, 30 )
  38. button:SetText( "Close" )
  39. button.DoClick = function()
  40. zc_isopen = nil
  41. DermaPanel:Close()
  42. end
  43. DermaList:AddItem( button )
  44. end
  45. end)
  46.  
  47. ///////////////////////////////////////////SERVERSIDE FILE 1/////////////////////////////////
  48.  
  49. hook.Add( "DoPlayerDeath", "RagmodCreateRagdoll", function( victim )
  50. if victim:Team() == 2 then
  51. if victim:GetActiveWeapon():IsValid() then
  52. victim:DropWeapon( victim:GetActiveWeapon() ) --Drop active weapon
  53. end
  54. end
  55. //snipped unrelated crap
  56. local ragModel = victim:GetModel()
  57. local ragPos = victim:GetPos()
  58. local ragAng = victim:GetAngles()
  59. local ragObj = ents.Create( "prop_ragdoll" )
  60. ragObj:SetModel( ragModel )
  61. //snipped unrelated crap
  62. ragObj:Spawn()
  63. //snipped unrelated crap
  64. ragObj.Name = victim:Nick()
  65. ragObj.Team = victim:Team()
  66. ragObj.holster = {}
  67. for k, v in pairs( victim:GetWeapons() ) do
  68. table.insert(ragObj.holster, v:GetClass() )
  69. end
  70. end)
  71.  
  72. //////////////////////////////////////////SERVERSIDE FILE 2////////////////////////////
  73.  
  74. function GM:KeyPress( ply, key )
  75. //snipped unrelated crap
  76. if key == IN_USE then
  77. if !ply:IsPlayer() then return false end
  78. if ply:Team() != 2 and ply:Team() != 3 then return false end
  79. local tr = ply:GetEyeTrace()
  80. if tr.Entity and tr.Entity.IsValid and tr.Entity:GetClass() == "prop_ragdoll" and tr.Entity:GetPos():Distance(ply:GetPos()) < 400 then
  81. local deadplayer = tr.Entity
  82. if ply:Team() == 2 then
  83. ply:PrintMessage( HUD_PRINTTALK, "Sorry, scavenging is currently in development, please wait for later versions. Derp you're a survivor." )
  84. elseif ply:Team() == 3 then
  85. ply:PrintMessage( HUD_PRINTTALK, "Sorry, scavenging is currently in development, please wait for later versions. Derp you're a zombie." )
  86. end
  87. umsg.Start("zc_usedragdoll", ply)
  88. umsg.End()
  89. print("Printing from server...")
  90. print("Weapons in the ragdoll before sent to client")
  91. for k, v in pairs( deadplayer.holster ) do
  92. print( zc_weapontables[v].class )
  93. print( zc_weapontables[v].name )
  94. print( zc_weapontables[v].model )
  95. local table
  96. datastream.StreamToClients( ply, "HolsteredWeapons", zc_weapontables[v] )
  97. end
  98. end
  99. end
  100. end
  101. datastream.Hook( "SendWeaponClass", function( ply, handler, id, encoded, decoded )///////////////CODE WITH PROBLEM////////////////////
  102. print( "The client clicked on a weapon, give it to him" )
  103. print( "Printing incoming table" )
  104. print( decoded.class .. "This is the weapon to give" )
  105. print( decoded.model .. "Just for lulz" )
  106. print( decoded.name .. "Just for shitz n gigglez...or not" )
  107. print( "Removing the weapon the client chose from the table" )
  108. if table.HasValue( deadplayer.holster, decoded.class ) then
  109. table.remove( deadplayer.holster[decoded.class] )
  110. ply:Give( decoded.class )
  111. ply:PrintMessage( HUD_PRINTTALK, "You have scavenged a " .. decoded.name )
  112. else
  113. ply:PrintMessage( HUD_PRINTTALK, "Sorry, that weapon was taken" )
  114. end
  115. end) ////////////////////CODE WITH PROBLEM////////////////////
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement