From 61cb61465f7f8eefd5e634229e2a17a28803d44f Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Fri, 22 Apr 2016 12:48:04 -0400 Subject: Moved meta-functions relateing to processes to player_functions.lua --- gamemode/chatcommands.lua | 6 ++-- gamemode/resources.lua | 69 ------------------------------------ gamemode/server/player_functions.lua | 64 +++++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 72 deletions(-) (limited to 'gamemode') diff --git a/gamemode/chatcommands.lua b/gamemode/chatcommands.lua index 54d4bba..9989054 100644 --- a/gamemode/chatcommands.lua +++ b/gamemode/chatcommands.lua @@ -75,7 +75,7 @@ CHATCMD.CCName = "gms_help" function CHATCMD:Run( ply, args ) ply:ConCommand( self.CCName ) -end +end GMS.RegisterChatCmd( CHATCMD ) @@ -90,7 +90,7 @@ CHATCMD.CCName = "gms_dropresources" function CHATCMD:Run( ply, args ) GAMEMODE.DropResource( ply, self.CCName, args ) -end +end GMS.RegisterChatCmd( CHATCMD ) @@ -427,7 +427,7 @@ function CHATCMD:Run( ply, args ) if ( !mahTribe ) then ply:SendMessage( "Something went wrong! Report this to admins: " .. ply:Team(), 3, Color( 200, 10, 10, 255 ) ) return end - ply:SendMessage( "Invitation sent!", 3, Color( 200, 200, 200, 255 ) ) + ply:SendMessage( "Invitation sent!", 3, Color( 200, 200, 200, 255 ) ) umsg.Start( "gms_invite", him ) umsg.String( mahTribe.name ) diff --git a/gamemode/resources.lua b/gamemode/resources.lua index 17179d8..16ccfcb 100644 --- a/gamemode/resources.lua +++ b/gamemode/resources.lua @@ -24,72 +24,3 @@ resource.AddFile( "sound/cough1.wav" ) resource.AddFile( "sound/cough2.wav" ) resource.AddFile( "sound/cough3.wav" ) resource.AddFile( "sound/cough4.wav" ) - - -/*------------------------ Models ------------------------*/ -/* -resource.AddFile( "models/weapons/v_fists.mdl" ) -resource.AddFile( "models/weapons/w_fists.mdl" ) -resource.AddFile( "models/weapons/v_shovel.mdl" ) -resource.AddFile( "models/weapons/w_shovel.mdl" ) -resource.AddFile( "models/weapons/v_copper_pickaxe.mdl" ) -resource.AddFile( "models/weapons/w_copper_pickaxe.mdl" ) -resource.AddFile( "models/weapons/v_iron_pickaxe.mdl" ) -resource.AddFile( "models/weapons/w_iron_pickaxe.mdl" ) -resource.AddFile( "models/weapons/v_stone_pickaxe.mdl" ) -resource.AddFile( "models/weapons/w_stone_pickaxe.mdl" ) -resource.AddFile( "models/weapons/v_copper_hatchet.mdl" ) -resource.AddFile( "models/weapons/v_iron_hatchet.mdl" ) -resource.AddFile( "models/weapons/v_stone_hatchet.mdl" ) -resource.AddFile( "models/weapons/w_copper_hatchet.mdl" ) -resource.AddFile( "models/weapons/w_iron_hatchet.mdl" ) -resource.AddFile( "models/weapons/w_stone_hatchet.mdl" ) - -resource.AddFile( "models/gm_forest/tree_oak1.mdl" ) - -/*------------------------ Materials ------------------------*/ -/* -resource.AddFile( "materials/models/weapons/shovel/shovel1.vmt" ) -resource.AddFile( "materials/models/weapons/shovel/shovel1.vtf" ) -resource.AddFile( "materials/models/weapons/shovel/shovel1_n.vtf" ) -resource.AddFile( "materials/models/weapons/shovel/shovel2.vmt" ) -resource.AddFile( "materials/models/weapons/shovel/shovel2.vtf" ) -resource.AddFile( "materials/models/weapons/shovel/shovel2_n.vtf" ) -resource.AddFile( "materials/models/weapons/shovel/shovel3.vmt" ) -resource.AddFile( "materials/models/weapons/shovel/shovel3.vtf" ) -resource.AddFile( "materials/models/weapons/shovel/shovel3_n.vtf" ) -resource.AddFile( "materials/models/weapons/pickaxe/copper/copper.vtf" ) -resource.AddFile( "materials/models/weapons/pickaxe/copper/copper_n.vtf" ) -resource.AddFile( "materials/models/weapons/pickaxe/copper/pickaxe01.vmt" ) -resource.AddFile( "materials/models/weapons/pickaxe/stone/pickaxe01.vmt" ) -resource.AddFile( "materials/models/weapons/pickaxe/stone/stone.vtf" ) -resource.AddFile( "materials/models/weapons/pickaxe/stone/stone_n.vtf" ) -resource.AddFile( "materials/models/weapons/pickaxe/iron/iron.vtf" ) -resource.AddFile( "materials/models/weapons/pickaxe/iron/iron_n.vtf" ) -resource.AddFile( "materials/models/weapons/pickaxe/iron/pickaxe01.vmt" ) -resource.AddFile( "materials/models/weapons/hatchet/copper/axe.vmt" ) -resource.AddFile( "materials/models/weapons/hatchet/copper/Copper.vtf" ) -resource.AddFile( "materials/models/weapons/hatchet/copper/Copper_n.vtf" ) -resource.AddFile( "materials/models/weapons/hatchet/stone/axe.vmt" ) -resource.AddFile( "materials/models/weapons/hatchet/stone/stone.vtf" ) -resource.AddFile( "materials/models/weapons/hatchet/stone/stone_n.vtf" ) -resource.AddFile( "materials/models/weapons/hatchet/iron/axe.vmt" ) -resource.AddFile( "materials/models/weapons/hatchet/iron/iron.vtf" ) -resource.AddFile( "materials/models/weapons/hatchet/iron/iron_n.vtf" ) -resource.AddFile( "materials/models/weapons/hands.vmt" ) -resource.AddFile( "materials/models/weapons/hands.vtf" ) -resource.AddFile( "materials/models/weapons/hands_normal.vtf" ) - -resource.AddFile( "materials/gm_forest/oak_brk.vmt" ) -resource.AddFile( "materials/gm_forest/brg_eik_brn2.vmt" ) -resource.AddFile( "materials/gm_forest/brg_eik_brn2.vtf" ) - -/*------------------------ Sounds ------------------------*/ -/* -resource.AddFile( "sound/citizen_beaten1.wav" ) -resource.AddFile( "sound/citizen_beaten4.wav" ) -resource.AddFile( "sound/citizen_beaten5.wav" ) -resource.AddFile( "sound/cough1.wav" ) -resource.AddFile( "sound/cough2.wav" ) -resource.AddFile( "sound/cough3.wav" ) -resource.AddFile( "sound/cough4.wav" ) diff --git a/gamemode/server/player_functions.lua b/gamemode/server/player_functions.lua index 093b20a..b4cc7c0 100644 --- a/gamemode/server/player_functions.lua +++ b/gamemode/server/player_functions.lua @@ -588,3 +588,67 @@ function PlayerMeta:SaveCharacter() file.Write( "gmstranded/saves/" .. self:UniqueID() .. ".txt", util.TableToJSON( tbl ) ) self:SendMessage( "Saved character!", 3, Color( 255, 255, 255 ) ) end + +function PlayerMeta:DoProcess( name, time, data ) + if ( self.InProcess ) then self:SendMessage( "You can't do this much at once.", 3, Color( 200, 0, 0, 255 ) ) return end + if ( self:GetNWBool( "AFK" ) ) then self:SendMessage( "You can't do this while afk.", 3, Color( 200, 0, 0, 255 ) ) return end + if ( self:GetNWBool( "Sleeping" ) ) then self:SendMessage( "You can't do this while sleeping.", 3, Color( 200, 0, 0, 255 ) ) return end + + self.ProcessTable = table.Merge( table.Copy( GMS.Processes.BaseProcess ), table.Copy( GMS.Processes[ name ] ) ) + self.ProcessTable.Owner = self + self.ProcessTable.Time = time + self.ProcessTable.StartTime = CurTime() + self.ProcessTable.TimerID = self:UniqueID() + if ( data ) then self.ProcessTable.Data = data end + + self.InProcess = true + if ( self.ProcessTable.Freeze ) then self:Freeze( true ) end + if ( self.ProcessTable.OnStart ) then self.ProcessTable:OnStart() end + + table.insert( GAMEMODE.ProcessThinkHookTable, self.ProcessTable ) + + timer.Create( "GMS_ProcessTimer_" .. self:UniqueID(), time, 1, function() self:StopProcess() end ) +end + +function PlayerMeta:MakeProcessBar( name, time, cancel ) + umsg.Start( "gms_MakeProcessBar", self ) + umsg.String( name ) + umsg.Short( time ) + umsg.Bool( cancel ) + umsg.End() +end + +function PlayerMeta:StopProcessBar() + umsg.Start( "gms_StopProcessBar", self ) + umsg.End() +end + +function PlayerMeta:StopProcess() + if ( !IsValid( self ) or self.ProcessTable == nil ) then return end + + local bool = self.ProcessTable:BaseStop() + if ( self.ProcessTable.Freeze ) then self:Freeze( false ) end + if ( self.ProcessTable.OnStop ) then self.ProcessTable:OnStop() end + if ( self.ProcessTable.Think ) then GAMEMODE:RemoveProcessThink( self.ProcessTable ) end + + self.InProcess = false + self.ProcessTable = nil +end + +function PlayerMeta:CancelProcess() + if ( !self.InProcess ) then return end + + local v = self.ProcessTable + if ( !v.Cancel ) then return end + + if ( v.Owner and v.Owner != NULL and IsValid( v.Owner ) ) then + v.Owner:Freeze( false ) + v.Owner:StopProcessBar() + v.Owner.InProcess = false + v.Owner:SendMessage( "Cancelled.", 3, Color( 200, 0, 0, 255 ) ) + end + + v.IsStopped = true + timer.Destroy( "GMS_ProcessTimer_" .. v.TimerID ) + GAMEMODE:RemoveProcessThink( v ) +end -- cgit v1.2.3-70-g09d2