diff options
| -rw-r--r-- | gamemode/client/hud.lua | 1 | ||||
| -rw-r--r-- | gamemode/init.lua | 227 | ||||
| -rw-r--r-- | gamemode/init_utility.lua | 27 | ||||
| -rw-r--r-- | gamemode/server/tribes.lua | 10 |
4 files changed, 179 insertions, 86 deletions
diff --git a/gamemode/client/hud.lua b/gamemode/client/hud.lua new file mode 100644 index 0000000..ff6e224 --- /dev/null +++ b/gamemode/client/hud.lua @@ -0,0 +1 @@ +--print("Hello, from /gamemode/client/hud.lua!") diff --git a/gamemode/init.lua b/gamemode/init.lua index 5426d99..0dda971 100644 --- a/gamemode/init.lua +++ b/gamemode/init.lua @@ -1,4 +1,7 @@ + + + -- Send clientside files AddCSLuaFile( "shared.lua" ) AddCSLuaFile( "cl_init.lua" ) @@ -19,15 +22,24 @@ include( "processes.lua" ) include( "chatcommands.lua" ) -- include( "resources.lua" ) +GM.GAMEMODE_FOLDER_NAME = "gmstranded" +include( "init_utility.lua") + +AddCSLuaFolder("client",false) + +includeFolder("server",false) + --Vars GM.NextSaved = 0 GM.NextLoaded = 0 + --Locals local PlayerMeta = FindMetaTable( "Player" ) local EntityMeta = FindMetaTable( "Entity" ) --Tribes table +/* Moved to /server/tribes.lua if ( !GM.Tribes ) then GM.Tribes = GM.Tribes or {} table.insert( GM.Tribes, { name = "The Stranded", color = Color( 200, 200, 0 ), password = false } ) @@ -37,6 +49,7 @@ if ( !GM.Tribes ) then table.insert( GM.Tribes, { name = "The Dynamics", color = Color( 0, 72, 255 ), password = false } ) table.insert( GM.Tribes, { name = "Scavengers", color = Color( 8, 255, 0 ), password = false } ) end +*/ GM.AntlionBarrowSpawns = {} GM.AntlionBarrowSpawns[ "gm_construct" ] = { Vector( -4321.8149, -2551.3449, 257.5130 ) } @@ -59,12 +72,12 @@ Vector( 2804.810303, 12146.677734, -9125.259766 ), GM.TreeSpawns = {} -GM.TreeSpawns[ "gms_coastal_outlands" ] = { +GM.TreeSpawns[ "gms_coastal_outlands" ] = { // The third coordinate is the height coordinate -// Always subtract 70 to the height coord if it is positive so that the tree will be touching the floor +// Always subtract 70 to the height coord if it is positive so that the tree will be touching the floor -Vector( 1462.160522, -3664.370361, -10941.564453 ), +Vector( 1462.160522, -3664.370361, -10941.564453 ), Vector( 3718.633545, -1710.644409, -11269.974609 ), Vector( 3159.402588, 145.593597, -11045.797852 ), Vector( 2519.847168, -547.534180, -11161.646484 ), @@ -112,16 +125,16 @@ net.Receive('givePlayerWeapon', function(len, ply) local wepSlot = net.ReadInt(32) local weptbl = ply:GetEyeTrace().Entity.deathWeapons table.remove(weptbl, wepSlot) - + ply:Give(wepToGive) - - - + + + end) --Give player resource from grave net.Receive('givePlayerResource', function(len, ply) - + local ResToGive = net.ReadString() local Amount = net.ReadInt(32) local resSlot = net.ReadInt(32) @@ -129,19 +142,19 @@ net.Receive('givePlayerResource', function(len, ply) local tbl1 = string.Split(restbl[resSlot], " ") local tbl2 = string.Split(tbl1[2], "x") local amt = tbl2[2] - + ply:IncResource( ResToGive, Amount ) - + if (amt - Amount <= 0) then - + table.remove(restbl, resSlot) else amt = amt - Amount restbl[resSlot] = tbl1[1] .. " x" .. amt - + end - - + + end) -- Custom anlion barrow auto placement @@ -154,12 +167,12 @@ hook.Add( "InitPostEntity", "gms_custom_antspawns", function() ent.GMSAutoSpawned = true ent:SetNetworkedString( "Owner", "World" ) end - + end ) -- Custom tree auto placement hook.Add( "InitPostEntity", "gms_custom_treespawns", function() - + if ( !GAMEMODE.TreeSpawns[ game.GetMap() ] ) then return end for id, pos in pairs( GAMEMODE.TreeSpawns[ game.GetMap() ] ) do local ent = ents.Create( "gms_tree" ) @@ -343,7 +356,7 @@ end function PlayerMeta:SetResource( resource, int ) resource = string.Capitalize( resource ) if ( !self.Resources[resource] ) then self.Resources[resource] = 0 end - + self.Resources[resource] = int @@ -391,7 +404,7 @@ function PlayerMeta:DecResource( resource, int ) self.Power = math.min( self.Power, maxPow ) self:UpdateNeeds() end - + umsg.Start( "gms_SetResource", self ) umsg.String( resource ) umsg.Short( self:GetResource( resource ) ) @@ -692,7 +705,7 @@ function PlayerMeta:Sleep() if ( !tr.HitWorld and !tr.HitNonWorld ) then self.NeedShelter = true end - + self:EmitSound( "stranded/start_sleeping.wav" ) end @@ -1082,7 +1095,7 @@ concommand.Add( "gms_admin_populatearea", function( ply, cmd, args ) local info = {} info.Amount = Amount - if ( Amount > 200 ) then + if ( Amount > 200 ) then ply:SendMessage( "Auto-capped at 200 props.", 3, Color( 200, 0, 0, 255 ) ) info.Amount = 200 end @@ -1226,7 +1239,7 @@ function GM.ADropResource( ply, cmd, args ) if ( tonumber( args[2] ) <= 0 ) then ply:SendMessage( "No zeros/negatives!", 3, Color( 200, 0, 0, 255 ) ) return end local int = tonumber( args[2] ) - local Type = args[1] + local Type = args[1] ply:DropResource( Type, int ) ply:SendMessage( "Dropped " .. string.Replace( Type, "_", " " ) .. " ( " .. int .. "x )", 3, Color( 10, 200, 10, 255 ) ) @@ -1287,10 +1300,51 @@ concommand.Add( "gms_steal", function( ply, cmd, args ) ply:DoProcess( "Steal", time, { Ent = ent } ) end ) +/*Alright, let's refactor this shit*/ + +//First, make a table of all the stuff we need to make this generic +// {skill, resourcename, action, time, you-need-a string, command} +GM.Plantables = { + {nil, "Melon_Seeds", "PlantMelon", 3, "a melon seed", "gms_plantmelon"}, + {nil, "Banana_Seeds", "PlantBanana", 3, "a banana seed", "gms_plantbanana"}, + {nil, "Orange_Seeds", "PlantOrange", 3, "an orange seed", "gms_plantorange"}, + {"Grain_Planting", "Grain_Seeds", 3, "PlantGrain", "a grain seed", "gms_plantgrain"}, + {nil, "Berries", "PlantBush", 3, "a berry", "gms_plantbush"}, + {"Sprout_Planting", "Sprouts", 5, "PlantTree", "a sprout", "gms_planttree"}, +} + +for k,v in pairs(GM.Plantables) do + concommand.Add(v[6], function(ply,cmd,args) + //Check to make sure they have the appropriate level + if(v[1] != nil) then + if(!ply:HasUnlock(v[1])) then + ply:SendMessage("You need more planting skill.",3,Color (200,0,0,255)) + return + end + end + local tr = ply:TraceFromEyes(150) + if(!tr.HitWorld) then + ply:SendMessage( "Aim at the ground to plant.", 3, Color( 200, 0, 0, 255 ) ) + return + end + local trm = tr.MatType + if( (!(trm == MAT_DIRT) and !(trm == MAT_GRASS) and !(trm == MAT_SAND)) or (GMS.IsInWater)) then + ply:SendMessage( "You cannot plant on this terrain.", 3, Color( 200, 0, 0, 255 ) ) + return + end + if(ply:GetResource(v[2]) == 0) then + ply:SendMessage( "You need " .. v[5] .. ".", 3, Color( 200, 0, 0, 255 ) ) + return + end + ply:DoProcess( v[3], v[4], { Pos = tr.HitPos } ) + end) +end + +/* Refactored, see above function GM.PlantMelon( ply, cmd, args ) - if ( ply:GetNWInt( "plants" ) >= GetConVarNumber( "gms_PlantLimit" ) ) then + if ( ply:GetNWInt( "plants" ) >= GetConVarNumber( "gms_PlantLimit" ) ) then ply:SendMessage( "You have hit the plant limit.", 3, Color( 200, 0, 0, 255 ) ) - return + return end local tr = ply:TraceFromEyes( 150 ) @@ -1433,7 +1487,7 @@ function GM.PlantTree( ply, cmd, args ) if ( !ply:HasUnlock( "Sprout_Planting" ) ) then ply:SendMessage( "You need more planting skill.", 3, Color( 200, 0, 0, 255 ) ) return end local tr = ply:TraceFromEyes( 150 ) - if ( tr.HitWorld ) then + if ( tr.HitWorld ) then if ( ( tr.MatType == MAT_DIRT or tr.MatType == MAT_GRASS or tr.MatType == MAT_SAND ) and !GMS.IsInWater( tr.HitPos ) ) then if ( ply:GetResource( "Sprouts" ) >= 1 ) then ply:DoProcess( "PlantTree", 5, { Pos = tr.HitPos } ) @@ -1448,6 +1502,7 @@ function GM.PlantTree( ply, cmd, args ) end end concommand.Add( "gms_planttree", GM.PlantTree ) +*/ function GM.DrinkFromBottle( ply, cmd, args ) if ( ply:GetResource( "Water_Bottles" ) < 1 ) then ply:SendMessage( "You need a water bottle.", 3, Color( 200, 0, 0, 255 ) ) return end @@ -1544,7 +1599,7 @@ function GM.TakeResource( ply, cmd, args ) if ( totake >= num ) then totake = num end if ( room < totake ) then totake = room end ent.Resources[ res ] = num - totake - ent:SetResPackInfo( res, ent.Resources[ res ] ) + ent:SetResPackInfo( res, ent.Resources[ res ] ) if ( ent.Resources[ res ] <= 0 ) then ent.Resources[ res ] = nil end ply:IncResource( res, totake ) @@ -1559,7 +1614,7 @@ function GM.TakeResource( ply, cmd, args ) for res, num in pairs( ent.Resources ) do if ( res == args[ 1 ] ) then ent.Resources[ res ] = num - 1 - ent:SetResPackInfo( res, ent.Resources[ res ] ) + ent:SetResPackInfo( res, ent.Resources[ res ] ) if ( ent.Resources[ res ] <= 0 ) then ent.Resources[ res ] = nil end local food = ents.Create( "gms_food" ) @@ -1569,7 +1624,7 @@ function GM.TakeResource( ply, cmd, args ) food.Name = res food:Spawn() food:SetFoodInfo( res ) - + timer.Simple( 300, function( food ) if ( IsValid( food ) ) then food:Fadeout( 2 ) end end, food ) end end @@ -1673,7 +1728,7 @@ concommand.Add( "gms_MakeCombination", function( ply, cmd, args ) local timecount = 1 for k, v in pairs( data.Cost ) do timecount = timecount + v - end + end local time = timecount * 0.3 if ( tbl.SwepClass != nil ) then @@ -1696,14 +1751,14 @@ concommand.Add( "gms_MakeCombination", function( ply, cmd, args ) local timecount = 1 for k, v in pairs( data.Cost ) do timecount = timecount + v - end + end local time = timecount * 0.3 local smelt = false for r,n in pairs( data.Res ) do if ( r == "Iron" or r == "Copper" ) then smelt = true end end - + if ( tbl.SwepClass != nil ) then data.Class = tbl.SwepClass ply:DoProcess( "MakeWeapon", time, data ) @@ -1718,7 +1773,7 @@ concommand.Add( "gms_MakeCombination", function( ply, cmd, args ) data.Name = tbl.Name data.Class = tbl.SwepClass data.Cost = table.Copy( tbl.Req ) - + local time = 10 if ( ply:GetActiveWeapon():GetClass() == "gms_wrench" ) then time = 7 end time = math.max( time - math.floor( math.max( ply:GetSkill( "Weapon_Crafting" ) - 8, 0 ) / 4 ), 4 ) @@ -1766,8 +1821,8 @@ concommand.Add( "gms_MakeCombination", function( ply, cmd, args ) local timecount = 1 for k, v in pairs( data.Cost ) do timecount = timecount + v - end - + end + local time = timecount * 0.5 time = math.max( time - math.floor( ply:GetSkill( "Smelting" ) / 5 ), math.max( timecount * 0.25, 2 ) ) @@ -1786,7 +1841,7 @@ concommand.Add( "gms_MakeCombination", function( ply, cmd, args ) local timecount = 1 for k, v in pairs( data.Cost ) do timecount = timecount + v - end + end local time = timecount * 0.6 time = math.max( time - math.floor( ply:GetSkill( "Smelting" ) / 5 ), math.max( timecount * 0.3, 2 ) ) @@ -1805,7 +1860,7 @@ concommand.Add( "gms_MakeCombination", function( ply, cmd, args ) local timecount = 1 for k, v in pairs( data.Cost ) do timecount = timecount + v - end + end local time = timecount * 0.7 time = math.max( time - math.floor( ply:GetSkill( "Smelting" ) / 5 ), math.max( timecount * 0.35, 2 ) ) @@ -1824,7 +1879,7 @@ concommand.Add( "gms_MakeCombination", function( ply, cmd, args ) local timecount = 1 for k, v in pairs( data.Cost ) do timecount = timecount + v - end + end local time = timecount * 0.7 time = math.max( time - math.floor( ply:GetSkill( "Smelting" ) / 5 ), math.max( timecount * 0.35, 2 ) ) @@ -1843,7 +1898,7 @@ concommand.Add( "gms_MakeCombination", function( ply, cmd, args ) local timecount = 1 for k, v in pairs( data.Cost ) do timecount = timecount + v - end + end local time = timecount * 0.7 time = math.max( time - math.floor( ply:GetSkill( "Smelting" ) / 5 ), math.max( timecount * 0.35, 2 ) ) @@ -1862,7 +1917,7 @@ concommand.Add( "gms_MakeCombination", function( ply, cmd, args ) local timecount = 1 for k, v in pairs( data.Cost ) do timecount = timecount + v - end + end local time = timecount * 0.7 time = math.max( time - math.floor( ply:GetSkill( "Smelting" ) / 5 ), math.max( timecount * 0.35, 2 ) ) @@ -1881,7 +1936,7 @@ concommand.Add( "gms_MakeCombination", function( ply, cmd, args ) local timecount = 1 for k, v in pairs( data.Cost ) do timecount = timecount + v - end + end local time = timecount * 0.1 time = math.max( time - math.floor( ply:GetSkill( "Smelting" ) / 5 ), math.max( timecount * 0.35, 2 ) ) @@ -1900,12 +1955,12 @@ concommand.Add( "gms_MakeCombination", function( ply, cmd, args ) local timecount = 1 for k, v in pairs( data.Cost ) do timecount = timecount + v - end + end local time = timecount * 0.5 time = math.max( time - math.floor( ply:GetSkill( "Smelting" ) / 5 ), math.max( timecount * 0.35, 2 ) ) - - + + ply:DoProcess( "Smelt", time, data ) elseif ( group == "gms_mithrilfactory") then local data = {} @@ -1921,15 +1976,15 @@ concommand.Add( "gms_MakeCombination", function( ply, cmd, args ) local timecount = 1 for k, v in pairs( data.Cost ) do timecount = timecount + v - end + end local time = timecount * 0.2 time = math.max( time - math.floor( ply:GetSkill( "Smelting" ) / 5 ), math.max( timecount * 0.20, 2 ) ) - - - - - - + + + + + + ply:DoProcess( "Smelt", time, data ) elseif ( group == "gms_grindingstone" ) then local data = {} @@ -1940,7 +1995,7 @@ concommand.Add( "gms_MakeCombination", function( ply, cmd, args ) for r, n in pairs( sourcetable.Results ) do if ( r == "Flour" ) then sourcetable.Results[r] = math.floor( n * 0.6 ) end end - + data.Res = sourcetable.Results data.Cost = table.Copy( sourcetable.Req ) else @@ -1950,7 +2005,7 @@ concommand.Add( "gms_MakeCombination", function( ply, cmd, args ) local timecount = 1 for k, v in pairs( data.Cost ) do timecount = timecount + v - end + end local time = timecount * 0.75 ply:DoProcess( "Crush", time, data ) @@ -2056,7 +2111,7 @@ function GM:PlayerInitialSpawn( ply ) for k, v in pairs( tbl["experience"] ) do ply:SetXP( k, v ) end end - /*if ( tbl["unlocks"] ) then + /*if ( tbl["unlocks"] ) then for k, v in pairs( tbl["unlocks"] ) do ply.FeatureUnlocks[ k ] = v end end*/ @@ -2101,7 +2156,7 @@ function GM:PlayerInitialSpawn( ply ) umsg.Short( id ) umsg.String( t.name ) umsg.Vector( Vector( t.color.r, t.color.g, t.color.b ) ) - if ( t.password == false ) then + if ( t.password == false ) then umsg.Bool( false ) else umsg.Bool( true ) @@ -2177,7 +2232,7 @@ function GM:PlayerSelectSpawn( pl ) local count = table.Count( self.SpawnPoints ) if ( count == 0 ) then MsgN( "[PlayerSelectSpawn] Error! No spawn points!" ) - return nil + return nil end local ChosenSpawnPoint = nil @@ -2297,17 +2352,17 @@ hook.Add( "PlayerDeath", "Death", function( ply ) // Creates the gravestone local grave = ents.Create("gms_gravestone") - + grave:SetPos( Vector( ply:GetPos().x, ply:GetPos().y, ply:GetPos().z+18 ) ) - + grave:Spawn() grave:SetplName(ply:Nick()) - + grave:SetNetworkedString( "Owner", "Everyone" ) wepstbl = {} restbl = {} - + for _, v in pairs( ply:GetWeapons() ) do if ( !table.HasValue( GMS.NonDropWeapons, v:GetClass() ) && GetConVarNumber( "gms_AllTools" ) != 1 ) then //ply:DropWeapon( v ) @@ -2315,25 +2370,25 @@ hook.Add( "PlayerDeath", "Death", function( ply ) SPropProtection.PlayerMakePropOwner( ply, v ) end end - + for _, v in pairs(ply.Resources) do - + num1 = v * 0.1 num2 = v - math.Round(num1) - + if (num2 > 0) then - + table.insert(restbl, _.." x"..num2) ply:DecResource(_,v) - + end - - - + + + end - + ply.Resources = {} - + grave.deathWeapons = wepstbl grave.deathResources = restbl @@ -2568,7 +2623,7 @@ end function GM:PlayerSpawnVehicle( ply, model, vname, vtable ) return false end - + /*------------------------ Needs ------------------------*/ timer.Create( "GMS.SubtractNeeds", 3, 0, function() @@ -2619,7 +2674,7 @@ timer.Create( "GMS.SubtractNeeds", 3, 0, function() end else if ( ply.Oxygen < 1000 ) then ply.Oxygen = math.min( ply.Oxygen + 100, 1000 ) end - end + end // Flashlight if ( ply:FlashlightIsOn() ) then @@ -2651,7 +2706,7 @@ timer.Create( "GMS.SubtractNeeds", 3, 0, function() for k, v in pairs( player.GetAll() ) do v:SendMessage( ply:Nick() .. " didn't survive.", 3, Color( 170, 0, 0, 255 ) ) end end end - + if ( ply.Oxygen <= 0 ) then if ( ply:Health() >= 9 ) then ply:SetHealth( ply:Health() - 8 ) @@ -2682,7 +2737,7 @@ function GM:OnNPCKilled( npc, killer, weapon ) local loot = ents.Create( "gms_loot" ) SPropProtection.PlayerMakePropOwner( killer, loot ) - loot.Resources = { Meat = math.random( 1, 5 ) } + loot.Resources = { Meat = math.random( 1, 5 ) } loot:SetPos( npc:GetPos() + Vector( 0, 0, 64 ) ) loot:Spawn() timer.Simple( 180, function() if ( loot:IsValid() ) then loot:Fadeout( 2 ) end end ) @@ -2752,7 +2807,7 @@ hook.Add( "KeyPress", "GMS_UseKeyHook", function( ply, key ) elseif ( GMS.IsInWater( tr.HitPos ) && !tr.HitNonWorld ) then if (ply:GetActiveWeapon():GetClass() == "gms_bucket") then ply:DoProcess( "BottleWater", 20 ) - else + else ply:DoProcess( "BottleWater", 3 ) end end @@ -2878,7 +2933,7 @@ function GM:PreLoadMap( name ) if ( !file.Exists( "gmstranded/gamesaves/" .. name .. ".txt", "DATA" ) ) then return end game.CleanUpMap() - + for k, ply in pairs( player.GetAll() ) do ply:MakeLoadingBar( "Savegame \"" .. name .. "\"" ) end self.NextLoaded = CurTime() + 0.6 @@ -2895,7 +2950,7 @@ function GM:LoadMap( name ) ply:StopLoadingBar() end return end - + Time = DayTime self:LoadMapEntity( savegame, num, 1 ) @@ -2906,13 +2961,13 @@ function GM:LoadMapEntity( savegame, max, k ) local entry = savegame["entries"][k] local ent = ents.Create( entry["class"] ) - + if ( !entry["model"] ) then print( "WARNING! " .. entry["class"] .. " doesn't have a model!" ) else ent:SetModel( entry["model"] ) end - + ent:SetColor( entry["color"] ) ent:SetPos( entry["pos"] ) @@ -2994,7 +3049,7 @@ hook.Add( "Think", "GM_WaterExtinguish", function() if ( v:WaterLevel() > 0 and v:IsOnFire() ) then v:Extinguish() timer.Remove( "gms_removecampfire_" .. v:EntIndex() ) - end + end end end ) @@ -3009,7 +3064,7 @@ local AlertSoundsSleep = { "stranded/need_sleepiness1.wav", "stranded/need_sleep /* Alert Messages */ timer.Create( "AlertTimer", 6, 0, function() //if ( GetConVarNumber( "gms_alerts" ) != 1 ) then return end - for k, ply in pairs( player.GetAll() ) do + for k, ply in pairs( player.GetAll() ) do if ( !ply:Alive() ) then continue end if ( ply.Hunger < 125 ) then ply:EmitSound( Sound( AlertSoundsHunger[ math.random( 1, #AlertSoundsHunger ) ] ), 100, math.random( 95, 105 ) ) end if ( ply.Thirst < 125 ) then ply:EmitSound( Sound( AlertSoundsThirst[ math.random( 1, #AlertSoundsThirst ) ] ), 100, math.random( 95, 105 ) ) end @@ -3051,7 +3106,7 @@ function CreateTribe( ply, name, red, green, blue, password ) ply:UpdatePlayerColor() SPropProtection.TribePP( ply ) ply:SendMessage( "Successfully created " .. name .. ".", 5, Color( 255, 255, 255, 255 ) ) - + end function GM.CreateTribeCmd( ply, cmd, args, argv ) @@ -3070,7 +3125,7 @@ function GM.JoinTribeCmd( ply, cmd, args ) if ( string.lower( v.name ) != string.lower( args[1] ) ) then continue end if ( v.password && v.password != args[ 2 ] ) then ply:SendMessage( "Incorrcet tribal password", 3, Color( 255, 50, 50, 255 ) ) return end - + ply:SetTeam( id ) ply:UpdatePlayerColor() SPropProtection.TribePP( ply ) @@ -3166,7 +3221,7 @@ function gms_addbuildsiteresource( ent_resourcedrop, ent_buildsite ) ent_buildsite.Costs[ent_resourcedrop.Type] = nil elseif ( ent_resourcedrop.Amount <= ent_buildsite.Costs[ent_resourcedrop.Type] ) then ent_buildsite.Costs[ent_resourcedrop.Type] = ent_buildsite.Costs[ent_resourcedrop.Type] - ent_resourcedrop.Amount - ent_resourcedrop:Remove() + ent_resourcedrop:Remove() end for k, v in pairs( ent_buildsite.Costs ) do if ( ent_buildsite.Costs[ent_resourcedrop.Type] ) then @@ -3174,7 +3229,7 @@ function gms_addbuildsiteresource( ent_resourcedrop, ent_buildsite ) ent_buildsite.Costs[ent_resourcedrop.Type] = nil end end - end + end if ( table.Count( ent_buildsite.Costs ) > 0 ) then local str = "You need: " @@ -3188,7 +3243,7 @@ function gms_addbuildsiteresource( ent_resourcedrop, ent_buildsite ) ply:SendMessage( "Finished!", 3, Color( 10, 200, 10, 255 ) ) ent_buildsite:Finish() end - + local str = ":" for k, v in pairs( ent_buildsite.Costs ) do str = str .. " " .. string.Replace( k, "_", " " ) .. " ( " .. v .. "x )" @@ -3207,7 +3262,7 @@ function gms_addbuildsiteresourcePack( ent_resourcepack, ent_buildsite ) if ( ent_resourcedrop_owner != nil and ent_buildsite_owner != nil and ply != nil and ent_resourcepack:IsPlayerHolding() ) then if ( SPropProtection.PlayerCanTouch( ply, ent_buildsite ) ) then for res, num in pairs( ent_resourcepack.Resources ) do - if ( ent_buildsite.Costs[res] and num > ent_buildsite.Costs[res] ) then + if ( ent_buildsite.Costs[res] and num > ent_buildsite.Costs[res] ) then ent_resourcepack.Resources[res] = num - ent_buildsite.Costs[res] ent_resourcepack:SetResPackInfo( res, ent_resourcepack.Resources[res] ) ent_buildsite.Costs[res] = nil @@ -3237,7 +3292,7 @@ function gms_addbuildsiteresourcePack( ent_resourcepack, ent_buildsite ) ply:SendMessage( "Finished!", 3, Color( 10, 200, 10, 255 ) ) ent_buildsite:Finish() end - + local str = ":" for k, v in pairs( ent_buildsite.Costs ) do str = str .. " " .. string.Replace( k, "_", " " ) .. " ( " .. v .. "x )" diff --git a/gamemode/init_utility.lua b/gamemode/init_utility.lua index ca2d888..5346cdc 100644 --- a/gamemode/init_utility.lua +++ b/gamemode/init_utility.lua @@ -1 +1,28 @@ //Helper functions to refactor the init + +function findRecursive(folderstring,recursive,dofunction) + local folderpath = "gamemodes/" .. GM.GAMEMODE_FOLDER_NAME .. "/gamemode/" .. folderstring .. "/" + local files, directories = file.Find(folderpath .. "*", "MOD") + if(recursive) then + for k,v in pairs(directories) do + addResourceFolder(folderstring..v,recursive) + end + end + for k,v in pairs(files) do + dofunction(folderstring .. "/".. v) + end +end + +//Does AddCSLuaFile() on all files within a folderpath, optionally recursive +//Ex: +// AddCSLuaFolder("client/extras",true) +function AddCSLuaFolder(folderstring,recursive) + findRecursive(folderstring,recursive,function(string) AddCSLuaFile(string) end) +end + +//Does include() on all files within a folderpath, optionally recursive +//Ex: +// includeFolder("server/extras",false) +function includeFolder(folderstring,recursive) + findRecursive(folderstring,recursive,function(string) include(string) end) +end diff --git a/gamemode/server/tribes.lua b/gamemode/server/tribes.lua new file mode 100644 index 0000000..d2e6722 --- /dev/null +++ b/gamemode/server/tribes.lua @@ -0,0 +1,10 @@ +--Tribes table +if ( !GM.Tribes ) then + GM.Tribes = GM.Tribes or {} + table.insert( GM.Tribes, { name = "The Stranded", color = Color( 200, 200, 0 ), password = false } ) + table.insert( GM.Tribes, { name = "Survivalists", color = Color( 225, 225, 225 ), password = false } ) + table.insert( GM.Tribes, { name = "Anonymous", color = Color( 0, 145, 145 ), password = false } ) + table.insert( GM.Tribes, { name = "The Gummies", color = Color( 255, 23, 0 ), password = false } ) + table.insert( GM.Tribes, { name = "The Dynamics", color = Color( 0, 72, 255 ), password = false } ) + table.insert( GM.Tribes, { name = "Scavengers", color = Color( 8, 255, 0 ), password = false } ) +end |
