mirror of
https://github.com/lifestorm/wnsrc.git
synced 2025-12-17 13:53:45 +03:00
Upload
This commit is contained in:
174
gamemodes/darkrp/plugins/goi_factory/3d2d/cl_nets.lua
Normal file
174
gamemodes/darkrp/plugins/goi_factory/3d2d/cl_nets.lua
Normal file
@@ -0,0 +1,174 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
net.Receive("ix.terminal.CWUWorkshiftData", function(len, client)
|
||||
local ent = net.ReadEntity()
|
||||
local data = util.JSONToTable(net.ReadString())
|
||||
|
||||
local terminalPanel = ent.terminalPanel
|
||||
|
||||
if terminalPanel then
|
||||
if !IsValid(terminalPanel.shiftPanel) then
|
||||
terminalPanel:ProceedShiftBuilding(data)
|
||||
else
|
||||
terminalPanel:PopulateWorkshift(data)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
net.Receive("ix.terminal.CWUWorkshiftSound", function()
|
||||
surface.PlaySound(ix.config.Get("broadcastSound", "ambience/3d-sounds/alarms/workshiftalarm.ogg"))
|
||||
end)
|
||||
|
||||
net.Receive("ix.terminal.AuthError", function(len, client)
|
||||
local ent = net.ReadEntity()
|
||||
|
||||
local terminalPanel = ent.terminalPanel
|
||||
|
||||
if terminalPanel then
|
||||
terminalPanel:AuthError()
|
||||
end
|
||||
end)
|
||||
|
||||
net.Receive("ix.terminal.DiscAttach", function(len, client)
|
||||
local ent = net.ReadEntity()
|
||||
local disc = net.ReadString()
|
||||
|
||||
local terminalPanel = ent.terminalPanel
|
||||
if terminalPanel then
|
||||
terminalPanel:SetDisc(disc)
|
||||
terminalPanel:OnDiscAttach()
|
||||
end
|
||||
end)
|
||||
|
||||
net.Receive("ix.terminal.DiscDetach", function(len, client)
|
||||
local ent = net.ReadEntity()
|
||||
local terminalPanel = ent.terminalPanel
|
||||
|
||||
if terminalPanel then
|
||||
terminalPanel:SetDisc(nil)
|
||||
terminalPanel:OnDiscDetach()
|
||||
end
|
||||
end)
|
||||
|
||||
net.Receive("ix.terminal.Scan", function(len, client)
|
||||
local ent = net.ReadEntity()
|
||||
local terminalPanel = ent.terminalPanel
|
||||
|
||||
if terminalPanel then
|
||||
terminalPanel:Encode()
|
||||
end
|
||||
end)
|
||||
|
||||
net.Receive("ix.terminal.UpdateCWUTerminals", function(len)
|
||||
local cityTbl = util.JSONToTable(net.ReadString())
|
||||
|
||||
local ent = net.ReadEntity()
|
||||
local terminalPanel = ent.terminalPanel
|
||||
if terminalPanel then
|
||||
terminalPanel:Populate(cityTbl)
|
||||
end
|
||||
end)
|
||||
|
||||
net.Receive("ix.terminal.RequestCities", function(len)
|
||||
local cities = util.JSONToTable(net.ReadString())
|
||||
local ent = net.ReadEntity()
|
||||
local terminalPanel = ent.terminalPanel
|
||||
|
||||
if terminalPanel then
|
||||
terminalPanel:CreateMarketPanel(cities)
|
||||
end
|
||||
end)
|
||||
|
||||
net.Receive("ix.terminal.RequestMainCityInfo", function(len)
|
||||
local cityInfo = util.JSONToTable(net.ReadString())
|
||||
local budgets = util.JSONToTable(net.ReadString())
|
||||
local ent = net.ReadEntity()
|
||||
local option = net.ReadString()
|
||||
local terminalPanel = ent.terminalPanel
|
||||
|
||||
if terminalPanel then
|
||||
if option == "status" then
|
||||
terminalPanel:CreateStatusPanel(cityInfo, budgets)
|
||||
elseif option == "cart" then
|
||||
terminalPanel:BuildCart(terminalPanel.cartPanel, cityInfo)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
net.Receive("ix.terminal.GetCityStock", function(len)
|
||||
local items = util.JSONToTable(net.ReadString())
|
||||
local ent = net.ReadEntity()
|
||||
local terminalPanel = ent.terminalPanel
|
||||
|
||||
if terminalPanel then
|
||||
terminalPanel:CreateStock(items)
|
||||
end
|
||||
end)
|
||||
|
||||
net.Receive("ix.terminal.turnOn", function(len)
|
||||
local ent = net.ReadEntity()
|
||||
local client = net.ReadEntity()
|
||||
local data = net.ReadString()
|
||||
data = util.JSONToTable(data)
|
||||
|
||||
if IsValid(ent) then
|
||||
ent:CreateStartScreen(client, data)
|
||||
end
|
||||
end)
|
||||
|
||||
net.Receive("ix.terminal.turnOff", function(len)
|
||||
local ent = net.ReadEntity()
|
||||
|
||||
if IsValid(ent) then
|
||||
ent:PurgeScreenPanels()
|
||||
end
|
||||
end)
|
||||
|
||||
net.Receive("ix.terminal.CWUCardInserted", function(len)
|
||||
local ent = net.ReadEntity()
|
||||
|
||||
local terminalPanel = ent.terminalPanel
|
||||
|
||||
if terminalPanel then
|
||||
terminalPanel:OnCWUCardInserted()
|
||||
end
|
||||
end)
|
||||
|
||||
net.Receive("ix.terminal.CWUCardRemoved", function(len)
|
||||
local ent = net.ReadEntity()
|
||||
|
||||
local terminalPanel = ent.terminalPanel
|
||||
|
||||
if terminalPanel then
|
||||
terminalPanel:OnCWUCardRemoved()
|
||||
end
|
||||
end)
|
||||
|
||||
net.Receive("ix.terminal.SendCIDInfo", function(len)
|
||||
local genData = util.JSONToTable(net.ReadString())
|
||||
local ent = net.ReadEntity()
|
||||
|
||||
local terminalPanel = ent.terminalPanel
|
||||
|
||||
if terminalPanel then
|
||||
terminalPanel:OnCIDInserted(genData)
|
||||
end
|
||||
end)
|
||||
|
||||
net.Receive("ix.terminal.SendCIDRemoved", function(len)
|
||||
local ent = net.ReadEntity()
|
||||
|
||||
local terminalPanel = ent.terminalPanel
|
||||
|
||||
if terminalPanel then
|
||||
terminalPanel:OnCIDRemoved()
|
||||
end
|
||||
end)
|
||||
98
gamemodes/darkrp/plugins/goi_factory/3d2d/cl_panels.lua
Normal file
98
gamemodes/darkrp/plugins/goi_factory/3d2d/cl_panels.lua
Normal file
@@ -0,0 +1,98 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
ix.factoryPanels = ix.factoryPanels or {}
|
||||
ix.factoryPanels.list = ix.factoryPanels.list or {}
|
||||
|
||||
function ix.factoryPanels:CreatePanel(panel, ent)
|
||||
local pnl = vgui.Create(panel)
|
||||
pnl:SetTerminalEntity(ent)
|
||||
ent.terminalPanel = pnl
|
||||
ix.factoryPanels.list[#ix.factoryPanels.list + 1] = pnl
|
||||
return pnl
|
||||
end
|
||||
|
||||
function ix.factoryPanels:PurgeEntityPanels(ent)
|
||||
for index, panel in pairs(self.list) do
|
||||
if panel:GetTerminalEntity() == ent then
|
||||
panel:Destroy()
|
||||
table.remove(self.list, index)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- fonts
|
||||
|
||||
surface.CreateFont( "WNTerminalSmallText", {
|
||||
font = "Open Sans",
|
||||
extended = false,
|
||||
size = 32,
|
||||
weight = 550,
|
||||
scanlines = 2,
|
||||
antialias = true,
|
||||
outline = true
|
||||
} )
|
||||
|
||||
surface.CreateFont( "WNTerminalMediumSmallerText", {
|
||||
font = "Open Sans",
|
||||
extended = false,
|
||||
size = 38,
|
||||
weight = 550,
|
||||
scanlines = 2,
|
||||
antialias = true,
|
||||
outline = true
|
||||
} )
|
||||
|
||||
surface.CreateFont( "WNTerminalMediumText", {
|
||||
font = "Open Sans",
|
||||
extended = false,
|
||||
size = 48,
|
||||
weight = 550,
|
||||
scanlines = 2,
|
||||
antialias = true,
|
||||
outline = true
|
||||
} )
|
||||
|
||||
surface.CreateFont( "WNTerminalLargeText", {
|
||||
font = "Open Sans",
|
||||
extended = false,
|
||||
size = 96,
|
||||
weight = 550,
|
||||
scanlines = 2,
|
||||
antialias = true,
|
||||
outline = true
|
||||
} )
|
||||
|
||||
surface.CreateFont( "WNTerminalMoreLargerText", {
|
||||
font = "Open Sans",
|
||||
extended = false,
|
||||
size = 114,
|
||||
weight = 550,
|
||||
scanlines = 2,
|
||||
antialias = true,
|
||||
outline = true
|
||||
} )
|
||||
|
||||
surface.CreateFont( "WNTerminalVeryLargeText", {
|
||||
font = "Open Sans",
|
||||
extended = false,
|
||||
size = 600,
|
||||
weight = 550,
|
||||
scanlines = 2,
|
||||
antialias = true,
|
||||
outline = true
|
||||
} )
|
||||
|
||||
surface.CreateFont("ButtonLabel", {
|
||||
font = "Roboto",
|
||||
size = 70,
|
||||
antialias = true,
|
||||
extended = true
|
||||
})
|
||||
377
gamemodes/darkrp/plugins/goi_factory/3d2d/sv_nets.lua
Normal file
377
gamemodes/darkrp/plugins/goi_factory/3d2d/sv_nets.lua
Normal file
@@ -0,0 +1,377 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
-- one day i definitely should re-do the networking here..
|
||||
|
||||
util.AddNetworkString("ix.terminal.turnOn")
|
||||
util.AddNetworkString("ix.terminal.turnOff")
|
||||
util.AddNetworkString("ix.terminal.AuthError")
|
||||
util.AddNetworkString("ix.terminal.CWUBroadcast")
|
||||
util.AddNetworkString("ix.terminal.CWUWorkshiftBegin")
|
||||
util.AddNetworkString("ix.terminal.CWUWorkshiftEnd")
|
||||
util.AddNetworkString("ix.terminal.CWUWorkshiftPause")
|
||||
util.AddNetworkString("ix.terminal.CWUWorkshiftRewardUpdate")
|
||||
util.AddNetworkString("ix.terminal.CWUWorkshiftSound")
|
||||
util.AddNetworkString("ix.terminal.CWUWorkshiftData")
|
||||
util.AddNetworkString("ix.terminal.CWUCardInserted")
|
||||
util.AddNetworkString("ix.terminal.CWUCardRemoved")
|
||||
util.AddNetworkString("ix.terminal.SendCIDInfo")
|
||||
util.AddNetworkString("ix.terminal.SendCIDRemoved")
|
||||
util.AddNetworkString("ix.terminal.GetCityStock")
|
||||
util.AddNetworkString("ix.terminal.RequestMainCityInfo")
|
||||
util.AddNetworkString("ix.terminal.RequestCities")
|
||||
util.AddNetworkString("ix.terminal.UpdateCWUTerminals")
|
||||
util.AddNetworkString("ix.terminal.DiscAttach")
|
||||
util.AddNetworkString("ix.terminal.DiscDetach")
|
||||
util.AddNetworkString("ix.terminal.Scan")
|
||||
util.AddNetworkString("ix.terminal.Fabricate")
|
||||
util.AddNetworkString("ix.terminal.Recycle")
|
||||
util.AddNetworkString("ix.terminal.Bioprocess")
|
||||
util.AddNetworkString("ix.terminal.ToggleDepot")
|
||||
|
||||
local workshifts = ix.plugin.Get("combineutilities")
|
||||
|
||||
net.Receive("ix.terminal.CWUWorkshiftPause", function(_, client)
|
||||
local ent = net.ReadEntity()
|
||||
local wActive = GetNetVar("WorkshiftStarted", false)
|
||||
|
||||
if (client:EyePos():DistToSqr(ent:GetPos()) > 62500) then return end
|
||||
if (!ix.city:IsAuthorized(client, ent)) then return end
|
||||
if (!wActive) then return end
|
||||
|
||||
local workshiftTerminals = ents.FindByClass("ix_workshiftterminal")
|
||||
local pauseBool
|
||||
|
||||
if #workshiftTerminals > 0 then
|
||||
for _, wTerminal in pairs(workshiftTerminals) do
|
||||
if !wTerminal.workshiftStarted then continue end
|
||||
|
||||
workshifts:PauseWorkshift(wTerminal, client, !wTerminal.workshiftPaused)
|
||||
if !pauseBool then
|
||||
pauseBool = wTerminal.workshiftPaused
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if isbool(pauseBool) then
|
||||
client:NotifyLocalized("La pause d'enrengistrement est réglée sur: " .. tostring(pauseBool))
|
||||
|
||||
ix.combineNotify:AddNotification(pauseBool and "NTC:// Enrengistrement session de travail mis en pause par " .. client:GetCombineTag() or "NTC:// Enrengistrement session de travail mis en cours " .. client:GetCombineTag(), nil, client)
|
||||
end
|
||||
end)
|
||||
|
||||
net.Receive("ix.terminal.CWUWorkshiftBegin", function(_, client)
|
||||
local ent = net.ReadEntity()
|
||||
local wActive = GetNetVar("WorkshiftStarted", false)
|
||||
|
||||
if (client:EyePos():DistToSqr(ent:GetPos()) > 62500) then return end
|
||||
if (!ix.city:IsAuthorized(client, ent)) then return end
|
||||
if (wActive) then return end
|
||||
|
||||
local workshiftTerminals = ents.FindByClass("ix_workshiftterminal")
|
||||
if #workshiftTerminals > 0 then
|
||||
for _, wTerminal in pairs(workshiftTerminals) do
|
||||
wTerminal:StartWorkshift(client)
|
||||
end
|
||||
else
|
||||
return client:NotifyLocalized("Il y a pas de terminaux de travail!")
|
||||
end
|
||||
ix.combineNotify:AddNotification("NTC:// Session de travail initié par " .. client:GetCombineTag(), nil, client)
|
||||
|
||||
local idCard = ix.item.instances[ent:GetCID()]
|
||||
workshifts:AddToWorkshift(client, idCard, ent.curGenData, workshiftTerminals[1])
|
||||
workshifts:StartWorkshift()
|
||||
client:NotifyLocalized("Session de travail commencer!")
|
||||
end)
|
||||
|
||||
net.Receive("ix.terminal.CWUWorkshiftEnd", function(_, client)
|
||||
local ent = net.ReadEntity()
|
||||
local wActive = GetNetVar("WorkshiftStarted", false)
|
||||
|
||||
if (client:EyePos():DistToSqr(ent:GetPos()) > 62500) then return end
|
||||
if (!ix.city:IsAuthorized(client, ent)) then return end
|
||||
if (!wActive) then return end
|
||||
local rewards = {}
|
||||
local workshiftDataExtracted = false
|
||||
|
||||
local workshiftTerminals = ents.FindByClass("ix_workshiftterminal")
|
||||
if #workshiftTerminals > 0 then
|
||||
for _, wTerminal in pairs(workshiftTerminals) do
|
||||
if !wTerminal.workshiftStarted then continue end
|
||||
|
||||
if wTerminal.workshiftStarted and !workshiftDataExtracted then
|
||||
rewards = wTerminal.savedInfo
|
||||
workshiftDataExtracted = true
|
||||
end
|
||||
wTerminal:StopWorkshift(client)
|
||||
end
|
||||
else
|
||||
return client:NotifyLocalized("Il y a pas de terminaux de travail!")
|
||||
end
|
||||
ix.combineNotify:AddNotification("NTC:// Session de travail terminer par " .. client:GetCombineTag(), nil, client)
|
||||
|
||||
workshifts:EndWorkshift(rewards, client)
|
||||
client:NotifyLocalized("Session de travail terminer!")
|
||||
end)
|
||||
|
||||
net.Receive("ix.terminal.CWUWorkshiftRewardUpdate", function(_, client)
|
||||
local ent = net.ReadEntity()
|
||||
local data = util.JSONToTable(net.ReadString())
|
||||
local wActive = GetNetVar("WorkshiftStarted", false)
|
||||
|
||||
if (client:EyePos():DistToSqr(ent:GetPos()) > 62500) then return end
|
||||
if (!ix.city:IsAuthorized(client, ent)) then return end
|
||||
if (!wActive) then return end
|
||||
|
||||
local workshiftTerminals = ents.FindByClass("ix_workshiftterminal")
|
||||
if #workshiftTerminals > 0 then
|
||||
for _, wTerminal in pairs(workshiftTerminals) do
|
||||
if !wTerminal.workshiftStarted then continue end
|
||||
workshifts:SaveWorkshift(data, wTerminal)
|
||||
end
|
||||
else
|
||||
return client:NotifyLocalized("Il y a pas de terminaux de travail!")
|
||||
end
|
||||
end)
|
||||
|
||||
net.Receive("ix.terminal.CWUWorkshiftData", function(_, client)
|
||||
local ent = net.ReadEntity()
|
||||
|
||||
if (client:EyePos():DistToSqr(ent:GetPos()) > 62500) then return end
|
||||
if (!ix.city:IsAuthorized(client, ent)) then return end
|
||||
|
||||
local wActive = GetNetVar("WorkshiftStarted", false)
|
||||
local workshiftTerminals = ents.FindByClass("ix_workshiftterminal")
|
||||
local dataToSend = {}
|
||||
if wActive and #workshiftTerminals > 0 then
|
||||
dataToSend["participants"] = {}
|
||||
dataToSend["rewards"] = {}
|
||||
|
||||
for _, wTerminal in pairs(workshiftTerminals) do
|
||||
if !wTerminal.workshiftStarted then continue end
|
||||
|
||||
if (wTerminal.participants and istable(wTerminal.participants) and !table.IsEmpty(wTerminal.participants)) then
|
||||
for id, participant in pairs(wTerminal.participants) do
|
||||
dataToSend["participants"][id] = participant
|
||||
end
|
||||
end
|
||||
|
||||
if (wTerminal.savedInfo and istable(wTerminal.savedInfo) and !table.IsEmpty(wTerminal.savedInfo)) then
|
||||
for id, reward in pairs(wTerminal.savedInfo) do
|
||||
dataToSend["rewards"][id] = reward
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
net.Start("ix.terminal.CWUWorkshiftData")
|
||||
net.WriteEntity(ent)
|
||||
net.WriteString(util.TableToJSON(dataToSend))
|
||||
net.Send(client)
|
||||
end)
|
||||
|
||||
net.Receive("ix.terminal.CWUBroadcast", function(_, client)
|
||||
local ent = net.ReadEntity()
|
||||
if (!ent or !ent:IsValid() or ent:GetClass() != "ix_cwuterminal") then return end
|
||||
|
||||
if ((ent.nextBroadcast or 0) >= CurTime()) then return end
|
||||
if (client:EyePos():DistToSqr(ent:GetPos()) > 62500) then return end
|
||||
if (!ix.city:IsAuthorized(client, ent)) then return end
|
||||
|
||||
local broadcast = !ent:GetNetVar("broadcasting", false)
|
||||
client:SetNetVar("broadcastAuth", broadcast and broadcast or nil)
|
||||
ent:ToggleBroadcast()
|
||||
end)
|
||||
|
||||
net.Receive("ix.terminal.Bioprocess", function(len, client)
|
||||
local ent = net.ReadEntity()
|
||||
local itemID = net.ReadString()
|
||||
local isBulk = net.ReadBool()
|
||||
local amount = net.ReadInt(5)
|
||||
|
||||
if (client:EyePos():DistToSqr(ent:GetPos()) > 62500) then
|
||||
return
|
||||
end
|
||||
|
||||
local bioprocess = ent:SynthesizeFabrication(client, itemID, isBulk, amount)
|
||||
if bioprocess then
|
||||
client:NotifyLocalized(bioprocess)
|
||||
end
|
||||
end)
|
||||
|
||||
net.Receive("ix.terminal.ToggleDepot", function(len, client)
|
||||
local ent = net.ReadEntity()
|
||||
|
||||
if (client:EyePos():DistToSqr(ent:GetPos()) > 62500) then
|
||||
return
|
||||
end
|
||||
|
||||
local depotToggle = ent:ToggleDepot()
|
||||
if depotToggle then
|
||||
client:NotifyLocalized(depotToggle)
|
||||
end
|
||||
end)
|
||||
|
||||
net.Receive("ix.terminal.Recycle", function(len, client)
|
||||
local ent = net.ReadEntity()
|
||||
|
||||
if (client:EyePos():DistToSqr(ent:GetPos()) > 62500) then
|
||||
return
|
||||
end
|
||||
|
||||
local recycle = ent:Recycle(client)
|
||||
if recycle then
|
||||
client:NotifyLocalized(recycle)
|
||||
end
|
||||
end)
|
||||
|
||||
net.Receive("ix.terminal.Fabricate", function(len, client)
|
||||
local ent = net.ReadEntity()
|
||||
local isBulk = net.ReadBool()
|
||||
local amount = net.ReadInt(5)
|
||||
|
||||
if (client:EyePos():DistToSqr(ent:GetPos()) > 62500) then
|
||||
return
|
||||
end
|
||||
|
||||
local fabrication = ent:SynthesizeFabrication(client, ent:GetDiscItemID(), isBulk, amount)
|
||||
if fabrication then
|
||||
client:NotifyLocalized(fabrication)
|
||||
end
|
||||
end)
|
||||
|
||||
net.Receive("ix.terminal.Scan", function(len, client)
|
||||
local ent = net.ReadEntity()
|
||||
|
||||
if (client:EyePos():DistToSqr(ent:GetPos()) > 62500) then
|
||||
return
|
||||
end
|
||||
|
||||
local scan = ent:Scan(client)
|
||||
if scan then
|
||||
client:NotifyLocalized(scan)
|
||||
end
|
||||
end)
|
||||
|
||||
net.Receive("ix.terminal.RequestCities", function(len, client)
|
||||
local ent = net.ReadEntity()
|
||||
|
||||
if (client:EyePos():DistToSqr(ent:GetPos()) > 62500) then
|
||||
return
|
||||
end
|
||||
|
||||
local cities = {}
|
||||
for cityID, city in pairs(ix.city.list) do
|
||||
cities[cityID] = city
|
||||
end
|
||||
cities["1"] = table.Copy(ix.city.main)
|
||||
cities = util.TableToJSON(cities)
|
||||
|
||||
net.Start("ix.terminal.RequestCities")
|
||||
net.WriteString(cities)
|
||||
net.WriteEntity(ent)
|
||||
net.Send(client)
|
||||
end)
|
||||
|
||||
net.Receive("ix.terminal.RequestMainCityInfo", function(len, client)
|
||||
local ent = net.ReadEntity()
|
||||
local option = net.ReadString()
|
||||
|
||||
if (client:EyePos():DistToSqr(ent:GetPos()) > 62500) then
|
||||
return
|
||||
end
|
||||
|
||||
local city = util.TableToJSON(ix.city:GetMainCity())
|
||||
local budgets = util.TableToJSON(ix.factionBudget.list)
|
||||
|
||||
net.Start("ix.terminal.RequestMainCityInfo")
|
||||
net.WriteString(city)
|
||||
net.WriteString(budgets)
|
||||
net.WriteEntity(ent)
|
||||
net.WriteString(option)
|
||||
net.Send(client)
|
||||
end)
|
||||
|
||||
net.Receive("ix.terminal.GetCityStock", function(len, client)
|
||||
local ent = net.ReadEntity()
|
||||
|
||||
if (client:EyePos():DistToSqr(ent:GetPos()) > 62500) then
|
||||
return
|
||||
end
|
||||
|
||||
local city = ix.city:GetMainCity()
|
||||
local items = util.TableToJSON(city:GetItems())
|
||||
|
||||
net.Start("ix.terminal.GetCityStock")
|
||||
net.WriteString(items)
|
||||
net.WriteEntity(ent)
|
||||
net.Send(client)
|
||||
end)
|
||||
|
||||
net.Receive("ix.terminal.turnOn", function(len, client)
|
||||
local ent = net.ReadEntity()
|
||||
|
||||
if (client:EyePos():DistToSqr(ent:GetPos()) > 62500) then
|
||||
return
|
||||
end
|
||||
|
||||
local dataToSend = {}
|
||||
|
||||
if ent:GetClass() == "ix_cwuterminal" then
|
||||
if ent.curGenData then
|
||||
dataToSend[1] = ent.curGenData
|
||||
end
|
||||
|
||||
if ent:GetCWUCard() and ent:GetCWUCard() != -1 then
|
||||
dataToSend[2] = ent:GetCWUCard()
|
||||
end
|
||||
|
||||
if ent:HasCWUCard() and ent:HasCID() or ent.curGenData and ent.curGenData.combine then
|
||||
dataToSend[3] = !ent:IsFullyAuthed()
|
||||
end
|
||||
end
|
||||
|
||||
if ent.dItemID then
|
||||
dataToSend = {ent.dItemID}
|
||||
end
|
||||
|
||||
ent:SetUsedBy(client)
|
||||
ent:CreateUserTimer()
|
||||
net.Start("ix.terminal.turnOn")
|
||||
net.WriteEntity(ent)
|
||||
net.WriteEntity(client)
|
||||
net.WriteString(util.TableToJSON(dataToSend))
|
||||
net.Broadcast()
|
||||
end)
|
||||
|
||||
net.Receive("ix.terminal.turnOff", function(len, client)
|
||||
local ent = net.ReadEntity()
|
||||
|
||||
if (client:EyePos():DistToSqr(ent:GetPos()) > 62500) then
|
||||
return
|
||||
end
|
||||
|
||||
if (IsValid(ent:GetUsedBy()) and ent:GetUsedBy() != client) then
|
||||
return client:NotifyLocalized("Ce terminal est utilisé par quelqu'un d'autre.")
|
||||
end
|
||||
|
||||
ent:SetUsedBy(ent)
|
||||
|
||||
if ent:GetClass() == "ix_cwuterminal" and ent:GetNetVar("broadcasting", false) then
|
||||
if client:GetNetVar("broadcastAuth", false) then
|
||||
client:SetNetVar("broadcastAuth", nil)
|
||||
end
|
||||
ent:ToggleBroadcast()
|
||||
end
|
||||
|
||||
net.Start("ix.terminal.turnOff")
|
||||
net.WriteEntity(ent)
|
||||
net.Broadcast()
|
||||
end)
|
||||
Reference in New Issue
Block a user