Advertisement
Friks12829

Untitled

Dec 29th, 2019
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.65 KB | None | 0 0
  1. /*---------------------------------------------------------------------------
  2. Создано для R6S by Friks
  3. ---------------------------------------------------------------------------*/
  4.  
  5. timer.Simple(3, function()
  6.  
  7. include('areas_config.lua')
  8. AddCSLuaFile('areas_config.lua')
  9. util.AddNetworkString('org_area_change')
  10.  
  11. local nextCheck = CurTime()
  12. function CheckPlayersPosition()
  13.  
  14. if (nextCheck >= CurTime()) then return end
  15. if (player.GetCount() <= 0) then return end
  16.  
  17. for name, adata in pairs(ORG_AREAS) do
  18. for _, ply in pairs(ents.FindInBox(adata.pos1, adata.pos2)) do
  19. if !ply:IsPlayer() or !ply:Alive() or table.HasValue(adata.allowedTeams, ply:Team()) or (ply.InOrgArea != nil and ply.InOrgArea == name) then continue end
  20.  
  21. ply.InOrgArea = name
  22. net.Start('org_area_change')
  23. net.WriteBool(true)
  24. net.WriteString(name)
  25. net.Send(ply)
  26.  
  27. timer.Create('org_area'..ply:AccountID(), 1, adata.time, function()
  28. if !IsValid(ply) or ply.InOrgArea == nil then return end
  29.  
  30. for k, adata2 in pairs(ORG_AREAS) do
  31. if k != ply.InOrgArea then continue end
  32.  
  33. local IsFind = false
  34. for _, ply2 in pairs(ents.FindInBox(adata2.pos1, adata2.pos2)) do
  35. if ply2 != ply then continue end
  36.  
  37. IsFind = !IsFind
  38.  
  39. break
  40. end
  41.  
  42. if IsFind == false then
  43. ply.InOrgArea = nil
  44.  
  45. net.Start('org_area_change')
  46. net.WriteBool(false)
  47. net.WriteString("")
  48. net.Send(ply)
  49.  
  50. timer.Remove('org_area'..ply:AccountID())
  51. elseif( timer.RepsLeft( 'org_area'..ply:AccountID() ) <= 0 ) then
  52. adata2.func(ply)
  53. ply.InOrgArea = nil
  54.  
  55. net.Start('org_area_change')
  56. net.WriteBool(false)
  57. net.WriteString("")
  58. net.Send(ply)
  59. end
  60.  
  61. break
  62. end
  63. end)
  64. end
  65. end
  66.  
  67. nextCheck = CurTime() + 1
  68. end
  69.  
  70. hook.Add('Tick', "CheckPlysPositions", CheckPlayersPosition)
  71.  
  72. end)
  73.  
  74. /*---------------------------------------------------------------------------
  75. Создано для R6S by Friks
  76. ---------------------------------------------------------------------------*/
  77.  
  78. local function CreateInventory()
  79. if not sql.TableExists("Inventory") then
  80. sql.Query("CREATE TABLE Inventory (steamid VARCHAR(255), type TEXT NOT NULL, class TEXT NOT NULL, count INTEGER)")
  81. print('Таблица создана!')
  82. end
  83. end
  84. hook.Add( "Initialize", "CreateInventory", CreateInventory )
  85.  
  86.  
  87. local meta = FindMetaTable'Player'
  88.  
  89. local function LoadInvetory(ply)
  90.  
  91. if not ply:IsValid() then return end
  92.  
  93. local Inventory = sql.Query("SELECT * FROM Inventory WHERE steamid = '"..ply:SteamID().."';") or {}
  94.  
  95. ply.inv = Inventory
  96.  
  97. end
  98.  
  99. hook.Add('PlayerInitialSpawn', 'LoadInvetory', LoadInvetory)
  100.  
  101.  
  102.  
  103.  
  104.  
  105. function meta:GetInventory()
  106.  
  107.  
  108. end
  109.  
  110. function meta:SaveInentory()
  111.  
  112.  
  113. end
  114.  
  115. function meta:AddItem(type, class, count)
  116. if not IsValid(self) then return end
  117. -- if table.HasValue(cfg.Inventory.BlackListItems, class) then return end
  118.  
  119.  
  120.  
  121. local Items = sql.Query("SELECT * FROM Inventory WHERE steamid = '"..self:SteamID().."' AND class = '"..class.."';") or {}
  122.  
  123. if Items[1].count != nil then
  124.  
  125. local ItemCount = Items[1].count + count
  126.  
  127.  
  128. sql.Query("UPDATE Inventory SET count = " .. ItemCount .. " WHERE SteamID = '" .. self:SteamID().."' AND class='"..class.."';")
  129.  
  130. print('Количество обновлено.')
  131.  
  132. else
  133.  
  134. sql.Query("INSERT INTO Inventory VALUES( '"..self:SteamID().."', '"..type.."', '" ..class.. "', '"..count.."');")
  135.  
  136. print('Предмет добавлен.')
  137.  
  138. end
  139.  
  140. end
  141.  
  142. function meta:RemoveItem(class)
  143.  
  144. end
  145.  
  146. function meta:ClearInventory()
  147.  
  148. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement