From e879c365577b0cc51c48bace7cd5fb52cdc26eaa Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Mon, 20 Jun 2016 15:33:39 -0400 Subject: Re-syncing last updated copy --- gamemode/itemsystem/items/armor.lua | 77 +++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 gamemode/itemsystem/items/armor.lua (limited to 'gamemode/itemsystem') diff --git a/gamemode/itemsystem/items/armor.lua b/gamemode/itemsystem/items/armor.lua new file mode 100644 index 0000000..cf0ce40 --- /dev/null +++ b/gamemode/itemsystem/items/armor.lua @@ -0,0 +1,77 @@ + +local materials = { + + "Copper", + "Iron", + "Tech", + "Silver", + "Gold", + "Steel", + "Platinum", + +} + +local parts = { + + "Helmet", + "Platebody", + "Platelegs", + "Boots", + +} + +if(SERVER) then + util.AddNetworkString( "gms_equip" ) +end + +local equip_server = function(ln,player) + tbl = net.ReadTable() + t = net.ReadString( 32 ) + player:DecResource( tbl.Item, 1 ) + player:SendMessage( tbl.Type.." Equipped!", 3, Color( 10, 200, 10, 255 ) ) + bool = net.ReadBool() + sName = net.ReadString( 32 ) + if !bool then return end + player:SendMessage( sName, 3, Color( 10, 200, 10, 255 ) ) + player:IncResource( sName, 1 ) + +end +net.Receive( "gms_equip", equip_server ) + +for k,v in pairs(parts) do + for o,p in pairs(materials) do + + local ITEM = {} + ITEM.Name = p.." "..v + ITEM.Description = v.." that will protect you." + ITEM.Icon = "test.png" + ITEM.Type = v + ITEM.UniqueData = false + ITEM.Actions = {} + genericMakeDroppable(ITEM) + ITEM.Actions["Equip"] = function() + + local tbl = { Item = ITEM.Name, Icon = ITEM.Icon, Type = ITEM.Type, Description = ITEM.Description } + local sName = "-" + for g,h in pairs(GMS.Equipped) do + if h['Type'] == tbl.Type then + tbl2 = table.remove(GMS.Equipped,g) + sName = tbl2.Item + break + end + end + + table.insert( GMS.Equipped, tbl ) + net.Start("gms_equip") + net.WriteTable( tbl ) + net.WriteString( v, 32 ) + if sName != "-" then net.WriteBool( true ) else net.WriteBool( false ) end + net.WriteString( sName, 32 ) + + net.SendToServer() + + end + GMS.RegisterResource(ITEM) + + end +end -- cgit v1.2.3-70-g09d2