This commit is contained in:
lifestorm
2024-08-05 18:40:29 +03:00
parent 9f505a0646
commit c6d9b6f580
8044 changed files with 1853472 additions and 21 deletions

View File

@@ -0,0 +1,102 @@
--[[
| 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/
--]]
include('shared.lua')
local glowMaterial = ix.util.GetMaterial("sprites/glow04_noz")
local color_red = Color(255, 0, 0, 255)
function ENT:Initialize()
self.buttons = {}
end
function ENT:Draw()
self:DrawModel()
local width, height = 260, 135
local ang = self:GetAngles()
local pos = self:GetPos() + ang:Up() * 60 - ang:Right() * 4.1 - ang:Forward() * 13
ang:RotateAroundAxis(ang:Right(), 90)
ang:RotateAroundAxis(ang:Up(), -65)
ang:RotateAroundAxis(ang:Right(), -90)
local display = self.Displays[self:GetDisplay()] or self.Displays[6]
cam.Start3D2D(pos, ang, 0.1)
render.PushFilterMin(TEXFILTER.NONE)
render.PushFilterMag(TEXFILTER.NONE)
surface.SetDrawColor(Color(255, 255, 255, 250))
surface.SetMaterial(ix.util.GetMaterial("willardnetworks/datafile/workshifterminal.png"))
surface.DrawTexturedRect(0, 0, width, height)
surface.SetDrawColor(Color(16, 16, 16, 100))
surface.DrawRect(10, 5, width - 20, height - 10)
surface.SetDrawColor(Color(72, 255, 243, 10))
surface.DrawOutlinedRect(10, 5, width - 20, height - 10)
surface.SetDrawColor(Color(255, 255, 255, 16))
surface.DrawRect(10, (height - 5) / 1.9 + math.sin(CurTime() * 4) * (height + 8) / 2.3, width - 20, 1)
local alpha = 191 + 64 * math.sin(CurTime() * 4)
local color = ColorAlpha(display[2], alpha)
draw.SimpleText("Workshift Terminal", "MenuFont", width / 2, height * 0.35, Color(255, 255, 255, alpha), TEXT_ALIGN_CENTER)
draw.SimpleText(display[1], "MenuFont", width / 2, height * 0.6, color, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
if (self.buttons) then
for k, _ in pairs(self.buttons) do
local closest = self:GetNearestButton()
local thisText = "Enter CID"
if (closest == k) then
cam.Start3D2D(self.buttons[k], ang, 0.1)
draw.SimpleText(thisText, "MenuFont", 0, -30, Color(255, 255, 255, 255), TEXT_ALIGN_CENTER)
cam.End3D2D()
end
end
end
render.PopFilterMin()
render.PopFilterMag()
cam.End3D2D()
render.SetMaterial(glowMaterial)
if (self.buttons) then
local position = self:GetPos()
local f, r, u = self:GetForward(), self:GetRight(), self:GetUp()
self.buttons[1] = position + f*-5.6 + r*5.6 + u*46
local closest = self:GetNearestButton()
for k, v in pairs(self.buttons) do
local thisColor = Color(255, 255, 255, 255)
if (closest != k) then
thisColor.a = thisColor == color_red and 100 or 75
else
thisColor.a = 230 + (math.sin(RealTime() * 7.5) * 25)
end
if (LocalPlayer():KeyDown(IN_USE) and closest == k) then
thisColor = table.Copy(thisColor)
thisColor.r = math.min(thisColor.r + 100, 255)
thisColor.g = math.min(thisColor.g + 100, 255)
thisColor.b = math.min(thisColor.b + 100, 255)
end
render.DrawSprite(v, 4, 4, thisColor)
end
end
end

View File

@@ -0,0 +1,122 @@
--[[
| 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/
--]]
AddCSLuaFile( "cl_init.lua" ) -- Make sure clientside
AddCSLuaFile( "shared.lua" ) -- and shared scripts are sent.
include('shared.lua')
local PLUGIN = PLUGIN
function ENT:OnInitialize()
self:SetDisplay(9)
end
function ENT:SaveTerminalLocations()
ix.saveEnts:SaveEntity(self)
end
function ENT:SetGroups(bUse)
end
function ENT:CheckStartedWorkshift()
if !PLUGIN:CheckStartedWorkshift(self) then
self:SetDisplay(9)
self:EmitSound("buttons/button8.wav")
self:ResetInfo()
return false
end
return true
end
function ENT:StopWorkshift(client)
if !self.workshiftStarted then
self:ResetInfo()
self:EmitSound("buttons/button8.wav")
return
end
PLUGIN:StopWorkshift(self, client)
end
function ENT:StartWorkshift(client)
if self.workshiftStarted then
self:ResetInfo()
self:EmitSound("buttons/button8.wav")
return
end
self:SetDisplay(3)
timer.Simple(1, function()
if IsValid(self) then
self:SetDisplay(1)
end
end)
self.workshiftStarted = true
self:ResetInfo()
end
function ENT:ResetInfo()
self.canUse = true
self.activePlayer = nil
self.activeCharacter = nil
end
function ENT:OnUse(client)
local button = self:GetNearestButton(client)
if (button) then
self:EmitSound("buttons/lightswitch2.wav")
if !self:CheckStartedWorkshift() then
self:EmitSound("buttons/button8.wav")
self:ResetInfo()
return false
end
self:CheckForCID(client)
else
client:NotifyLocalized("You need to use one of the buttons!")
self:ResetInfo()
end
end
function ENT:ReadyForAnother()
timer.Simple(1, function()
if IsValid(self) then
self:SetDisplay(1)
self:ResetInfo()
end
end)
end
function ENT:OnSuccess(idCard, genericData, client)
self:SetDisplay(6)
self:EmitSound("buttons/button14.wav")
self:ReadyForAnother()
if (client:IsVortigaunt()) then
ix.combineNotify:AddNotification("LOG:// Subject " .. string.upper("biotic asset identification card: #") .. genericData.cid .. " joined Work-Cycle")
else
ix.combineNotify:AddNotification("LOG:// Subject '" .. genericData.name .. "' joined Work-Cycle", nil, client)
end
PLUGIN:AddToWorkshift(client, idCard, genericData, self)
end
function ENT:AlreadyParticipated()
self:SetDisplay(10)
self:EmitSound("buttons/button8.wav")
self:ReadyForAnother()
end

View File

@@ -0,0 +1,77 @@
--[[
| 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/
--]]
ENT.Type = "anim"
ENT.PrintName = "Workshift Terminal"
ENT.Base = "ix_terminal"
ENT.Author = "Fruity"
ENT.Contact = "Willard Networks"
ENT.Purpose = "Start and stop workshifts via an entity."
ENT.Instructions = "Press E to enter CID, use the buttons to start/stop."
ENT.Category = "HL2 RP"
ENT.Spawnable = true
ENT.AdminOnly = true
ENT.PhysgunDisable = true
ENT.bNoPersist = true
ENT.model = "models/willard/combine/checkin.mdl"
ENT.workshiftStarted = false
ENT.participants = {}
ENT.canMalfunction = true
ENT.Displays = {
[1] = {"WAITING FOR ID", Color( 255, 255, 180 ), true},
[2] = {"CHECKING", Color(255, 200, 0)},
[3] = {"WORKSHIFT STARTED", Color(0, 255, 0)},
[4] = {"RELOADING", Color(255, 200, 0)},
[5] = {"OFFLINE", Color(255, 0, 0), true},
[6] = {"SUCCESS", Color( 0, 255, 180 )},
[7] = {"WORKSHIFT FINISHED", Color(255, 0, 0)},
[8] = {"NO INFO", Color(0, 255, 0)},
[9] = {"SHIFT INACTIVE", Color(255, 0, 0)},
[10] = {"ALREADY PARTICIPATED", Color(255, 0, 0)},
[11] = {"REGISTRATION PAUSED", Color(255, 0, 0)}
}
ENT.buttons = {}
function ENT:SetupDataTables()
self:NetworkVar("Int", 0, "Display")
end
function ENT:GetNearestButton(client)
client = client or (CLIENT and LocalPlayer())
if (self.buttons) then
if (SERVER) then
local position = self:GetPos()
local f, r, u = self:GetForward(), self:GetRight(), self:GetUp()
self.buttons[1] = position + f*-5.6 + r*5.6 + u*46
end
local data = {}
data.start = client:GetShootPos()
data.endpos = data.start + client:GetAimVector()*96
data.filter = client
local trace = util.TraceLine(data)
local hitPos = trace.HitPos
if (hitPos) then
for k, v in pairs(self.buttons) do
if (v:Distance(hitPos) <= 2) then
return k
end
end
end
end
end

View File

@@ -0,0 +1,145 @@
--[[
| 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/
--]]
local PLUGIN = PLUGIN
function PLUGIN:StartWorkshift()
SetNetVar("WorkshiftStarted", true)
end
function PLUGIN:StopWorkshift(ent)
ent.workshiftPaused = ent.workshiftPaused or false
ent.savedInfo = ent.savedInfo or {}
ent.workshiftStarted = false
ent.workshiftPaused = false
ent.participants = {}
ent.savedInfo = {}
ent:ResetInfo()
ent:SetDisplay(9)
ent:EmitSound("ambient/machines/combine_terminal_idle2.wav")
end
function PLUGIN:EndWorkshift(tSaved, client)
local character = client:GetCharacter()
local datafields = {"genericdata", "datafilelogs"}
if tSaved and istable(tSaved) and !table.IsEmpty(tSaved) then
for genericID, tInfo in pairs(tSaved) do
local coupon = tInfo.coupon or false
local points = tInfo.points or 0
local dataSelect = mysql:Select("ix_characters_data")
dataSelect:Where("id", genericID)
dataSelect:WhereIn("key", datafields)
dataSelect:Callback(function(dataSelectResult)
if (!istable(dataSelectResult) or #dataSelectResult == 0) then
return
end
local file = {}
for _, v in ipairs(dataSelectResult) do
file[v.key] = util.JSONToTable(v.data or "")
end
local limitCount = 0
for _, v in pairs(file["datafilelogs"]) do
if !v.points then
continue
end
if isnumber(v.date) and os.date("%d/%m/%Y", v.date) == os.date("%d/%m/%Y") then
limitCount = limitCount + v.points
end
end
if ((points + limitCount) > 20 or (points + limitCount) < -20) then
PLUGIN:AddLog(client, file["datafilelogs"], file["genericdata"], client:Name(), 0, "Finished Workshift", true, true)
else
if (file["genericdata"].cohesionPoints) then
file["genericdata"].cohesionPoints = !file["genericdata"].combine and math.Clamp(file["genericdata"].cohesionPoints + points, 0, 200) or file["genericdata"].cohesionPoints + points
file["genericdata"].cohesionPointsDate = os.time()
else
file["genericdata"].socialCredits = !file["genericdata"].combine and math.Clamp(file["genericdata"].socialCredits + points, 0, 200) or file["genericdata"].socialCredits + points
file["genericdata"].socialCreditsDate = os.time()
end
PLUGIN:AddLog(client, file["datafilelogs"], file["genericdata"], client:Name(), points, "Finished Workshift", true, true)
PLUGIN:EditDatafile(client, file["genericdata"], true, true)
end
local couponCharacter = ix.char.loaded[genericID]
if couponCharacter and coupon != false then
if coupon == "BASIC" then
couponCharacter:SetPurchasedItems("coupon_basic", 1)
elseif coupon == "MEDIUM" then
couponCharacter:SetPurchasedItems("coupon_medium", 1)
else
couponCharacter:SetPurchasedItems("coupon_priority", 1)
end
end
end)
dataSelect:Execute()
end
end
SetNetVar("WorkshiftStarted", false)
end
function PLUGIN:PauseWorkshift(ent, client, bPaused)
ent.workshiftPaused = bPaused
end
function PLUGIN:SaveWorkshift(tSaved, ent)
ent.savedInfo = tSaved
end
function PLUGIN:CheckStartedWorkshift(ent)
if ent.workshiftStarted then return true end
return false
end
function PLUGIN:AddToWorkshift(client, idCard, genericData, ent)
if ent.workshiftPaused then
ent:SetDisplay(11)
ent:ReadyForAnother()
return false
end
if ent.participants[genericData.id] then
ent:AlreadyParticipated()
ent:ResetInfo()
return false
end
ent.participants[genericData.id] = {genericData.cid, genericData.name}
local pointsToday = 0
local queryObj = mysql:Select("ix_characters_data")
queryObj:Where("id", genericData.id)
queryObj:Where("key", "datafilelogs")
queryObj:Select("data")
queryObj:Callback(function(result)
if (!istable(result) or !result[1]) then return end
if !result[1].data then return end
for _, tLog in pairs(util.JSONToTable(result[1].data)) do
if tLog.points and tLog.points != 0 and tLog.date and isnumber(tLog.date) and os.date("%d/%m/%Y", tLog.date) == os.date("%d/%m/%Y") then
pointsToday = pointsToday + tLog.points
end
end
ent.participants[genericData.id][3] = pointsToday
end)
queryObj:Execute()
end