diff options
Diffstat (limited to 'ftp_gmstranded/entities/weapons/gms_inventory.lua')
| -rw-r--r-- | ftp_gmstranded/entities/weapons/gms_inventory.lua | 277 |
1 files changed, 0 insertions, 277 deletions
diff --git a/ftp_gmstranded/entities/weapons/gms_inventory.lua b/ftp_gmstranded/entities/weapons/gms_inventory.lua deleted file mode 100644 index 15aaa27..0000000 --- a/ftp_gmstranded/entities/weapons/gms_inventory.lua +++ /dev/null @@ -1,277 +0,0 @@ - -AddCSLuaFile() - -SWEP.Slot = 2 -SWEP.SlotPos = 5 - -SWEP.Base = "gms_base_weapon" -SWEP.PrintName = "Inventory" -SWEP.ViewModel = "models/Weapons/v_hands.mdl" -SWEP.WorldModel = "models/props_c17/tools_wrench01a.mdl" - -SWEP.Purpose = "Lets the user keep structures on them for a certain amount of time." -SWEP.Instructions = "Left click on a structure to pick up a structure." - -SWEP.HoldType = "knife" - -SWEP.Structures = {} -SWEP.StructureModels = {} - -local active = false - -// setting time to 0 will make it unlimited - -local dSlot = 4 -local dTime = 24 - -group = { - - { - - rank = "superadmin", - slot = 8, - time = 0, - }, - - { - - rank = "admin", - slot = 8, - time = 0, - - }, - - -} - -SWEP.FixWorldModel = true -SWEP.FixWorldModelPos = Vector( -1.5, 1, -3 ) -SWEP.FixWorldModelAng = Angle( 90, 90, 0 ) -SWEP.FixWorldModelScale = 1 - -local strTBL = {} -local mdlTBL = {} - -if (SERVER) then - -util.AddNetworkString('invStructures') -util.AddNetworkString('createEntity') - -net.Receive('createEntity', function(len, pl) - - strTBL = net.ReadTable() - local slot = net.ReadInt(32) - mdlTBL = net.ReadTable() - - local tr = pl:TraceFromEyes( 200 ) - local loc = tr.HitPos + Vector( 0, 0, 10 ) - - - - - mbEnt=ents.Create(strTBL[slot]) - - if ( strTBL[slot] == "gms_fridge" ) then loc = loc + (mbEnt:GetUp() * 50) else mbEnt:DropToGround() end - - mbEnt:SetModel(mdlTBL[slot]) - mbEnt:SetPos(loc) - mbEnt:Spawn() - SPropProtection.PlayerMakePropOwner( pl, mbEnt ) - - pl:PrintMessage(HUD_PRINTTALK, strTBL[slot]) - pl:PrintMessage(HUD_PRINTTALK, slot) - pl:PrintMessage(HUD_PRINTTALK, mdlTBL[slot]) - - table.remove(strTBL,slot) - table.remove(mdlTBL, slot) - - - -end) - -function SWEP:Think() - - self.Structures = strTBL - self.StructureModels = mdlTBL - -end - -function SWEP:PrimaryAttack() - - self.Structures = strTBL - - local ent = self.Owner:GetEyeTrace().Entity - if ( SPropProtection.PlayerIsPropOwner( self.Owner, ent ) ) then - table.insert(self.Structures, ent:GetClass()) - table.insert(self.StructureModels, ent:GetModel()) - ent:Remove() - - net.Start('invStructures') - - net.WriteTable(self.Structures) - net.WriteTable(self.StructureModels) - - net.Send(self.Owner) - - end - -end - - -end - - - -if (CLIENT) then - -local StructuresTbl = strTBL -local StructureModelsTbl = mdlTBL - -function SWEP:SecondaryAttack() - - net.Receive('invStructures', function(len, pl) - StructuresTbl = net.ReadTable() - StructureModelsTbl = net.ReadTable() - //PrintTable(StructuresTbl) - end) - - if ( active == false ) then - local df = vgui.Create("invPanel") - active = true - end - -end - - - -local PANEL = {} - -function PANEL:Init() - self:SetTitle("") - - rowAmount = 1 - - for k,v in pairs( group ) do - if (LocalPlayer():IsUserGroup(v['rank'])) then - dSlot = v['slot'] - dTime = v['time'] - end - - end - - for i=1,dSlot do - if (i % 5 == 0) then rowAmount=rowAmount+1 end - end - - OffSet = 5 - - self:SetSize(400 + (OffSet*5),(rowAmount*100) + (OffSet*(rowAmount+1)) + 20) - self:SetPos((ScrW()/2)-(self:GetWide()/2),ScrH()-self:GetTall()) - self:ShowCloseButton(true) - gui.EnableScreenClicker(true) - - - row = 1 - col = 1 - - - - for i=1,dSlot do - local button = vgui.Create("slotPanel", self) - - print(StructuresTbl[i]) - - if (StructuresTbl[i] != nil and StructureModelsTbl[i] != nil) then - - - local icon = vgui.Create( "DModelPanel", button ) - icon:SetSize( 100, 150 ); - icon:SetCamPos( Vector( 50,50,50 ) ); - icon:SetLookAt( Vector( 0, 0, -40 ) ); - //icon:SetLookAt( Vector( right, left, up/down ) ); - icon:SetModel( StructureModelsTbl[i] ) - icon:SetText(tostring(StructuresTbl[i])) - - icon.DoClick = function() - - local mb = DermaMenu() - - mb:AddOption("Drop", function() - - net.Start('createEntity') - - net.WriteTable( StructuresTbl ) - net.WriteInt( i, 32 ) - net.WriteTable( StructureModelsTbl ) - - net.SendToServer() - - table.remove( StructuresTbl, i ) - table.remove( StructureModelsTbl, i ) - - self:Close() - local df = vgui.Create("invPanel") - active = true - - end) - - mb:Open() - - end - end - - - if (i/4 <= col) then - - button:SetPos((row-1)*button:GetWide() + (OffSet*row),(col-1)*button:GetTall() + (OffSet*col) + 20) - row=row+1 - - else - - row=1 - col=col+1 - button:SetPos((row-1)*button:GetWide() + (OffSet*row),(col-1)*button:GetTall() + (OffSet*col) + 20) - row=row+1 - - end - end - -end - -function PANEL:Paint(w,h) - if (!LocalPlayer():HasWeapon("gms_inventory")) then return end - if (LocalPlayer():GetActiveWeapon():GetClass() != "gms_inventory") then - self:Close() - end - - draw.RoundedBox( 0, 0, 0, w, h, Color( 48, 48, 48, 255 ) ) - -end - -function PANEL:Close() - active = false - gui.EnableScreenClicker( false ) - self:Remove() -end - -vgui.Register("invPanel", PANEL, "DFrame") - -local PANEL = {} - -function PANEL:Init() - - self:SetSize(100,100) - self:SetPos(0,0) - self:SetText("") - -end - -function PANEL:Paint(w,h) - if (!LocalPlayer():HasWeapon("gms_inventory")) then return end - draw.RoundedBox( 0, 0, 0, w, h, Color( 24, 24, 24, 255 ) ) - -end - -vgui.Register("slotPanel", PANEL, "DButton") - -end
\ No newline at end of file |
