Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*---------------------------------------------------------------------------
- Создано для R6S by Friks
- ---------------------------------------------------------------------------*/
- timer.Simple(3, function()
- include('areas_config.lua')
- AddCSLuaFile('areas_config.lua')
- util.AddNetworkString('org_area_change')
- local nextCheck = CurTime()
- function CheckPlayersPosition()
- if (nextCheck >= CurTime()) then return end
- if (player.GetCount() <= 0) then return end
- for name, adata in pairs(ORG_AREAS) do
- for _, ply in pairs(ents.FindInBox(adata.pos1, adata.pos2)) do
- if !ply:IsPlayer() or !ply:Alive() or table.HasValue(adata.allowedTeams, ply:Team()) or (ply.InOrgArea != nil and ply.InOrgArea == name) then continue end
- ply.InOrgArea = name
- net.Start('org_area_change')
- net.WriteBool(true)
- net.WriteString(name)
- net.Send(ply)
- timer.Create('org_area'..ply:AccountID(), 1, adata.time, function()
- if !IsValid(ply) or ply.InOrgArea == nil then return end
- for k, adata2 in pairs(ORG_AREAS) do
- if k != ply.InOrgArea then continue end
- local IsFind = false
- for _, ply2 in pairs(ents.FindInBox(adata2.pos1, adata2.pos2)) do
- if ply2 != ply then continue end
- IsFind = !IsFind
- break
- end
- if IsFind == false then
- ply.InOrgArea = nil
- net.Start('org_area_change')
- net.WriteBool(false)
- net.WriteString("")
- net.Send(ply)
- timer.Remove('org_area'..ply:AccountID())
- elseif( timer.RepsLeft( 'org_area'..ply:AccountID() ) <= 0 ) then
- adata2.func(ply)
- ply.InOrgArea = nil
- net.Start('org_area_change')
- net.WriteBool(false)
- net.WriteString("")
- net.Send(ply)
- end
- break
- end
- end)
- end
- end
- nextCheck = CurTime() + 1
- end
- hook.Add('Tick', "CheckPlysPositions", CheckPlayersPosition)
- end)
- /*---------------------------------------------------------------------------
- Создано для R6S by Friks
- ---------------------------------------------------------------------------*/
- local function CreateInventory()
- if not sql.TableExists("Inventory") then
- sql.Query("CREATE TABLE Inventory (steamid VARCHAR(255), type TEXT NOT NULL, class TEXT NOT NULL, count INTEGER)")
- print('Таблица создана!')
- end
- end
- hook.Add( "Initialize", "CreateInventory", CreateInventory )
- local meta = FindMetaTable'Player'
- local function LoadInvetory(ply)
- if not ply:IsValid() then return end
- local Inventory = sql.Query("SELECT * FROM Inventory WHERE steamid = '"..ply:SteamID().."';") or {}
- ply.inv = Inventory
- end
- hook.Add('PlayerInitialSpawn', 'LoadInvetory', LoadInvetory)
- function meta:GetInventory()
- end
- function meta:SaveInentory()
- end
- function meta:AddItem(type, class, count)
- if not IsValid(self) then return end
- -- if table.HasValue(cfg.Inventory.BlackListItems, class) then return end
- local Items = sql.Query("SELECT * FROM Inventory WHERE steamid = '"..self:SteamID().."' AND class = '"..class.."';") or {}
- if Items[1].count != nil then
- local ItemCount = Items[1].count + count
- sql.Query("UPDATE Inventory SET count = " .. ItemCount .. " WHERE SteamID = '" .. self:SteamID().."' AND class='"..class.."';")
- print('Количество обновлено.')
- else
- sql.Query("INSERT INTO Inventory VALUES( '"..self:SteamID().."', '"..type.."', '" ..class.. "', '"..count.."');")
- print('Предмет добавлен.')
- end
- end
- function meta:RemoveItem(class)
- end
- function meta:ClearInventory()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement