Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //////////////////////////////////////////////CLIENTSIDE/////////////////////////////////
- usermessage.Hook("zc_usedragdoll", function()
- if zc_isopen == nil then
- zc_isopen = 1
- local DermaPanel = vgui.Create( "DFrame" )
- DermaPanel:SetPos( 50,50 )
- DermaPanel:SetSize( 450, 450 )
- DermaPanel:SetTitle( "Scavenge!" )
- DermaPanel:SetVisible( true )
- DermaPanel:SetDraggable( true )
- DermaPanel:ShowCloseButton( false )
- DermaPanel:MakePopup()
- local DermaList = vgui.Create( "DPanelList", DermaPanel )
- DermaList:SetPos( 25,25 )
- DermaList:SetSize( 400, 400 )
- DermaList:SetSpacing( 5 )
- DermaList:EnableHorizontal( true )
- DermaList:EnableVerticalScrollbar( true )
- datastream.Hook( "HolsteredWeapons", function( handler, id, encoded, decoded )
- local Icon = vgui.Create("SpawnIcon", DermaList)
- Icon:SetModel( decoded.model )
- Icon.OnMousePressed = function()
- DermaList:RemoveItem( Icon )
- datastream.StreamToServer( "SendWeaponClass", decoded )
- return false --return false to disable the pressing effect
- end
- Icon:SetToolTip( decoded.name )
- Icon:SizeToContents()
- DermaList:AddItem( Icon )
- end)
- local button = vgui.Create( "DButton", DermaList )
- button:SetSize( 100, 30 )
- button:SetPos( 50, 30 )
- button:SetText( "Close" )
- button.DoClick = function()
- zc_isopen = nil
- DermaPanel:Close()
- end
- DermaList:AddItem( button )
- end
- end)
- ///////////////////////////////////////////SERVERSIDE FILE 1/////////////////////////////////
- hook.Add( "DoPlayerDeath", "RagmodCreateRagdoll", function( victim )
- if victim:Team() == 2 then
- if victim:GetActiveWeapon():IsValid() then
- victim:DropWeapon( victim:GetActiveWeapon() ) --Drop active weapon
- end
- end
- //snipped unrelated crap
- local ragModel = victim:GetModel()
- local ragPos = victim:GetPos()
- local ragAng = victim:GetAngles()
- local ragObj = ents.Create( "prop_ragdoll" )
- ragObj:SetModel( ragModel )
- //snipped unrelated crap
- ragObj:Spawn()
- //snipped unrelated crap
- ragObj.Name = victim:Nick()
- ragObj.Team = victim:Team()
- ragObj.holster = {}
- for k, v in pairs( victim:GetWeapons() ) do
- table.insert(ragObj.holster, v:GetClass() )
- end
- end)
- //////////////////////////////////////////SERVERSIDE FILE 2////////////////////////////
- function GM:KeyPress( ply, key )
- //snipped unrelated crap
- if key == IN_USE then
- if !ply:IsPlayer() then return false end
- if ply:Team() != 2 and ply:Team() != 3 then return false end
- local tr = ply:GetEyeTrace()
- if tr.Entity and tr.Entity.IsValid and tr.Entity:GetClass() == "prop_ragdoll" and tr.Entity:GetPos():Distance(ply:GetPos()) < 400 then
- local deadplayer = tr.Entity
- if ply:Team() == 2 then
- ply:PrintMessage( HUD_PRINTTALK, "Sorry, scavenging is currently in development, please wait for later versions. Derp you're a survivor." )
- elseif ply:Team() == 3 then
- ply:PrintMessage( HUD_PRINTTALK, "Sorry, scavenging is currently in development, please wait for later versions. Derp you're a zombie." )
- end
- umsg.Start("zc_usedragdoll", ply)
- umsg.End()
- print("Printing from server...")
- print("Weapons in the ragdoll before sent to client")
- for k, v in pairs( deadplayer.holster ) do
- print( zc_weapontables[v].class )
- print( zc_weapontables[v].name )
- print( zc_weapontables[v].model )
- local table
- datastream.StreamToClients( ply, "HolsteredWeapons", zc_weapontables[v] )
- end
- end
- end
- end
- datastream.Hook( "SendWeaponClass", function( ply, handler, id, encoded, decoded )///////////////CODE WITH PROBLEM////////////////////
- print( "The client clicked on a weapon, give it to him" )
- print( "Printing incoming table" )
- print( decoded.class .. "This is the weapon to give" )
- print( decoded.model .. "Just for lulz" )
- print( decoded.name .. "Just for shitz n gigglez...or not" )
- print( "Removing the weapon the client chose from the table" )
- if table.HasValue( deadplayer.holster, decoded.class ) then
- table.remove( deadplayer.holster[decoded.class] )
- ply:Give( decoded.class )
- ply:PrintMessage( HUD_PRINTTALK, "You have scavenged a " .. decoded.name )
- else
- ply:PrintMessage( HUD_PRINTTALK, "Sorry, that weapon was taken" )
- end
- end) ////////////////////CODE WITH PROBLEM////////////////////
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement