shadowndacorner

commands.lua

Oct 12th, 2011
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 37.24 KB | None | 0 0
  1. if SERVER then
  2.     include("team.lua")
  3. end
  4.  
  5. concommand.Add("uw_setlevel",function(ply,cmd,args)
  6.     if ply:IsSuperAdmin() then
  7.         local target = args[1]
  8.         local number = tonumber(args[2])
  9.         local found = FindPlayerByName(target) or NULL
  10.         if not found:IsValid() then
  11.             ply:PrintMessage(HUD_PRINTCONSOLE,"Player not found")
  12.             return
  13.         end
  14.         found:SetLevel(number)
  15.         if number <= found:GetMaxLevel() and number >= 0 then
  16.             GAMEMODE:PrintAll(ply:Name().." set "..found:Name().."'s level to "..number..".")
  17.         else
  18.             ply:PrintMessage(HUD_PRINTCONSOLE,"Number out of range (0-"..found:GetMaxLevel()..")")
  19.         end
  20.     else
  21.         ply:PrintMessage(HUD_PRINTCONSOLE,"No access.")
  22.     end
  23. end)
  24.  
  25. concommand.Add("uw_setprestige",function(ply,cmd,args)
  26.     if ply:IsSuperAdmin() then
  27.         local target = args[1]
  28.         local number = tonumber(args[2])
  29.         local found = FindPlayerByName(target) or NULL
  30.         if not found:IsValid() then
  31.             ply:PrintMessage(HUD_PRINTCONSOLE,"Player not found")
  32.             return
  33.         end
  34.         found:SetPrestige(number)
  35.         if number <= 5 and number >= 0 then
  36.             GAMEMODE:PrintAll(ply:Name().." set "..found:Name().."'s prestige to "..number..".")
  37.         else
  38.             ply:PrintMessage(HUD_PRINTCONSOLE,"Number out of range (0-5)")
  39.         end
  40.     else
  41.         ply:PrintMessage(HUD_PRINTCONSOLE,"No access.")
  42.     end
  43. end)
  44.  
  45. concommand.Add("uw_doublexp",function(ply,cmd,args)
  46.     if ply:IsSuperAdmin() then
  47.         local number = tonumber(args[1])
  48.         if number <= 1 and number >= 0 then
  49.             for _,v in pairs(player.GetAll()) do
  50.                 v:SetDoubleExp(number)
  51.             end
  52.             GamemodeData.DoubleXP = number
  53.             GAMEMODE:PrintAll(ply:Name().." set double exp to "..((number == 1 and "enabled") or "disabled")..".")
  54.         else
  55.             ply:PrintMessage(HUD_PRINTCONSOLE,"Number out of range (0-1)")
  56.         end
  57.     else
  58.         ply:PrintMessage(HUD_PRINTCONSOLE,"No access.")
  59.     end
  60. end)
  61.  
  62. concommand.Add("uw_setmoney",function(ply,cmd,args)
  63.     if ply:IsSuperAdmin() then
  64.         local target = args[1]
  65.         local number = tonumber(args[2])
  66.         local found = FindPlayerByName(target) or NULL
  67.         if not found:IsValid() then
  68.             ply:PrintMessage(HUD_PRINTCONSOLE,"Player not found")
  69.             return
  70.         end
  71.         if number <= 999999999999 and number >= 0 then
  72.             GAMEMODE:PrintAll(ply:Name().." set "..found:Name().."'s money to $"..FormatMoney(number)..".")
  73.             found:SetMoney(number)
  74.         else
  75.             ply:PrintMessage(HUD_PRINTCONSOLE,"Number out of range (0-999999999999)")
  76.         end
  77.     else
  78.         ply:PrintMessage(HUD_PRINTCONSOLE,"No access.")
  79.     end
  80. end)
  81.  
  82. concommand.Add("uw_addmoney",function(ply,cmd,args)
  83.     //if ply:IsSuperAdmin() then
  84.     if !ply:IsPlayer() or ply:IsSuperAdmin() then
  85.         local target = args[1]
  86.         local number = tonumber(args[2])
  87.         if target == "*" then
  88.             if number <= 999999999999 and number >= 0 then
  89.                 GAMEMODE:PrintAll(ply:Name().." gave everyone $"..FormatMoney(number)..".")
  90.                 for k,v in pairs(player.GetAll()) do
  91.                     v:SetMoney(v:GetMoney() + number)
  92.                 end
  93.             else
  94.                 ply:PrintMessage(HUD_PRINTCONSOLE,"Number out of range (0-999999999999)")
  95.             end
  96.         else
  97.             local found = FindPlayerByName(target) or NULL
  98.             if not found:IsValid() then
  99.                 ply:PrintMessage(HUD_PRINTCONSOLE,"Player not found")
  100.                 return
  101.             end
  102.             if number <= 999999999999 and number >= 0 then
  103.                 GAMEMODE:PrintAll(ply:Name().." gave "..found:Name().." $"..FormatMoney(number)..".")
  104.                 found:SetMoney(found:GetMoney() + number)
  105.             else
  106.                 ply:PrintMessage(HUD_PRINTCONSOLE,"Number out of range (0-999999999999)")
  107.             end
  108.         end
  109.     else
  110.         ply:PrintMessage(HUD_PRINTCONSOLE,"No access.")
  111.     end
  112. end)
  113.  
  114. concommand.Add("uw_adminears",function(ply,cmd,args)
  115.     if ply:IsAdmin() then
  116.         local num = tonumber(args[1])
  117.         if num == 1 or num == 0 then
  118.             ply.AdminEars = num
  119.             ply:ChatPrint("You "..((num==1 and "can") or "cannot").." hear everyone.")
  120.         end
  121.     end
  122. end)
  123.  
  124. concommand.Add("uw_adminspeak",function(ply,cmd,args)
  125.     if ply:IsAdmin() then
  126.         local num = tonumber(args[1])
  127.         if num == 1 or num == 0 then
  128.             ply.AdminSpeak = num
  129.             ply:ChatPrint("Everyone "..((num==1 and "can") or "cannot").." hear you.")
  130.         end
  131.     end
  132. end)
  133.  
  134. concommand.Add("uw_settokens",function(ply,cmd,args)
  135.     if ply:IsSuperAdmin() then
  136.         local target = args[1]
  137.         local number = tonumber(args[2])
  138.         local found = FindPlayerByName(target) or NULL
  139.         if not found:IsValid() then
  140.             ply:PrintMessage(HUD_PRINTCONSOLE,"Player not found")
  141.             return
  142.         end
  143.         if number <= 999999999999 and number >= 0 then
  144.             GAMEMODE:PrintAll(ply:Name().." set "..found:Name().."'s donation tokens to "..number..".")
  145.             found:SetDonateTokens(number)
  146.         else
  147.             ply:PrintMessage(HUD_PRINTCONSOLE,"Number out of range (0-999999999999)")
  148.         end
  149.     else
  150.         ply:PrintMessage(HUD_PRINTCONSOLE,"No access.")
  151.     end
  152. end)
  153.  
  154. concommand.Add("uw_addtokens",function(ply,cmd,args)
  155.     if ply:IsSuperAdmin() then
  156.         local target = args[1]
  157.         local number = tonumber(args[2])
  158.         local found = FindPlayerByName(target) or NULL
  159.         if not found:IsValid() then
  160.             ply:PrintMessage(HUD_PRINTCONSOLE,"Player not found")
  161.             return
  162.         end
  163.         if number <= 999999999999 and number >= 0 then
  164.             GAMEMODE:PrintAll(ply:Name().." gave "..found:Name().." "..number.." donation tokens.")
  165.             found:AddDonateTokens(number)
  166.         else
  167.             ply:PrintMessage(HUD_PRINTCONSOLE,"Number out of range (0-999999999999)")
  168.         end
  169.     else
  170.         ply:PrintMessage(HUD_PRINTCONSOLE,"No access.")
  171.     end
  172. end)
  173.  
  174. concommand.Add("uw_commands",function(ply,cmd,args)
  175.     local cmds = {
  176.         "uw_setlevel <name> <level>\nSet someones level.",
  177.         "uw_setprestige <name> <prestige>\nSet someones prestige.",
  178.         "uw_doublexp <1/0>\nEnable double exp.",
  179.         "uw_setmoney <name> <money>\nSet someones money.",
  180.         "uw_addmoney <name> <amount>\nGive someone money.",
  181.         "uw_adminears <1/0>\n makes you hear everyone.",
  182.         "uw_adminspeak <1/0>\n makes everyone hear you.",
  183.         "uw_settokens <name> <amount>\n set someones donation tokens.",
  184.         "uw_addtokens <name> <amount>\n give someone donation tokens."
  185.     }
  186.     for _,v in pairs(cmds) do
  187.         ply:PrintMessage(HUD_PRINTCONSOLE,v)
  188.     end
  189. end)
  190.  
  191. concommand.Add("BuyWeapon",function(ply,cmd,args)
  192.     if ply.InMarketZone then
  193.         local data = GetWeaponByName(args[1])
  194.         if data then
  195.             local name = data[1]
  196.             local price = data[3]
  197.             local spreaddata = data[7]
  198.             local minspread = spreaddata[1]
  199.             local maxspread = spreaddata[2]
  200.            
  201.             local damagedata = data[8]
  202.             local mindamage = damagedata[1]
  203.             local maxdamage = damagedata[2]
  204.  
  205.             local recoildata = data[9]
  206.             local minrecoil = recoildata[1]
  207.             local maxrecoil = recoildata[2]
  208.            
  209.             local leveldata = data[10]
  210.             local minlevel = leveldata[1]
  211.             local maxlevel = leveldata[2]
  212.            
  213.             local socketsdata = data[11]
  214.             local minsockets = socketsdata[1]
  215.             local maxsockets = socketsdata[2]
  216.             local numsockets = math.random(minsockets,maxsockets)
  217.             local sockets = {}
  218.             for i=1,numsockets do
  219.                 table.insert(sockets,1)
  220.             end
  221.             if ply:CanAfford(price) then
  222.                 ply:ChatPrint("You bought a "..name.." for $"..FormatMoney(price)..".")
  223.                 ply:TakeMoney(price)
  224.                 ply:AddToInventory({Name = name,ItemType="weapon",Data={firerate=1,spread=math.Rand(minspread,maxspread),damage=math.Rand(mindamage,maxdamage),recoil=math.Rand(minrecoil,maxrecoil),levelreq=math.random(minlevel,maxlevel)},Sockets=sockets})
  225.             else
  226.                 ply:ChatPrint("You cannot affort that.")
  227.             end
  228.         else
  229.             ply:ChatPrint("Error: invalid weapon.")
  230.         end
  231.     else
  232.         ply:ChatPrint("You arent in the market.")
  233.     end
  234. end)
  235.  
  236. concommand.Add("SellWeapon",function(ply,cmd,args)
  237.     local id = tonumber(args[1])
  238.     if not id then return end
  239.     local item = ply:GetInventory()[id]
  240.     local data = GetWeaponByName(item.Name)
  241.     if data then
  242.         if item.ItemType == "weapon" then
  243.             local price = data[3]
  244.             ply:TakeMoney(-(price*0.25))
  245.             ply:ChatPrint("You succesfully sold "..item.Name.." for $"..FormatMoney(price*0.25)..".")
  246.             ply:RemoveInventorySlot(id)
  247.         else
  248.             ply:ChatPrint("Not a weapon.")
  249.         end
  250.     else
  251.         ply:ChatPrint("Invalid Slot.")
  252.     end
  253. end)
  254.  
  255. concommand.Add("SellArmor",function(ply,cmd,args)
  256.     local id = tonumber(args[1])
  257.     if not id then return end
  258.     local item = ply:GetInventory()[id]
  259.     local data = GetArmorByName(item.Name)
  260.     if data then
  261.         if item.ItemType == "armor" then
  262.             local price = data[2]
  263.             ply:TakeMoney(-(price*0.25))
  264.             ply:ChatPrint("You succesfully sold "..item.Name.." for $"..FormatMoney(price*0.25)..".")
  265.             ply:RemoveInventorySlot(id)
  266.         else
  267.             ply:ChatPrint("Not an armor.")
  268.         end
  269.     else
  270.         ply:ChatPrint("Invalid Slot.")
  271.     end
  272. end)
  273.  
  274. concommand.Add("EquipWeapon",function(ply,cmd,args)
  275.     local id = tonumber(args[1])
  276.     local slot = tonumber(args[2])
  277.    
  278.     if not (ply:GetInventory()[id] and ply:GetInventory()[id].Name) then return end
  279.    
  280.     local wepdata = GetWeaponByName(ply:GetInventory()[id].Name)
  281.    
  282.     if not wepdata then return end
  283.    
  284.     local goesto = wepdata[5]
  285.    
  286.     local bonus = GetWeaponSocketBonuses(ply:GetInventory()[id])
  287.    
  288.     local levelreq = ply:GetInventory()[id].Data.levelreq + bonus[5]
  289.  
  290.     if ply:GetLevel() >= levelreq then
  291.         if not ply:GetEquipped()["weapon"..slot] or ply:GetEquipped()["weapon"..slot].Name == "0" then
  292.             if slot == goesto then
  293.                 ply:Equip("weapon"..slot,ply:GetInventory()[id])
  294.                 ply:ChatPrint("Equipped "..ply:GetInventory()[id].Name.." to "..(slot == 1 and "Primary" or "Secondary"))
  295.                 ply:RemoveInventorySlot(id)
  296.             else
  297.                 if goesto == 1 then
  298.                     ply:ChatPrint("This weapon can only be equipped to Primary.")
  299.                 elseif goesto == 2 then
  300.                     ply:ChatPrint("This weapon can only be equipped to Secondary.")
  301.                 end
  302.             end
  303.         else
  304.             ply:ChatPrint("Slot "..slot.." already taken, please unequip first.")
  305.         end
  306.     else
  307.         ply:ChatPrint("Your level isn't high enough.")
  308.     end
  309. end)
  310.  
  311. concommand.Add("UnEquipWeapon",function(ply,cmd,args)
  312.     local slot = args[1]
  313.     if ply:GetEquipped()[slot] and ply:GetEquipped()[slot].Name != "0" and ply:Alive() then
  314.         ply:UnEquip(slot)
  315.     else
  316.         ply:ChatPrint("Slot "..slot.." is already empty.")
  317.     end
  318. end)
  319.  
  320. concommand.Add("SocketWeapon",function(ply,cmd,args)
  321.     local sockets = {}
  322.     local slot = tonumber(args[1])
  323.     table.remove(args,1)
  324.    
  325.     for _,v in pairs(args) do
  326.         local data = string.Explode(",",v)
  327.         sockets[tonumber(data[1])] = tonumber(data[2])
  328.     end
  329.  
  330.     if table.Count(sockets) == 0 then
  331.         ply:ChatPrint("All sockets empty.")
  332.         return
  333.     end
  334.  
  335.     local socketcounts = {}
  336.     for k,v in pairs(sockets) do
  337.         if v != 1 then
  338.             if not socketcounts[tostring(v)] then
  339.                 socketcounts[tostring(v)] = 1
  340.             else
  341.                 socketcounts[tostring(v)] = socketcounts[tostring(v)] + 1
  342.             end
  343.         end
  344.     end
  345.  
  346.     local foundsocketables = {}
  347.     local counts = {}
  348.     for k,v in pairs(ply:GetInventory()) do
  349.         if v.ItemType == "wepsocketable" then
  350.             if table.HasValue(sockets,tonumber(v.Data.num)) then
  351.                 if not counts[tostring(v.Data.num)] then
  352.                     counts[tostring(v.Data.num)] = 0
  353.                 end
  354.                 if counts[tostring(v.Data.num)] < socketcounts[tostring(v.Data.num)] then
  355.                     foundsocketables[tostring(v.Data.num)] = k
  356.                     counts[tostring(v.Data.num)] = counts[tostring(v.Data.num)] + 1
  357.                 end
  358.             end
  359.         end
  360.     end
  361.  
  362.     local hasall = true
  363.     for k,v in pairs(counts) do
  364.         if not (tonumber(socketcounts[k]) >= tonumber(v)) then
  365.             hasall = false
  366.         end
  367.     end
  368.  
  369.     local weapon = ply:GetInventory()[slot]
  370.     if weapon and sockets and weapon.Sockets then
  371.         local tsockets = {}
  372.         for k,v in pairs(weapon.Sockets) do
  373.             tsockets[tonumber(k)] = tonumber(v)
  374.         end
  375.         for k,v in pairs(sockets) do
  376.             if v != 1 then
  377.                 tsockets[k] = sockets[k]
  378.             end
  379.         end
  380.         if table.Count(weapon.Sockets) == table.Count(tsockets) then
  381.             if hasall then
  382.                 ply:GetInventory()[slot] = {Name=weapon.Name,ItemType="weapon",Data=weapon.Data,Sockets=tsockets}
  383.                 ply:UpdateInventorySlot(slot)
  384.                 for k,v in pairs(foundsocketables) do
  385.                     ply:RemoveInventorySlot(tonumber(v))
  386.                 end
  387.                 ply:ChatPrint("Socketed "..weapon.Name)
  388.             else
  389.                 ply:ChatPrint("You dont have all the socketables.")
  390.             end
  391.         else
  392.             ply:ChatPrint("Invalid sockets.")
  393.         end
  394.     else
  395.         ply:ChatPrint("Invalid weapon.")
  396.     end
  397. end)
  398.  
  399. concommand.Add("SocketArmor",function(ply,cmd,args)
  400.     local sockets = {}
  401.     local slot = tonumber(args[1])
  402.     table.remove(args,1)
  403.    
  404.     for _,v in pairs(args) do
  405.         local data = string.Explode(",",v)
  406.         sockets[tonumber(data[1])] = tonumber(data[2])
  407.     end
  408.  
  409.     if table.Count(sockets) == 0 then
  410.         ply:ChatPrint("All sockets empty.")
  411.         return
  412.     end
  413.  
  414.     local socketcounts = {}
  415.     for k,v in pairs(sockets) do
  416.         if v != 1 then
  417.             if not socketcounts[tostring(v)] then
  418.                 socketcounts[tostring(v)] = 1
  419.             else
  420.                 socketcounts[tostring(v)] = socketcounts[tostring(v)] + 1
  421.             end
  422.         end
  423.     end
  424.  
  425.     local foundsocketables = {}
  426.     local counts = {}
  427.     for k,v in pairs(ply:GetInventory()) do
  428.         if v.ItemType == "armorsocketable" then
  429.             if table.HasValue(sockets,tonumber(v.Data.num)) then
  430.                 if not counts[tostring(v.Data.num)] then
  431.                     counts[tostring(v.Data.num)] = 0
  432.                 end
  433.                 if counts[tostring(v.Data.num)] < socketcounts[tostring(v.Data.num)] then
  434.                     foundsocketables[tostring(v.Data.num)] = k
  435.                     counts[tostring(v.Data.num)] = counts[tostring(v.Data.num)] + 1
  436.                 end
  437.             end
  438.         end
  439.     end
  440.  
  441.     local hasall = true
  442.     for k,v in pairs(counts) do
  443.         if not (tonumber(socketcounts[k]) >= tonumber(v)) then
  444.             hasall = false
  445.         end
  446.     end
  447.  
  448.     local armor = ply:GetInventory()[slot]
  449.     if armor and sockets and armor.Sockets then
  450.         local tsockets = {}
  451.         for k,v in pairs(armor.Sockets) do
  452.             tsockets[tonumber(k)] = tonumber(v)
  453.         end
  454.         for k,v in pairs(sockets) do
  455.             if v != 1 then
  456.                 tsockets[k] = sockets[k]
  457.             end
  458.         end
  459.         if table.Count(armor.Sockets) == table.Count(tsockets) then
  460.             if hasall then
  461.                 ply:GetInventory()[slot] = {Name=armor.Name,ItemType="armor",Data=armor.Data,Sockets=tsockets}
  462.                 ply:UpdateInventorySlot(slot)
  463.                 for k,v in pairs(foundsocketables) do
  464.                     ply:RemoveInventorySlot(tonumber(v))
  465.                 end
  466.                 ply:ChatPrint("Socketed "..armor.Name)
  467.             else
  468.                 ply:ChatPrint("You dont have all the socketables.")
  469.             end
  470.         else
  471.             ply:ChatPrint("Invalid sockets.")
  472.         end
  473.     else
  474.         ply:ChatPrint("Invalid armor.")
  475.     end
  476. end)
  477.  
  478. concommand.Add("AdminUpdateWeapon",function(ply,cmd,args)
  479.     if ply:IsSuperAdmin() then
  480.         local id = tonumber(args[1])
  481.         local firerate = tonumber(args[2])/100
  482.         local spread = tonumber(args[3])/100
  483.         local damage = tonumber(args[4])/100
  484.         local recoil = tonumber(args[5])/100
  485.         local levelreq = tonumber(args[6])
  486.         local name = args[7]
  487.         if ply:IsAdmin() then
  488.             if ply:GetInventory()[id] then
  489.                 ply:GetInventory()[id] = {Name=name,ItemType="weapon",Data={firerate=firerate,spread=spread,damage=damage,recoil=recoil,levelreq=levelreq},Sockets=ply:GetInventory()[id].Sockets}
  490.                 ply:UpdateInventorySlot(id)
  491.                 ply:ChatPrint("Weapon "..name.." updated!")
  492.                 GAMEMODE:PrintAll(ply:Name().." edited a weapon.")
  493.             end
  494.         end
  495.     end
  496. end)
  497.  
  498. concommand.Add("BuyArmor",function(ply,cmd,args)
  499.     if ply.InMarketZone then
  500.         local data = GetArmorByName(args[1])
  501.         local name = data[1]
  502.         local price = data[2]
  503.        
  504.         local socketsdata = data[4]
  505.         local minsockets = socketsdata[1]
  506.         local maxsockets = socketsdata[2]
  507.         local numsockets = math.random(minsockets,maxsockets)
  508.         local sockets = {}
  509.         for i=1,numsockets do
  510.             sockets[i] = 1
  511.         end
  512.        
  513.         local health = math.Rand(data[5][1],data[5][2])
  514.         local armor = math.Rand(data[6][1],data[6][2])
  515.         local speed = math.Rand(data[7][1],data[7][2])
  516.         local defence = math.Rand(data[8][1],data[8][2])
  517.         local levelreq = math.random(data[9][1],data[9][2])
  518.        
  519.         if ply:CanAfford(price) then
  520.             ply:ChatPrint("Item: "..name)
  521.             ply:ChatPrint("Buy succesful!")
  522.             ply:TakeMoney(price)
  523.             ply:AddToInventory({Name = name,ItemType="armor",Data={Health = health,Armor = armor,Speed = speed,Defence = defence,Levelreq = levelreq},Sockets=sockets})
  524.         else
  525.             ply:ChatPrint("You cannot affort that.")
  526.         end
  527.     else
  528.         ply:ChatPrint("You arent in the market.")
  529.     end
  530. end)
  531.  
  532. concommand.Add("EquipArmor",function(ply,cmd,args)
  533.     local id = tonumber(args[1])
  534.     if ply:GetEquipped()["armor"] and ply:GetEquipped()["armor"].Name == "No armor" then
  535.         local levelreq = tonumber(ply:GetInventory()[id].Data.Levelreq)
  536.         if ply:GetLevel() >= levelreq then
  537.             ply:Equip("armor",ply:GetInventory()[id])
  538.             ply:ChatPrint("Equipped "..ply:GetInventory()[id].Name)
  539.             ply:RemoveInventorySlot(id)
  540.         else
  541.             ply:ChatPrint("Your level isnt high enough")
  542.         end
  543.     else
  544.         ply:ChatPrint("Unequip current armor first.")
  545.     end
  546. end)
  547.  
  548. concommand.Add("UnequipArmor",function(ply,cmd,args)
  549.     if ply:GetEquipped()["armor"] and ply:GetEquipped()["armor"].Name != "No armor" and ply:Alive() then
  550.         ply:UnEquip("armor")
  551.     else
  552.         ply:ChatPrint("You aren't wearing any armor.")
  553.     end
  554. end)
  555.  
  556. concommand.Add("BuyAmmo",function(ply,cmd,args)
  557.     if ply.InMarketZone then
  558.         local count = tonumber(args[2])
  559.         local data = GetItemByName(args[1])
  560.         local name = data[1]
  561.         local price = count*tonumber(data[2])
  562.         local ammotype = data[3]
  563.        
  564.         local ammos = ply:GetInventory()[1].Data
  565.  
  566.         if count <= 0 then return end -- dont even bother
  567.        
  568.         if ply:CanAfford(price) and ammos then
  569.             ammos[ammotype] = ammos[ammotype] + count
  570.             ply:GiveAmmo(count,ammotype)
  571.             ply:ChatPrint("You bought "..count.." "..name.." for $"..FormatMoney(price)..".")
  572.             ply:TakeMoney(price)
  573.             ply:GetInventory()[1] = {Name="ammopackage",ItemType="ammo",Data=ammos,Sockets={}}
  574.             ply:UpdateInventorySlot(1)
  575.         else
  576.             ply:ChatPrint("You cannot affort that.")
  577.         end
  578.     else
  579.         ply:ChatPrint("You arent in the market.")
  580.     end
  581. end)
  582.  
  583. concommand.Add("NewGang",function(ply,cmd,args)
  584.     if ply.InMarketZone then
  585.         if ply:CanAfford(250000) then
  586.             ply:TakeMoney(250000)
  587.             local name = args[1]
  588.             local r = args[2]
  589.             local g = args[3]
  590.             local b = args[4]
  591.             NewTeam(#GamemodeData.Teams+1,name,Color(r,g,b,255),ply:SteamID(),{},{Damage = 1,Health = 1,Armor = 1,Speed = 1,Xp = 1,Money = 1},0)
  592.             ply:ChatPrint("Gang created!")
  593.         else
  594.             ply:ChatPrint("You cannot afford that.")
  595.         end
  596.     else
  597.         ply:ChatPrint("You arent in the market.")
  598.     end
  599. end)
  600.  
  601. concommand.Add("UpgradeGang",function(ply,cmd,args)
  602.     if ply.InMarketZone then
  603.         local Upgrade = args[1]
  604.         local CurTeam = GamemodeData.Teams[ply:Team()]
  605.         local CurLevel = CurTeam.Upgrades[Upgrade]
  606.         local GangBank = tonumber(CurTeam.Bank)
  607.         if CurTeam.Leader == ply:SteamID() then
  608.             if CurLevel < 10 then
  609.                 local amt = (CurLevel*2)*1000000
  610.                 if GangBank >= amt then
  611.                     AddToGangBank(ply:Team(),-amt,true)
  612.                     CurTeam.Upgrades[Upgrade] = CurLevel + 1
  613.                     UpgradeTeam(ply:Team())
  614.                     ply:ChatPrint(Upgrade.." upgraded!")
  615.                 else
  616.                     ply:ChatPrint("Your gang cannot afford that.")
  617.                 end
  618.             else
  619.                 ply:ChatPrint("Max Level Reached.")
  620.             end
  621.         else
  622.             ply:ChatPrint("You aren't the leader.")
  623.         end
  624.     else
  625.         ply:ChatPrint("You arent in the market.")
  626.     end
  627. end)
  628.  
  629. concommand.Add("InviteToGang",function(ply,cmd,args)
  630.     local toteam = tonumber(args[1])
  631.     local sid = args[2]
  632.     local invited = FindPlayerBySteamID(sid)
  633.     local CurTeam = GamemodeData.Teams[ply:Team()]
  634.     if not (toteam or sid) then return end
  635.     if toteam == ply:Team() and CurTeam.Leader == ply:SteamID() then
  636.         if invited then
  637.             if invited.InvitedTo == 0 then
  638.                 umsg.Start("ConfirmInvitation",invited)
  639.                     umsg.String(team.GetName(toteam))
  640.                 umsg.End()
  641.                 invited.InvitedTo = toteam
  642.             else
  643.                 ply:ChatPrint("Player "..invited:Name().." already has a pending invite.")
  644.             end
  645.         else
  646.             ply:ChatPrint("Couldnt find player.")
  647.         end
  648.     else
  649.         ply:ChatPrint("You aren't the leader.")
  650.     end
  651. end)
  652.  
  653. concommand.Add("InvitedToGang",function(ply,cmd,args)
  654.     local answ = args[1]
  655.     if ply.InvitedTo > 0 then
  656.         if answ == "yes" then
  657.             ply:ChatPrint("Joined gang "..team.GetName(ply.InvitedTo))
  658.             ply:SetTeam(ply.InvitedTo)
  659.             table.insert(GamemodeData.Teams[ply.InvitedTo].Members,ply:SteamID())
  660.             SaveTeam(ply.InvitedTo)
  661.             ply.InvitedTo = 0
  662.         else
  663.             ply:ChatPrint("Didn't join gang "..team.GetName(ply.InvitedTo))
  664.             ply.InvitedTo = 0
  665.         end
  666.     else
  667.         ply:ChatPrint("You havent been invited to any gang.")
  668.     end
  669. end)
  670.  
  671. concommand.Add("LeaveGang",function(ply,cmd,args)
  672.     local tnum = ply:Team()
  673.     local gang = GamemodeData.Teams[tnum]
  674.     local sid = ply:SteamID()
  675.     if tnum != 0 then
  676.         if sid == gang.Leader then
  677.             ply:SetTeam(0)
  678.             for k,v in pairs(team.GetPlayers(tnum)) do
  679.                 v:SetTeam(0)
  680.             end
  681.             ply:ChatPrint("Gang \""..team.GetName(tnum).."\" destroyed.")
  682.             RemoveTeam(tnum)
  683.         else
  684.             for k,v in pairs(gang.Members) do
  685.                 if v == sid then
  686.                     table.remove(gang.Members,k)
  687.                     ply:SetTeam(0)
  688.                     ply:ChatPrint("You left "..team.GetName(tnum)..".")
  689.                     SaveTeam(tnum)
  690.                     break
  691.                 end
  692.             end
  693.         end
  694.     else
  695.         ply:ChatPrint("Can't leave gangless.")
  696.     end
  697. end)
  698.  
  699. concommand.Add("DepositToGangBank",function(ply,cmd,args)
  700.     local tnum = tonumber(args[1])
  701.     local amt = tonumber(args[2])
  702.     if ply:Team() == tnum and ply:Team() > 0 then
  703.         if amt > 0 then
  704.             if ply:CanAfford(amt) then
  705.                 ply:TakeMoney(amt)
  706.                 ply:ChatPrint("You deposit $"..FormatMoney(amt).." into your gangs bank.")
  707.                 AddToGangBank(tnum,amt)
  708.             else
  709.                 ply:ChatPrint("You cant afford that.")
  710.             end
  711.         else
  712.             ply:ChatPrint("Invalid amount.")
  713.         end
  714.     else
  715.         ply:ChatPrint("Invalid team.")
  716.     end
  717. end)
  718.  
  719. concommand.Add("KickFromGang",function(ply,cmd,args)
  720.     local tsid = args[1]
  721.     local t = FindPlayerBySteamID(tsid)
  722.     local tnum = ply:Team()
  723.     local gang = GamemodeData.Teams[tnum]
  724.     local sid = ply:SteamID()
  725.     if sid == gang.Leader then
  726.         for k,v in pairs(gang.Members) do
  727.             if tsid == sid then
  728.                 ply:ChatPrint("You cant kick yourself.")
  729.                 break
  730.             end
  731.             if v == tsid then
  732.                 table.remove(gang.Members,k)
  733.                 if t then
  734.                     t:SetTeam(0)
  735.                     t:ChatPrint("You have been kicked from "..team.GetName(tnum)..".")
  736.                     ply:ChatPrint("You kicked "..t:Name().." from your gang.")
  737.                     SaveTeam(tnum)
  738.                 end
  739.                 break
  740.             end
  741.         end
  742.     else
  743.         ply:ChatPrint("You aren't the leader.")
  744.     end
  745. end)
  746.  
  747. concommand.Add("VoteRoundLength",function(ply,cmd,args)
  748.     if GamemodeData.Round.Voting and not ply.Voted then
  749.         local len = args[1]
  750.         if len == "short" then
  751.             GamemodeData.Round.Votes.Short = GamemodeData.Round.Votes.Short + 1
  752.             GAMEMODE:PrintAll("Recieved a vote for short round ("..GamemodeData.Round.Votes.Short.." total).")
  753.         elseif len == "normal" then
  754.             GamemodeData.Round.Votes.Normal = GamemodeData.Round.Votes.Normal + 1
  755.             GAMEMODE:PrintAll("Recieved a vote for normal round ("..GamemodeData.Round.Votes.Normal.." total).")
  756.         elseif len == "long" then
  757.             GamemodeData.Round.Votes.Long = GamemodeData.Round.Votes.Long + 1
  758.             GAMEMODE:PrintAll("Recieved a vote for long round ("..GamemodeData.Round.Votes.Long.." total).")
  759.         else
  760.             ply:ChatPrint("Invalid option.")
  761.         end
  762.         ply.Voted = true
  763.     else
  764.         ply:ChatPrint("Not the time to vote.")
  765.     end
  766. end)
  767.  
  768. concommand.Add("SelectClass",function(ply,cmd,args)
  769.     local selection = args[1]
  770.     if IsClassValid(selection) then
  771.         if table.HasValue(ply.Data.UnlockedClasses,GetClassByName(selection)[1]) then
  772.             ply.Data.Class.Selection = GetClassByName(selection)[1]
  773.             ply:ChatPrint("You will become a "..GetClassByName(selection)[1].." when you respawn")
  774.         else
  775.             ply:ChatPrint("You havent unlocked that class.")
  776.         end
  777.     else
  778.         ply:ChatPrint("Invalid class: "..selection)
  779.     end
  780. end)
  781.  
  782. concommand.Add("AddClass",function(ply,cmd,args)
  783.     if ply:IsSuperAdmin() then
  784.         local name = args[1]
  785.         local bonuses = string.Explode("|",args[2])
  786.         local unlockable = (tonumber(args[3]) == 1 and true or false)
  787.         local unlockprice = tonumber(args[4])
  788.        
  789.         for k,v in pairs(bonuses) do
  790.             bonuses[k] = tonumber(v)
  791.         end
  792.        
  793.         local class = {name,bonuses,unlockable,unlockprice}
  794.         table.insert(Classes,class)
  795.        
  796.         umsg.Start("AddClass")
  797.             umsg.String(name)
  798.             umsg.String(table.concat(bonuses,"|"))
  799.             umsg.String(tostring((unlockable and 1 or 0)))
  800.             umsg.String(tostring(unlockprice))
  801.         umsg.End()
  802.        
  803.         DB.Query("INSERT INTO classes(name,bonuses,unlockable,unlockprice) VALUES('"..name.."','"..table.concat(bonuses,"|").."',"..(unlockable and 1 or 0)..","..unlockprice..") ON DUPLICATE KEY UPDATE name=VALUES(name),bonuses=VALUES(bonuses),unlockable=VALUES(unlockable),unlockprice=VALUES(unlockprice)")
  804.     end
  805. end)
  806.  
  807. concommand.Add("EditClass",function(ply,cmd,args)
  808.     if ply:IsSuperAdmin() then
  809.         local oldname = args[1]
  810.         local name = args[2]
  811.         local bonuses = string.Explode("|",args[3])
  812.         local unlockable = (tonumber(args[4]) == 1 and true or false)
  813.         local unlockprice = tonumber(args[5])
  814.        
  815.         for k,v in pairs(bonuses) do
  816.             bonuses[k] = tonumber(v)
  817.         end
  818.        
  819.         local num = 1
  820.         for k,v in pairs(Classes) do
  821.             if v[1] == oldname then
  822.                 num = k
  823.                 break
  824.             end
  825.         end
  826.        
  827.         local class = {name,bonuses,unlockable,unlockprice}
  828.         Classes[num] = class
  829.        
  830.         umsg.Start("EditClass")
  831.             umsg.String(oldname)
  832.             umsg.String(name)
  833.             umsg.String(table.concat(bonuses,"|"))
  834.             umsg.String(tostring((unlockable and 1 or 0)))
  835.             umsg.String(tostring(unlockprice))
  836.         umsg.End()
  837.        
  838.         DB.Query("UPDATE classes SET name='"..name.."',bonuses='"..table.concat(bonuses,"|").."',unlockable="..(unlockable and 1 or 0)..",unlockprice="..unlockprice.."")
  839.     end
  840. end)
  841.  
  842. concommand.Add("RemoveClass",function(ply,cmd,args)
  843.     if ply:IsSuperAdmin() then
  844.         local name = args[1]
  845.        
  846.         local num = 1
  847.         for k,v in pairs(Classes) do
  848.             if v[1] == name then
  849.                 num = k
  850.                 break
  851.             end
  852.         end
  853.        
  854.         table.remove(Classes,num)
  855.        
  856.         umsg.Start("RemoveClass")
  857.             umsg.String(name)
  858.         umsg.End()
  859.        
  860.         DB.Query("DELETE FROM classes WHERE name='"..name.."'")
  861.     end
  862. end)
  863.  
  864. concommand.Add("UnlockClass",function(ply,cmd,args)
  865.     local name = args[1]
  866.     local data = GetClassByName(name)
  867.     local unlockable = data[3]
  868.     local price = data[4]
  869.     if unlockable then
  870.         if not table.HasValue(ply.Data.UnlockedClasses,name) then
  871.             if ply:CanAfford(price) then
  872.                 table.insert(ply.Data.UnlockedClasses,name)
  873.                 umsg.Start("UnlockClass",ply)
  874.                     umsg.String(name)
  875.                 umsg.End()
  876.                 ply:TakeMoney(price)
  877.                 local sid = ply:SteamID()
  878.                
  879.                 DB.Query("UPDATE players SET unlockedclasses='"..table.concat(ply.Data.UnlockedClasses,"|").."' WHERE steamid='"..sid.."'")
  880.                
  881.                 ply:ChatPrint("Unlocked "..name)
  882.             else
  883.                 ply:ChatPrint("You cant afford that.")
  884.             end
  885.         else
  886.             ply:ChatPrint("You have already unlocked this class.")
  887.         end
  888.     else
  889.         ply:ChatPrint("The class "..name.." isnt unlockable.")
  890.     end
  891. end)
  892.  
  893. concommand.Add("GenerateAlphaKey",function(ply,cmd,args)
  894.     if ply:IsSuperAdmin() then
  895.         local len = 20
  896.         local key = {}
  897.         local exists = false
  898.        
  899.         local chars = {48,49,50,51,52,53,54,55,56,57,65,66,67,68,69,70,78,79,80,81,82,83,84,85,86,87,88,89,90,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122}
  900.         for i=1,len do
  901.             table.insert(key,string.char(table.Random(chars)))
  902.         end
  903.        
  904.         local _key = table.concat(key,"")
  905.        
  906.         local dir = "underworld_saves/alphakeys/"
  907.         local keys = file.FindDir(dir.."*")
  908.         for _,v in pairs(keys) do
  909.             if _key == v then
  910.                 exists = true
  911.             end
  912.         end
  913.        
  914.         if not exists then
  915.             file.Write(dir.._key.."/".."steamid.txt","")
  916.             ply:ChatPrint("Key Generated: ".._key)
  917.         else
  918.             ply:ChatPrint("Generating somehow failed, please try again.")
  919.         end
  920.     end
  921. end)
  922.  
  923. concommand.Add("GetAlphaKeys",function(ply,cmd,args)
  924.     if ply:IsSuperAdmin() then
  925.         local filter = args[1]
  926.         local dir = "underworld_saves/alphakeys/"
  927.         local keys = file.FindDir(dir.."*")
  928.         local tbl = {}
  929.         for k,v in pairs(keys) do
  930.             tbl[k] = {}
  931.             local used = false
  932.            
  933.             if file.Read(dir..v.."/steamid.txt") != "" then
  934.                 used = true
  935.                 tbl[k].usedby = file.Read(dir..v.."/steamid.txt")
  936.             else
  937.                 used = false
  938.             end
  939.            
  940.             tbl[k].key = v
  941.             tbl[k].used = used
  942.         end
  943.        
  944.         for k,v in pairs(tbl) do
  945.             if filter == "used" then
  946.                 if v.used then
  947.                     ply:PrintMessage(HUD_PRINTCONSOLE,(v.used and "Used: " or "Not Used: ")..(v.key)..(v.used and " ("..v.usedby..")" or ""))
  948.                 end
  949.             elseif filter == "notused" then
  950.                 if not v.used then
  951.                     ply:PrintMessage(HUD_PRINTCONSOLE,(v.used and "Used: " or "Not Used: ")..(v.key)..(v.used and " ("..v.usedby..")" or ""))
  952.                 end
  953.             else
  954.                 ply:PrintMessage(HUD_PRINTCONSOLE,(v.used and "Used: " or "Not Used: ")..(v.key)..(v.used and " ("..v.usedby..")" or ""))
  955.             end
  956.         end
  957.     end
  958. end)
  959.  
  960. concommand.Add("AlphaKeyMenu",function(ply,cmd,args)
  961.     if ply:IsSuperAdmin() then
  962.         local dir = "underworld_saves/alphakeys/"
  963.         local keys = file.FindDir(dir.."*")
  964.         local tbl = {}
  965.         for k,v in pairs(keys) do
  966.             tbl[k] = {}
  967.             local used = false
  968.            
  969.             if file.Read(dir..v.."/steamid.txt") != "" then
  970.                 used = true
  971.                 tbl[k].usedby = file.Read(dir..v.."/steamid.txt")
  972.                 tbl[k].usedbyname = file.Read(dir..v.."/name.txt")
  973.             else
  974.                 used = false
  975.             end
  976.            
  977.             tbl[k].key = v
  978.             tbl[k].used = used
  979.         end
  980.        
  981.         if table.Count(tbl) == 0 then
  982.             ply:ChatPrint("There are no alpha keys, generating one.")
  983.             ply:ConCommand("GenerateAlphaKey")
  984.             timer.Simple(0.1,function() ply:ChatPrint("Done, try again.") end,ply)
  985.             return
  986.         end
  987.         ply:ChatPrint("Sending data, please wait.")
  988.        
  989.         ply.num = 1
  990.         ply.keyspamtime = CurTime()
  991.         timer.Create("SendDataSlowlyForFucksSake_"..ply:SteamID(),0.01,0,function(tbl,ply)
  992.             if ply.num <= table.Count(tbl) then
  993.                 if ply.num <= table.Count(tbl) then
  994.                     for i=0,table.Count(tbl),5 do
  995.                         if ply.num == i or ply.num == table.Count(tbl) then
  996.                             ply:ChatPrint(ply.num.."/"..table.Count(tbl))
  997.                             break
  998.                         end
  999.                     end
  1000.                 else
  1001.                     ply:ChatPrint(ply.num.."/"..table.Count(tbl))
  1002.                 end
  1003.                 local v = tbl[ply.num]
  1004.                 umsg.Start("GetAlphaKeys",ply)
  1005.                     umsg.Bool(ply.num == 1)
  1006.                     umsg.String(v.key)
  1007.                     umsg.Bool(v.used)
  1008.                     umsg.String(v.usedby or "none")
  1009.                     umsg.String(v.usedbyname or "none")
  1010.                 umsg.End()
  1011.                 ply.num = ply.num + 1
  1012.             else
  1013.                 ply:ChatPrint("Done, sending "..(ply.num-1).." keys took "..(CurTime()-ply.keyspamtime).. " seconds.")
  1014.                 umsg.Start("AlphaKeyList",ply)
  1015.                 umsg.End()
  1016.                 timer.Destroy("SendDataSlowlyForFucksSake_"..ply:SteamID())
  1017.             end
  1018.         end,tbl,ply)
  1019.     end
  1020. end)
  1021.  
  1022. concommand.Add("UseAlphaKey",function(ply,cmd,args)
  1023.     if ply.ActivatingKey then
  1024.         local usekey = args[1]
  1025.         local dir = "underworld_saves/alphakeys/"
  1026.         local keys = file.FindDir(dir.."*")
  1027.         local tbl = {}
  1028.         for k,v in pairs(keys) do
  1029.             local used = false
  1030.            
  1031.             if file.Read(dir..v.."/steamid.txt") != "" then
  1032.                 used = true
  1033.             else
  1034.                 used = false
  1035.             end
  1036.            
  1037.             tbl[k] = {}
  1038.             tbl[k].key = v
  1039.             tbl[k].used = used
  1040.         end
  1041.        
  1042.         local done = false
  1043.        
  1044.         for k,v in pairs(tbl) do
  1045.             if v.key == usekey and not v.used then
  1046.                 file.Write("underworld_saves/alphakeys/"..(v.key).."/steamid.txt",ply:SteamID())
  1047.                 file.Write("underworld_saves/alphakeys/"..(v.key).."/name.txt",ply:Name())
  1048.                 ply:UnLock()
  1049.                 ply:ChatPrint("Welcome, "..ply:Name())
  1050.                 ply.ActivatingKey = false
  1051.                 done = true
  1052.                 break
  1053.             end
  1054.         end
  1055.        
  1056.         if not done then
  1057.             umsg.Start("AlphaKeyMenu",ply)
  1058.             umsg.End()
  1059.         end
  1060.     end
  1061. end)
  1062.  
  1063. concommand.Add("Destiny",function(ply,cmd,args)
  1064.     local destiny = args[1]
  1065.     if !ply:Alive() and ply.CanRespawn then
  1066.         if destiny == "1" then
  1067.             ply:Spawn()
  1068.         elseif destiny == "2" then
  1069.             local spawns = {}
  1070.             if ply:IsUserGroup("donator") or ply:IsUserGroup("silvervip") or ply:IsUserGroup("goldvip") or ply:IsUserGroup("platinumvip") or ply:IsUserGroup("diamondvip") or ply:IsAdmin() then
  1071.                 spawns = ents.FindByClass( "info_player_counterterrorist" )
  1072.             else
  1073.                 spawns = ents.FindByClass( "info_player_start" )
  1074.             end
  1075.             ply:Spawn()
  1076.             ply:SetPos(table.Random(spawns):GetPos())
  1077.             timer.Create(ply:SteamID().."_inthefuckingmarket",1,30,function(ply)
  1078.                 if ply and ply:IsValid() then
  1079.                     ply.InMarketZone = true
  1080.                 end
  1081.             end,ply)
  1082.             ply:ChatPrint("You are now in the market, press F3 to return to the battlefield.")
  1083.         end
  1084.     end
  1085. end)
  1086.  
  1087. concommand.Add("AddWeaponSocketable",function(ply,cmd,args)
  1088.     if ply:IsSuperAdmin() then
  1089.         local name = args[1]
  1090.         local bonuses = string.Explode("|",args[2])
  1091.         local num = tostring(table.Count(WeaponSocketTable)+1)
  1092.        
  1093.         for k,v in pairs(bonuses) do
  1094.             bonuses[k] = tonumber(v)
  1095.         end
  1096.        
  1097.         local sock = {name,bonuses}
  1098.         WeaponSocketTable[num] = sock
  1099.        
  1100.         umsg.Start("AddWepSocketable")
  1101.             umsg.String(tostring(table.Count(WeaponSocketTable)))
  1102.             umsg.String(name)
  1103.             umsg.String(table.concat(bonuses,"|"))
  1104.         umsg.End()
  1105.        
  1106.         DB.Query("INSERT INTO weapon_socketables(num,name,bonuses) VALUES('"..num.."','"..name.."','"..table.concat(bonuses,"|").."')")
  1107.     end
  1108. end)
  1109.  
  1110. concommand.Add("EditWeaponSocketable",function(ply,cmd,args)
  1111.     if ply:IsSuperAdmin() then
  1112.         local num = args[1]
  1113.         local name = args[2]
  1114.         local bonuses = string.Explode("|",args[3])
  1115.        
  1116.         for k,v in pairs(bonuses) do
  1117.             bonuses[k] = tonumber(v)
  1118.         end
  1119.        
  1120.         local sock = {name,bonuses}
  1121.         WeaponSocketTable[num] = sock
  1122.        
  1123.         umsg.Start("EditWeaponSocketable")
  1124.             umsg.String(num)
  1125.             umsg.String(name)
  1126.             umsg.String(table.concat(bonuses,"|"))
  1127.         umsg.End()
  1128.        
  1129.         DB.Query("UPDATE weapon_socketables SET name='"..name.."',bonuses='"..table.concat(bonuses,"|").."' WHERE num='"..num.."'")
  1130.     end
  1131. end)
  1132.  
  1133. concommand.Add("RemoveWeaponSocketable",function(ply,cmd,args)
  1134.     if ply:IsSuperAdmin() then
  1135.         local num = args[1]
  1136.        
  1137.         umsg.Start("RemoveWepSocketable")
  1138.             umsg.String(num)
  1139.         umsg.End()
  1140.        
  1141.         for k,v in pairs(WeaponSocketTable) do
  1142.             if k == num then
  1143.                 table.remove(WeaponSocketTable,k)
  1144.                 break
  1145.             end
  1146.         end
  1147.        
  1148.         DB.Query("DELETE FROM weapon_socketables WHERE num='"..num.."'")
  1149.     end
  1150. end)
  1151.  
  1152. concommand.Add("BuyWeaponSocketable",function(ply,cmd,args)
  1153.     local id = args[1]
  1154.     local socketdata = WeaponSocketTable[id]
  1155.     local name = socketdata[1]
  1156.     local tier = socketdata[2][6]
  1157.    
  1158.     local price = 0
  1159.     if tier == 1 then
  1160.         price = 50000
  1161.     elseif tier == 2 then
  1162.         price = 100000
  1163.     elseif tier == 3 then
  1164.         price = 200000
  1165.     elseif tier == 4 then
  1166.         price = 350000
  1167.     elseif tier == 5 then
  1168.         price = 500000
  1169.     elseif tier == 6 then
  1170.         price = 1000000
  1171.     else
  1172.         return
  1173.     end
  1174.    
  1175.     if ply:CanAfford(price) then
  1176.         ply:AddToInventory({Name = name,ItemType="wepsocketable",Data={num=id},Sockets={}})
  1177.         ply:TakeMoney(price)
  1178.         ply:ChatPrint("Succesfully bought "..name..".")
  1179.     else
  1180.         ply:ChatPrint("You can't afford that.")
  1181.     end
  1182. end)
  1183.  
  1184. concommand.Add("AddArmorSocketable",function(ply,cmd,args)
  1185.     if ply:IsSuperAdmin() then
  1186.         local name = args[1]
  1187.         local bonuses = string.Explode("|",args[2])
  1188.         local num = tostring(table.Count(ArmorSocketTable)+1)
  1189.        
  1190.         for k,v in pairs(bonuses) do
  1191.             bonuses[k] = tonumber(v)
  1192.         end
  1193.        
  1194.         local sock = {name,bonuses}
  1195.         ArmorSocketTable[num] = sock
  1196.        
  1197.         umsg.Start("AddArmorSocketable")
  1198.             umsg.String(num)
  1199.             umsg.String(name)
  1200.             umsg.String(table.concat(bonuses,"|"))
  1201.         umsg.End()
  1202.        
  1203.         DB.Query("INSERT INTO armor_socketables(num,name,bonuses) VALUES('"..num.."','"..name.."','"..table.concat(bonuses,"|").."')")
  1204.     end
  1205. end)
  1206.  
  1207. concommand.Add("EditArmorSocketable",function(ply,cmd,args)
  1208.     if ply:IsSuperAdmin() then
  1209.         local num = args[1]
  1210.         local name = args[2]
  1211.         local bonuses = string.Explode("|",args[3])
  1212.        
  1213.         for k,v in pairs(bonuses) do
  1214.             bonuses[k] = tonumber(v)
  1215.         end
  1216.        
  1217.         local sock = {name,bonuses}
  1218.         ArmorSocketTable[num] = sock
  1219.        
  1220.         umsg.Start("EditArmorSocketable")
  1221.             umsg.String(num)
  1222.             umsg.String(name)
  1223.             umsg.String(table.concat(bonuses,"|"))
  1224.         umsg.End()
  1225.        
  1226.         DB.Query("UPDATE armor_socketables SET name='"..name.."',bonuses='"..table.concat(bonuses,"|").."' WHERE num='"..num.."'")
  1227.     end
  1228. end)
  1229.  
  1230. concommand.Add("RemoveArmorSocketable",function(ply,cmd,args)
  1231.     if ply:IsSuperAdmin() then
  1232.         local num = args[1]
  1233.        
  1234.         umsg.Start("RemoveArmorSocketable")
  1235.             umsg.String(num)
  1236.         umsg.End()
  1237.        
  1238.         local num = 0
  1239.         for k,v in pairs(ArmorSocketTable) do
  1240.             if k == num then
  1241.                 table.remove(ArmorSocketTable,k)
  1242.                 break
  1243.             end
  1244.         end
  1245.        
  1246.         DB.Quer("DELETE FROM armor_socketables WHERE num='"..num.."'")
  1247.     end
  1248. end)
  1249.  
  1250. concommand.Add("BuyArmorSocketable",function(ply,cmd,args)
  1251.     local id = args[1]
  1252.     local socketdata = ArmorSocketTable[id]
  1253.     local name = socketdata[1]
  1254.     local tier = socketdata[2][6]
  1255.    
  1256.     local price = 0
  1257.     if tier == 1 then
  1258.         price = 50000
  1259.     elseif tier == 2 then
  1260.         price = 100000
  1261.     elseif tier == 3 then
  1262.         price = 200000
  1263.     elseif tier == 4 then
  1264.         price = 350000
  1265.     elseif tier == 5 then
  1266.         price = 500000
  1267.     elseif tier == 6 then
  1268.         price = 1000000
  1269.     else
  1270.         return
  1271.     end
  1272.    
  1273.     if ply:CanAfford(price) then
  1274.         ply:AddToInventory({Name = name,ItemType="armorsocketable",Data={num=id},Sockets={}})
  1275.         ply:TakeMoney(price)
  1276.         ply:ChatPrint("Succesfully bought "..name..".")
  1277.     else
  1278.         ply:ChatPrint("You can't afford that.")
  1279.     end
  1280. end)
  1281.  
Advertisement
Add Comment
Please, Sign In to add comment