diff options
Diffstat (limited to 'gamemode/server')
| -rw-r--r-- | gamemode/server/concommands.lua | 66 | ||||
| -rw-r--r-- | gamemode/server/spawnitem.lua | 12 | ||||
| -rw-r--r-- | gamemode/server/world.lua | 60 |
3 files changed, 138 insertions, 0 deletions
diff --git a/gamemode/server/concommands.lua b/gamemode/server/concommands.lua new file mode 100644 index 0000000..a6c891c --- /dev/null +++ b/gamemode/server/concommands.lua @@ -0,0 +1,66 @@ +concommand.Add("ws_giveitem",function(pl,com,args)
+ if (!IsValid(pl)) then return end
+ if (!pl:IsAdmin()) then return end
+ if (!args[1]) then return end
+
+ pl:AddItem(args[1],tonumber(args[2] or 1))
+end)
+
+concommand.Add("ws_revive",function(pl,com,args)
+ if (IsValid(pl) and !pl:IsAdmin()) then return end
+ if (!args[1]) then return end
+
+ for k,v in pairs(player.GetAll()) do
+ if (v:Nick():lower():find(args[1]) and v:IsPigeon()) then
+ v:ChatPrint("You have been resurrected from the dead by an admin!")
+ v:SetHuman(true)
+ v:KillSilent()
+ v:EmitSound("wintersurvival2/ritual/wololo.mp3")
+ end
+ end
+end)
+
+--Manual generate a proprain, for debugging
+concommand.Add("ws_proprain",function(ply,cmd,args)
+ if (IsValid(pl) and !pl:IsAdmin()) then return end
+ GAMEMODE:GeneratePropRain()
+end)
+
+--Manual reload of items + recepies, usefull for testing
+concommand.Add("ws_reloaditems",function(ply,cmd,args)
+ if (IsValid(pl) and !pl:IsAdmin()) then return end
+ GAMEMODE:LoadItems()
+end)
+
+--Manual reload of npc's, usefull for testing
+concommand.Add("ws_reloadnpcs",function(ply,cmd,args)
+ if (IsValid(pl) and !pl:IsAdmin()) then return end
+ GAMEMODE:LoadNPCS()
+end)
+
+--Generate a nice HTML representation of all the recepies.
+concommand.Add("ws_generaterecipes",function(pl,com,args)
+ if (IsValid(pl) and !pl:IsAdmin()) then return end
+ local filename = "ws_recipedata.txt"
+ for k,v in pairs(GAMEMODE.Recipes) do
+ if not v.Recipe then continue end
+ if not v.Name then continue end
+ file.Append(filename,"<li>\n\t<label>\n\t\t<input type='checkbox'>\n\t\t" .. v.Name)
+ for i,j in pairs(v.Recipe) do
+ if(i == "Resources") then
+ file.Append(filename,"\n\t<ul type='circle'>")
+ for p,q in pairs(j) do
+ file.Append(filename,"\n\t\t<li>" .. p .. " x " .. q .. "</li>")
+ end
+ file.Append(filename,"\n\t</ul>")
+ elseif(i == "Tools") then
+ file.Append(filename,"\n\t<ul type='square'>")
+ for p,q in pairs(j) do
+ file.Append(filename,"\n\t\t<li>" .. p .. " x " .. q .. "</li>")
+ end
+ file.Append(filename,"\n\t</ul>")
+ end
+ end
+ file.Append(filename,"\n\t</label>\n</li>\n")
+ end
+end)
diff --git a/gamemode/server/spawnitem.lua b/gamemode/server/spawnitem.lua new file mode 100644 index 0000000..ef13104 --- /dev/null +++ b/gamemode/server/spawnitem.lua @@ -0,0 +1,12 @@ +
+function SpawnWSItem(Item,pos)
+ local IT = GetItemByName(Item)
+
+ local drop = ents.Create("ws_item")
+ drop.Item = IT
+ drop:SetModel(drop.Item.Model)
+ drop:SetPos(pos)
+ drop:Spawn()
+
+ return drop
+end
\ No newline at end of file diff --git a/gamemode/server/world.lua b/gamemode/server/world.lua new file mode 100644 index 0000000..9d23c7b --- /dev/null +++ b/gamemode/server/world.lua @@ -0,0 +1,60 @@ +
+local random = math.random
+local traceline = util.TraceLine
+local contents = util.PointContents
+local Up = Vector(0,0,1)
+
+function GM:GeneratePropRain()
+ local Items = {
+ GetItemByName("Wood"),
+ GetItemByName("Rock"),
+ GetItemByName("Crystal"),
+ }
+
+ --THIS PIECE OF CODE IS FOR OLDER VERSIONS OF WS MAPS! ITS CRAP BUT WE HAVE TO... For WS players!
+ local areas = {}
+
+ for i,area in pairs(ents.FindByClass("info_target")) do
+ if (area:GetName() == "survival_spawn") then
+ local parent = area:GetParent()
+ if (IsValid(parent)) then
+ areas[area] = parent
+ end
+ end
+ end
+
+ for pAe,pBe in pairs(areas) do
+ local pA,pB = pAe:GetPos(),pBe:GetPos()
+ local Dis = pA:Distance(pB)
+
+ for i = 1,40+math.ceil(Dis/70) do
+ local V = Vector(random(pB.x,pA.x),random(pB.y,pA.y),random(pB.z,pA.z))
+ local Tr = traceline({start=V,endpos=V-Up*40000})
+ local Pos = Tr.HitPos+Up*20
+ local C = contents(Pos)
+
+ if (C != CONTENTS_WATER and C != CONTENTS_WATER+CONTENTS_TRANSLUCENT) then
+ local drop = ents.Create("ws_item")
+ drop.Item = Items[random(1,3)]
+ drop:SetModel(drop.Item.Model)
+ drop:SetPos(Pos)
+ drop:Spawn()
+ drop:GetPhysicsObject():Sleep()
+ end
+ end
+
+ --Shop spawn
+ local V = Vector(random(pB.x,pA.x),random(pB.y,pA.y),random(pB.z,pA.z))
+ local Tr = traceline({start=V,endpos=V-Up*40000})
+ local Pos = Tr.HitPos+Up*20
+ local C = contents(Pos)
+
+ if (C != CONTENTS_WATER and C != CONTENTS_WATER+CONTENTS_TRANSLUCENT) then
+ local drop = ents.Create("ws_shop")
+ drop:SetPos(Pos)
+ drop:Spawn()
+ drop:Activate()
+ end
+ end
+ --END... Newer versions of maps should use a brush entity instead.
+end
|
