--This file holds a bunch of common functions that happen in items. They're seperated out here so that they're easy to change if there's a bug somewhere. --Freezes the player, creates the loading bar, and calls ondone when the timer is up. function startProcessGeneric(player, string, time, ondone) if(player.InProcess) then self.Owner:SendMessage("You can't do that much at once!", 3, Color(255, 255, 255, 255)) return end player.InProcess = true player:Freeze(true) player:MakeProcessBar( string, time, false ) timer.Create( "process", time, 1, function() player:Freeze(false) player.InProcess = false player:StopProcessBar() ondone() end) end function genericMakeDroppable(tbl) local drop1 = function(player) genericDropResource(player,tbl.Name,1) end local dropall = function(player) PrintTable(Resources) print("Ammount:" .. Resources[tbl.Name]) genericDropResource(player,tbl.Name,Resources[tbl.Name]) end local dropx = function(player) if(SERVER) then return end local frame = vgui.Create( "DFrame" ) frame:SetSize( 400, 200 ) frame:Center() frame:MakePopup() local TextEntry = vgui.Create( "DTextEntry", frame ) -- create the form as a child of frame TextEntry:SetPos( 25, 50 ) TextEntry:SetSize( 75, 85 ) TextEntry:SetText( "Sample String" ) TextEntry.OnEnter = function( self ) genericDropResource(player,tbl.Name,self:GetValue()) end end if(tbl.Actions == nil) then tbl.Actions = {} end if(tbl.Actions["Drop"] == nil) then tbl.Actions["Drop"] = {} end tbl.Actions["Drop"]["Drop 1"] = drop1 tbl.Actions["Drop"]["Drop all"] = dropall tbl.Actions["Drop"]["Drop X"] = dropx end if(SERVER) then util.AddNetworkString( "gms_dropresources" ) end function genericDropResource(player, resource, ammount) if(CLIENT) then net.Start("gms_dropresources") net.WriteString(resource) net.WriteInt(ammount,GMS.NETINT_BITCOUNT) net.SendToServer() end if(SERVER) then if(player.Resources[resource] < ammount) then player:SendMessage("You don't have that many to drop!", 3, Color(255, 255, 255, 255)) return end local res = player.Resources[resource] if ( ammount > res ) then ammount = res end player:DropResource( resource, ammount ) player:DecResource( resource, ammount ) end end net.Receive( "gms_dropresources", function(len,pl) local resourcename = net.ReadString() local resourcenum = net.ReadInt(GMS.NETINT_BITCOUNT) print("resourcename:" .. resourcename) print("resourcenum:" .. resourcenum) genericDropResource(pl,resourcename,resourcenum) end)