mirror of
https://github.com/lifestorm/wnsrc.git
synced 2025-12-17 13:53:45 +03:00
Upload
This commit is contained in:
212
gamemodes/darkrp/plugins/scannerplugin/cl_hooks.lua
Normal file
212
gamemodes/darkrp/plugins/scannerplugin/cl_hooks.lua
Normal file
@@ -0,0 +1,212 @@
|
||||
--[[
|
||||
| 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 PICTURE_WIDTH = PLUGIN.PICTURE_WIDTH
|
||||
local PICTURE_HEIGHT = PLUGIN.PICTURE_HEIGHT
|
||||
local PICTURE_WIDTH2 = PICTURE_WIDTH * 0.5
|
||||
local PICTURE_HEIGHT2 = PICTURE_HEIGHT * 0.5
|
||||
|
||||
surface.CreateFont("ixScannerFont", {
|
||||
font = "Lucida Sans Typewriter",
|
||||
antialias = false,
|
||||
outline = true,
|
||||
weight = 800,
|
||||
size = SScaleMin(18 / 3)
|
||||
})
|
||||
|
||||
local view = {}
|
||||
local zoom = 0
|
||||
local deltaZoom = zoom
|
||||
local nextClick = 0
|
||||
local hidden = false
|
||||
local data = {}
|
||||
|
||||
local CLICK = "buttons/button18.wav"
|
||||
|
||||
local blackAndWhite = {
|
||||
["$pp_colour_addr"] = 0,
|
||||
["$pp_colour_addg"] = 0,
|
||||
["$pp_colour_addb"] = 0,
|
||||
["$pp_colour_brightness"] = 0,
|
||||
["$pp_colour_contrast"] = 1.5,
|
||||
["$pp_colour_colour"] = 0,
|
||||
["$pp_colour_mulr"] = 0,
|
||||
["$pp_colour_mulg"] = 0,
|
||||
["$pp_colour_mulb"] = 0
|
||||
}
|
||||
|
||||
function PLUGIN:CalcView(client, origin, angles, fov)
|
||||
local entity = client:GetViewEntity()
|
||||
|
||||
if (IsValid(entity) and entity:GetClass():find("scanner")) then
|
||||
view.angles = client:GetAimVector():Angle()
|
||||
view.fov = fov - deltaZoom
|
||||
|
||||
if (math.abs(deltaZoom - zoom) > 5 and nextClick < RealTime()) then
|
||||
nextClick = RealTime() + 0.05
|
||||
client:EmitSound("common/talk.wav", 50, 180)
|
||||
end
|
||||
|
||||
return view
|
||||
end
|
||||
end
|
||||
|
||||
function PLUGIN:InputMouseApply(command, x, y, angle)
|
||||
zoom = math.Clamp(zoom + command:GetMouseWheel()*1.5, 0, 40)
|
||||
deltaZoom = Lerp(FrameTime() * 2, deltaZoom, zoom)
|
||||
end
|
||||
|
||||
function PLUGIN:PreDrawOpaqueRenderables()
|
||||
local viewEntity = LocalPlayer():GetViewEntity()
|
||||
|
||||
if (IsValid(self.lastViewEntity) and self.lastViewEntity != viewEntity) then
|
||||
self.lastViewEntity:SetNoDraw(false)
|
||||
self.lastViewEntity = nil
|
||||
LocalPlayer():EmitSound(CLICK, 50, 120)
|
||||
end
|
||||
|
||||
if (IsValid(viewEntity) and viewEntity:GetClass():find("scanner")) then
|
||||
viewEntity:SetNoDraw(true)
|
||||
|
||||
if (self.lastViewEntity ~= viewEntity) then
|
||||
viewEntity:EmitSound(CLICK, 50, 140)
|
||||
end
|
||||
|
||||
self.lastViewEntity = viewEntity
|
||||
|
||||
hidden = true
|
||||
elseif (hidden) then
|
||||
hidden = false
|
||||
end
|
||||
end
|
||||
|
||||
function PLUGIN:ShouldDrawCrosshair()
|
||||
if (hidden) then
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
function PLUGIN:AdjustMouseSensitivity()
|
||||
if (hidden) then
|
||||
return 0.3
|
||||
end
|
||||
end
|
||||
|
||||
function PLUGIN:HUDPaint()
|
||||
if (not hidden) then return end
|
||||
|
||||
local scrW, scrH = surface.ScreenWidth() * 0.5, surface.ScreenHeight() * 0.5
|
||||
local x, y = scrW - PICTURE_WIDTH2, scrH - PICTURE_HEIGHT2
|
||||
|
||||
if (self.lastPic and self.lastPic >= CurTime()) then
|
||||
local delay = ix.config.Get("pictureDelay", 15)
|
||||
local percent = math.Round(math.TimeFraction(self.lastPic - delay, self.lastPic, CurTime()), 2) * 100
|
||||
local glow = math.sin(RealTime() * 15)*25
|
||||
|
||||
draw.SimpleText("RE-CHARGING: "..percent.."%", "ixScannerFont", x, y - SScaleMin(24 / 3), Color(255 + glow, 100 + glow, 25, 250))
|
||||
end
|
||||
|
||||
|
||||
local angle = LocalPlayer():GetAimVector():Angle()
|
||||
|
||||
if (LocalPlayer():GetArea()) then
|
||||
draw.SimpleText("POS ("..LocalPlayer():GetArea()..")", "ixScannerFont", x + SScaleMin(8 / 3), y + SScaleMin(8 / 3), color_white)
|
||||
else
|
||||
local position = LocalPlayer():GetPos()
|
||||
draw.SimpleText("POS ("..math.floor(position[1])..", "..math.floor(position[2])..", "..math.floor(position[3])..")", "ixScannerFont", x + SScaleMin(8 / 3), y + SScaleMin(8 / 3), color_white)
|
||||
end
|
||||
|
||||
draw.SimpleText("ANG ("..math.floor(angle[1])..", "..math.floor(angle[2])..", "..math.floor(angle[3])..")", "ixScannerFont", x + SScaleMin(8 / 3), y + SScaleMin(24 / 3), color_white)
|
||||
draw.SimpleText("ID ("..LocalPlayer():Name()..")", "ixScannerFont", x + SScaleMin(8 / 3), y + SScaleMin(40 / 3), color_white)
|
||||
draw.SimpleText("ZM ("..(math.Round(zoom / 40, 2) * 100).."%)", "ixScannerFont", x + SScaleMin(8 / 3), y + SScaleMin(56 / 3), color_white)
|
||||
|
||||
if (IsValid(self.lastViewEntity)) then
|
||||
data.start = self.lastViewEntity:GetPos()
|
||||
data.endpos = data.start + LocalPlayer():GetAimVector() * 500
|
||||
data.filter = self.lastViewEntity
|
||||
|
||||
local entity = util.TraceLine(data).Entity
|
||||
|
||||
if (IsValid(entity) and entity:IsPlayer()) then
|
||||
entity = entity:Name()
|
||||
else
|
||||
entity = "NULL"
|
||||
end
|
||||
|
||||
draw.SimpleText("TRG ("..entity..")", "ixScannerFont", x + SScaleMin(8 / 3), y + SScaleMin(72 / 3), color_white)
|
||||
end
|
||||
|
||||
surface.SetDrawColor(235, 235, 235, 230)
|
||||
|
||||
surface.DrawLine(0, scrH, x - SScaleMin(128 / 3), scrH)
|
||||
surface.DrawLine(scrW + PICTURE_WIDTH2 + SScaleMin(128 / 3), scrH, ScrW(), scrH)
|
||||
surface.DrawLine(scrW, 0, scrW, y - SScaleMin(128 / 3))
|
||||
surface.DrawLine(scrW, scrH + PICTURE_HEIGHT2 + SScaleMin(128 / 3), scrW, ScrH())
|
||||
|
||||
surface.DrawLine(x, y, x + SScaleMin(128 / 3), y)
|
||||
surface.DrawLine(x, y, x, y + SScaleMin(128 / 3))
|
||||
|
||||
x = scrW + PICTURE_WIDTH2
|
||||
|
||||
surface.DrawLine(x, y, x - SScaleMin(128 / 3), y)
|
||||
surface.DrawLine(x, y, x, y + SScaleMin(128 / 3))
|
||||
|
||||
x = scrW - PICTURE_WIDTH2
|
||||
y = scrH + PICTURE_HEIGHT2
|
||||
|
||||
surface.DrawLine(x, y, x + SScaleMin(128 / 3), y)
|
||||
surface.DrawLine(x, y, x, y - SScaleMin(128 / 3))
|
||||
|
||||
x = scrW + PICTURE_WIDTH2
|
||||
|
||||
surface.DrawLine(x, y, x - SScaleMin(128 / 3), y)
|
||||
surface.DrawLine(x, y, x, y - SScaleMin(128 / 3))
|
||||
|
||||
surface.DrawLine(scrW - SScaleMin(48 / 3), scrH, scrW - SScaleMin(8 / 3), scrH)
|
||||
surface.DrawLine(scrW + SScaleMin(48 / 3), scrH, scrW + SScaleMin(8 / 3), scrH)
|
||||
surface.DrawLine(scrW, scrH - SScaleMin(48 / 3), scrW, scrH - SScaleMin(8 / 3))
|
||||
surface.DrawLine(scrW, scrH + SScaleMin(48 / 3), scrW, scrH + SScaleMin(8 / 3))
|
||||
end
|
||||
|
||||
function PLUGIN:RenderScreenspaceEffects()
|
||||
if (not hidden) then return end
|
||||
blackAndWhite["$pp_colour_brightness"] = -0.05
|
||||
+ math.sin(RealTime() * 5) * 0.01
|
||||
DrawColorModify(blackAndWhite)
|
||||
end
|
||||
|
||||
function PLUGIN:PlayerBindPress(client, bind, pressed)
|
||||
bind = bind:utf8lower()
|
||||
|
||||
if (bind:find("attack2") and pressed and hidden and IsValid(self.lastViewEntity)) then
|
||||
data.start = self.lastViewEntity:GetPos()
|
||||
data.endpos = data.start + LocalPlayer():GetAimVector() * 500
|
||||
data.filter = self.lastViewEntity
|
||||
|
||||
local entity = util.TraceLine(data).Entity
|
||||
|
||||
if (entity and IsEntity(entity) and entity:IsValid() and entity:IsPlayer() and entity.GetCharacter) then
|
||||
local character = entity:GetCharacter()
|
||||
|
||||
if (character:IsVortigaunt()) then
|
||||
if (character:GetCollarID()) then
|
||||
ix.command.Send("datafile", "!" .. character:GetCollarID())
|
||||
else
|
||||
ix.command.Send("datafile", character:GetCid())
|
||||
end
|
||||
else
|
||||
ix.command.Send("datafile", character:GetName())
|
||||
end
|
||||
end
|
||||
elseif (bind:find("attack") and pressed and hidden and IsValid(self.lastViewEntity)) then
|
||||
self:TakePicture()
|
||||
return true
|
||||
end
|
||||
end
|
||||
139
gamemodes/darkrp/plugins/scannerplugin/cl_photos.lua
Normal file
139
gamemodes/darkrp/plugins/scannerplugin/cl_photos.lua
Normal file
@@ -0,0 +1,139 @@
|
||||
--[[
|
||||
| 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 PICTURE_WIDTH = PLUGIN.PICTURE_WIDTH
|
||||
local PICTURE_HEIGHT = PLUGIN.PICTURE_HEIGHT
|
||||
local PICTURE_WIDTH2 = PICTURE_WIDTH * 0.5
|
||||
local PICTURE_HEIGHT2 = PICTURE_HEIGHT * 0.5
|
||||
|
||||
local PHOTO_CACHE = {}
|
||||
local CURRENT_PHOTO
|
||||
|
||||
function PLUGIN:TakePicture()
|
||||
if ((self.lastPic or 0) < CurTime()) then
|
||||
self.lastPic = CurTime() + ix.config.Get("pictureDelay", 15)
|
||||
|
||||
net.Start("ixScannerPicture")
|
||||
net.SendToServer()
|
||||
|
||||
timer.Simple(0.1, function()
|
||||
self.startPicture = true
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
function PLUGIN:PostRender()
|
||||
if (self.startPicture) then
|
||||
local data = util.Compress(render.Capture({
|
||||
format = "jpeg",
|
||||
h = PICTURE_HEIGHT,
|
||||
w = PICTURE_WIDTH,
|
||||
quality = 35,
|
||||
x = ScrW()*0.5 - PICTURE_WIDTH2,
|
||||
y = ScrH()*0.5 - PICTURE_HEIGHT2
|
||||
}))
|
||||
|
||||
net.Start("ixScannerData")
|
||||
net.WriteUInt(#data, 16)
|
||||
net.WriteData(data, #data)
|
||||
net.SendToServer()
|
||||
|
||||
self.startPicture = false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
net.Receive("ixScannerData", function()
|
||||
local data = net.ReadData(net.ReadUInt(16))
|
||||
data = util.Base64Encode(util.Decompress(data))
|
||||
|
||||
if (not data) then return end
|
||||
|
||||
if (IsValid(CURRENT_PHOTO)) then
|
||||
local panel = CURRENT_PHOTO
|
||||
|
||||
CURRENT_PHOTO:AlphaTo(0, 0.25, 0, function()
|
||||
if (IsValid(panel)) then
|
||||
panel:Remove()
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
local html = Format([[
|
||||
<html>
|
||||
<body style="background: black; overflow: hidden; margin: 0; padding: 0;">
|
||||
<img src="data:image/jpeg;base64,%s" width="%s" height="%s" />
|
||||
</body>
|
||||
</html>
|
||||
]], data, PICTURE_WIDTH, PICTURE_HEIGHT)
|
||||
|
||||
local panel = vgui.Create("DPanel")
|
||||
panel:SetSize(PICTURE_WIDTH + SScaleMin(8 / 3), PICTURE_HEIGHT + SScaleMin(8 / 3))
|
||||
panel:SetPos(ScrW(), SScaleMin(8 / 3))
|
||||
panel:SetDrawBackground(true)
|
||||
panel:SetAlpha(150)
|
||||
|
||||
panel.body = panel:Add("DHTML")
|
||||
panel.body:Dock(FILL)
|
||||
panel.body:DockMargin(SScaleMin(4 / 3), SScaleMin(4 / 3), SScaleMin(4 / 3), SScaleMin(4 / 3))
|
||||
panel.body:SetHTML(html)
|
||||
|
||||
panel:MoveTo(ScrW() - (panel:GetWide() + SScaleMin(8 / 3)), SScaleMin(8 / 3), 0.5)
|
||||
|
||||
timer.Simple(15, function()
|
||||
if (IsValid(panel)) then
|
||||
panel:MoveTo(ScrW(), SScaleMin(8 / 3), 0.5, 0, -1, function()
|
||||
panel:Remove()
|
||||
end)
|
||||
end
|
||||
end)
|
||||
|
||||
PHOTO_CACHE[#PHOTO_CACHE + 1] = {data = html, time = os.time()}
|
||||
CURRENT_PHOTO = panel
|
||||
end)
|
||||
|
||||
net.Receive("ixScannerClearPicture", function()
|
||||
if (IsValid(CURRENT_PHOTO)) then
|
||||
CURRENT_PHOTO:Remove()
|
||||
end
|
||||
end)
|
||||
|
||||
concommand.Add("ix_photocache", function()
|
||||
local frame = vgui.Create("DFrame")
|
||||
frame:SetTitle("Photo Cache")
|
||||
frame:SetSize(SScaleMin(480 / 3), SScaleMin(360 / 3))
|
||||
frame:Center()
|
||||
DFrameFixer(frame)
|
||||
|
||||
frame.list = frame:Add("DScrollPanel")
|
||||
frame.list:Dock(FILL)
|
||||
frame.list:SetDrawBackground(true)
|
||||
|
||||
for _, v in ipairs(PHOTO_CACHE) do
|
||||
local button = frame.list:Add("DButton")
|
||||
button:SetTall(SScaleMin(28 / 3))
|
||||
button:Dock(TOP)
|
||||
button:SetFont("MenuFontNoClamp")
|
||||
button:DockMargin(SScaleMin(4 / 3), SScaleMin(4 / 3), SScaleMin(4 / 3), 0)
|
||||
button:SetText(os.date("%X - %d/%m/%Y", v.time))
|
||||
button.DoClick = function()
|
||||
local frame2 = vgui.Create("DFrame")
|
||||
frame2:SetSize(PICTURE_WIDTH + SScaleMin(8 / 3), PICTURE_HEIGHT + SScaleMin(8 / 3))
|
||||
frame2:SetTitle(button:GetText())
|
||||
frame2:Center()
|
||||
DFrameFixer(frame2)
|
||||
|
||||
frame2.body = frame2:Add("DHTML")
|
||||
frame2.body:SetHTML(v.data)
|
||||
frame2.body:Dock(FILL)
|
||||
frame2.body:DockMargin(SScaleMin(4 / 3), SScaleMin(4 / 3), SScaleMin(4 / 3), SScaleMin(4 / 3))
|
||||
end
|
||||
end
|
||||
end)
|
||||
@@ -0,0 +1,88 @@
|
||||
--[[
|
||||
| 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 knots = {
|
||||
Vector(-20, 0, 0),
|
||||
Vector(-30, 0, 0),
|
||||
Vector(120, 0, 0),
|
||||
Vector(90, 0, 0),
|
||||
}
|
||||
|
||||
function ENT:Think()
|
||||
local velocity = self:GetVelocity()
|
||||
local lengthSqr = velocity:LengthSqr()
|
||||
self.wheel = self.wheel or 360
|
||||
self.wheel = self.wheel - math.min((lengthSqr / 80) + 250, 900)
|
||||
* FrameTime()
|
||||
if (self.wheel < 0) then
|
||||
self.wheel = 360
|
||||
end
|
||||
|
||||
self:SetPoseParameter("dynamo_wheel", self.wheel)
|
||||
|
||||
local t = velocity.z / self.maxSpeed
|
||||
self.tail = math.BSplinePoint(t, knots, 1)
|
||||
self.realTail = Lerp(FrameTime() * 5, self.realTail or 0, self.tail.x)
|
||||
self:SetPoseParameter("tail_control", self.realTail)
|
||||
|
||||
local pilot = self:GetPilot()
|
||||
local angles = self:GetAngles()
|
||||
local goalAngles = IsValid(pilot) and pilot:EyeAngles() or angles
|
||||
|
||||
local hDiff = math.AngleDifference(goalAngles.y, angles.y) / 45
|
||||
local vDiff = math.AngleDifference(goalAngles.p, angles.p) / 45
|
||||
self:SetPoseParameter("flex_horz", hDiff * 20)
|
||||
self:SetPoseParameter("flex_vert", vDiff * 20)
|
||||
|
||||
self:PlayFlySound()
|
||||
|
||||
if (self.sound) then
|
||||
self.sound:ChangePitch(math.min(80 + (lengthSqr / 10000)*20, 255), 0.5)
|
||||
end
|
||||
end
|
||||
|
||||
function ENT:PlayFlySound()
|
||||
if (not self.sound) then
|
||||
local source = "npc/scanner/cbot_fly_loop.wav"
|
||||
if (self:GetModel():find("shield_scanner")) then
|
||||
source = "npc/scanner/combat_scan_loop6.wav"
|
||||
end
|
||||
self.sound = CreateSound(self, source)
|
||||
self.sound:PlayEx(0.5, 100)
|
||||
elseif (not self.sound:IsPlaying()) then
|
||||
self.sound:Play()
|
||||
end
|
||||
end
|
||||
|
||||
function ENT:OnRemove()
|
||||
if (self.sound) then
|
||||
self.sound:Stop()
|
||||
self.sound = nil
|
||||
end
|
||||
end
|
||||
|
||||
net.Receive("ixScannerFlash", function()
|
||||
local entity = net.ReadEntity()
|
||||
if (IsValid(entity)) then
|
||||
local light = DynamicLight(entity:EntIndex())
|
||||
if (not light) then return end
|
||||
|
||||
light.pos = entity:GetPos() + entity:GetForward() * 24
|
||||
light.r = 255
|
||||
light.g = 255
|
||||
light.b = 255
|
||||
light.brightness = 5
|
||||
light.Decay = 5000
|
||||
light.Size = 360
|
||||
light.DieTime = CurTime() + 1
|
||||
end
|
||||
end)
|
||||
@@ -0,0 +1,404 @@
|
||||
--[[
|
||||
| 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")
|
||||
|
||||
AddCSLuaFile("cl_init.lua")
|
||||
AddCSLuaFile("shared.lua")
|
||||
|
||||
util.AddNetworkString("ixScannerFlash")
|
||||
|
||||
ENT.scanSounds = {
|
||||
"npc/scanner/scanner_scan1.wav",
|
||||
"npc/scanner/scanner_scan2.wav",
|
||||
"npc/scanner/scanner_scan4.wav",
|
||||
"npc/scanner/scanner_scan5.wav",
|
||||
"npc/scanner/combat_scan1.wav",
|
||||
"npc/scanner/combat_scan2.wav",
|
||||
"npc/scanner/combat_scan3.wav",
|
||||
"npc/scanner/combat_scan4.wav",
|
||||
"npc/scanner/combat_scan5.wav",
|
||||
}
|
||||
ENT.painSounds = {
|
||||
"npc/scanner/scanner_pain1.wav",
|
||||
"npc/scanner/scanner_pain2.wav",
|
||||
"npc/scanner/scanner_alert1.wav",
|
||||
}
|
||||
ENT.sirenSound = "npc/scanner/scanner_siren2.wav"
|
||||
|
||||
function ENT:EjectPilot(no)
|
||||
local pilot = self:GetPilot()
|
||||
if (not IsValid(pilot)) then return end
|
||||
|
||||
pilot:SetMoveType(MOVETYPE_WALK)
|
||||
pilot:UnSpectate()
|
||||
|
||||
if (not self.noRespawn) then
|
||||
pilot:Spawn()
|
||||
end
|
||||
|
||||
pilot:DrawViewModel(true)
|
||||
pilot:CrosshairEnable()
|
||||
|
||||
if (self.health <= 0) then
|
||||
pilot:KillSilent()
|
||||
end
|
||||
|
||||
self:SetPilot(NULL)
|
||||
end
|
||||
|
||||
function ENT:SetPilotEntity(client)
|
||||
self:EjectPilot()
|
||||
self:SetPilot(client)
|
||||
|
||||
client:Spectate(OBS_MODE_CHASE)
|
||||
client:SpectateEntity(self)
|
||||
client:StripWeapons()
|
||||
client:DrawViewModel(false)
|
||||
client:CrosshairDisable()
|
||||
client:Flashlight(false)
|
||||
client:SetHealth(self.maxHealth)
|
||||
end
|
||||
|
||||
function ENT:CreateFlashSprite()
|
||||
if (IsValid(self.spotlight)) then return end
|
||||
|
||||
local SCANNER_ATTACHMENT_LIGHT = "light"
|
||||
|
||||
self.flashSprite = ents.Create("env_sprite")
|
||||
self.flashSprite:SetAttachment(
|
||||
self,
|
||||
self:LookupAttachment(SCANNER_ATTACHMENT_LIGHT)
|
||||
)
|
||||
self.flashSprite:SetKeyValue("model", "sprites/blueflare1.vmt")
|
||||
self.flashSprite:SetKeyValue("scale", 1.4)
|
||||
self.flashSprite:SetKeyValue("rendermode", 3)
|
||||
self.flashSprite:SetRenderFX(kRenderFxNoDissipation)
|
||||
self.flashSprite:Spawn()
|
||||
self.flashSprite:Activate()
|
||||
self.flashSprite:SetColor(Color(255, 255, 255, 0))
|
||||
end
|
||||
|
||||
function ENT:EnableSpotlight()
|
||||
if (IsValid(self.spotlight)) then return end
|
||||
|
||||
local SCANNER_ATTACHMENT_LIGHT = "light"
|
||||
local attachment = self:LookupAttachment(SCANNER_ATTACHMENT_LIGHT)
|
||||
local position = self:GetAttachment(attachment)
|
||||
|
||||
if (not position) then return end
|
||||
|
||||
-- The volumetric light effect.
|
||||
self.spotlight = ents.Create("point_spotlight")
|
||||
self.spotlight:SetPos(position.Pos)
|
||||
self.spotlight:SetAngles(self:GetAngles())
|
||||
self.spotlight:SetParent(self)
|
||||
self.spotlight:Fire("SetParentAttachment", SCANNER_ATTACHMENT_LIGHT)
|
||||
self.spotlight:SetLocalAngles(self:GetForward():Angle())
|
||||
self.spotlight:SetKeyValue("spotlightwidth", self.spotlightWidth)
|
||||
self.spotlight:SetKeyValue("spotlightlength", self.spotlightLength)
|
||||
self.spotlight:SetKeyValue("HDRColorScale", self.spotlightHDRColorScale)
|
||||
self.spotlight:SetKeyValue("color", "255 255 255")
|
||||
-- On by default and disable dynamic light.
|
||||
self.spotlight:SetKeyValue("spawnflags", 3)
|
||||
self.spotlight:Spawn()
|
||||
self.spotlight:Activate()
|
||||
|
||||
-- The actual dynamic light.
|
||||
self.flashlight = ents.Create("env_projectedtexture")
|
||||
self.flashlight:SetPos(position.Pos)
|
||||
self.flashlight:SetParent(self)
|
||||
self.flashlight:SetLocalAngles(self.spotlightLocalAngles)
|
||||
self.flashlight:SetKeyValue(
|
||||
"enableshadows",
|
||||
self.spotlightEnableShadows and 1 or 0
|
||||
)
|
||||
self.flashlight:SetKeyValue("nearz", self.spotlightNear)
|
||||
self.flashlight:SetKeyValue("lightfov", self.spotlightFOV)
|
||||
self.flashlight:SetKeyValue("farz", self.spotlightFar)
|
||||
self.flashlight:SetKeyValue("lightcolor", "255 255 255")
|
||||
self.flashlight:Spawn()
|
||||
self.flashlight:Input(
|
||||
"SpotlightTexture", NULL, NULL, "effects/flashlight/soft"
|
||||
)
|
||||
end
|
||||
|
||||
function ENT:DisableSpotlight()
|
||||
if (IsValid(self.spotlight)) then
|
||||
self.spotlight:SetParent(NULL)
|
||||
self.spotlight:Input("LightOff")
|
||||
self.spotlight:Fire("Kill", "", 0.25)
|
||||
end
|
||||
|
||||
if (IsValid(self.flashlight)) then
|
||||
self.flashlight:Remove()
|
||||
end
|
||||
end
|
||||
|
||||
function ENT:IsSpotlightOn()
|
||||
return IsValid(self.spotlight)
|
||||
end
|
||||
|
||||
function ENT:Initialize()
|
||||
self:SetModel("models/Combine_Scanner.mdl")
|
||||
self:PhysicsInit(SOLID_VPHYSICS)
|
||||
self:SetSolid(SOLID_VPHYSICS)
|
||||
self:AddSolidFlags(FSOLID_NOT_STANDABLE)
|
||||
self:SetMoveType(MOVETYPE_VPHYSICS)
|
||||
self:GetPhysicsObject():EnableMotion(true)
|
||||
self:GetPhysicsObject():Wake()
|
||||
self:GetPhysicsObject():EnableGravity(false)
|
||||
self:ResetSequence("idle")
|
||||
self:SetPlaybackRate(1.0)
|
||||
self:AddFlags(FL_FLY)
|
||||
self:PrecacheGibs()
|
||||
|
||||
if (SERVER) then
|
||||
self:CreateFlashSprite()
|
||||
end
|
||||
|
||||
self.targetDir = vector_origin
|
||||
self.health = self.maxHealth
|
||||
end
|
||||
|
||||
function ENT:SetClawScanner()
|
||||
self:SetModel("models/shield_scanner.mdl")
|
||||
self:PrecacheGibs()
|
||||
self:ResetSequence("hoverclosed")
|
||||
end
|
||||
|
||||
function ENT:Flash()
|
||||
local max = 30
|
||||
local value = max
|
||||
local timerID = "ScannerFlash"..self:EntIndex()
|
||||
|
||||
self.flashSprite:SetColor(color_white)
|
||||
self:EmitSound("npc/scanner/scanner_photo1.wav")
|
||||
|
||||
net.Start("ixScannerFlash")
|
||||
net.WriteEntity(self)
|
||||
net.SendPVS(self:GetPos())
|
||||
|
||||
timer.Create("ScannerFlash"..self:EntIndex(), 0, max, function()
|
||||
if (IsValid(self) and IsValid(self.flashSprite)) then
|
||||
self.flashSprite:SetColor(
|
||||
Color(255, 255, 255, (value / max) * 255)
|
||||
)
|
||||
value = value - 1
|
||||
else
|
||||
timer.Remove(timerID)
|
||||
end
|
||||
end)
|
||||
|
||||
self:EmitDelayedSound(table.Random(self.scanSounds), 1)
|
||||
end
|
||||
|
||||
function ENT:EmitDelayedSound(source, delay, volume, pitch)
|
||||
timer.Simple(delay or 0, function()
|
||||
if (IsValid(self)) then
|
||||
self:EmitSound(source, volume, pitch)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
function ENT:HandlePilotMove()
|
||||
local still = true
|
||||
local pilot = self:GetPilot()
|
||||
|
||||
if (pilot:KeyDown(IN_FORWARD)) then
|
||||
local speed = 10
|
||||
if (pilot:KeyDown(IN_SPEED)) then
|
||||
speed = speed + 200
|
||||
end
|
||||
self.accelXY = Lerp(0.1, self.accelXY, speed)
|
||||
self.targetDir = self.targetDir + pilot:GetAimVector()
|
||||
still = false
|
||||
end
|
||||
if (pilot:KeyDown(IN_JUMP)) then
|
||||
self.accelXY = Lerp(0.25, self.accelXY, 10)
|
||||
self.targetDir = self.targetDir + Vector(0, 0, 1)
|
||||
still = false
|
||||
end
|
||||
if (pilot:KeyDown(IN_DUCK)) then
|
||||
self.accelXY = Lerp(0.25, self.accelXY, 10)
|
||||
self.targetDir = self.targetDir - Vector(0, 0, 1)
|
||||
still = false
|
||||
end
|
||||
if (still) then
|
||||
self.accelXY = Lerp(0.5, self.accelXY, 0)
|
||||
self.accelZ = Lerp(0.5, self.accelZ, 0)
|
||||
end
|
||||
|
||||
pilot:SetPos(self:GetPos())
|
||||
|
||||
if (pilot:GetMoveType() ~= MOVETYPE_NONE) then
|
||||
pilot:SetMoveType(MOVETYPE_NONE)
|
||||
end
|
||||
end
|
||||
|
||||
function ENT:DiscourageHitGround()
|
||||
local trace = util.TraceLine({
|
||||
start = self:GetPos(),
|
||||
endpos = self:GetPos() - self.minHoverHeight,
|
||||
filter = {self, self:GetPilot()}
|
||||
})
|
||||
if (trace.Hit) then
|
||||
self.targetDir.z = self.minHoverPush.z
|
||||
end
|
||||
end
|
||||
|
||||
function ENT:Think()
|
||||
self.targetDir.x = 0
|
||||
self.targetDir.y = 0
|
||||
self.targetDir.z = 0
|
||||
self:UpdateDirection()
|
||||
|
||||
if (IsValid(self:GetPilot())) then
|
||||
self:HandlePilotMove()
|
||||
end
|
||||
|
||||
self:DiscourageHitGround()
|
||||
self.targetDir:Normalize()
|
||||
|
||||
end
|
||||
|
||||
function ENT:UpdateNoiseVelocity()
|
||||
self.noise.z = math.sin(CurTime() * 2) * 75 * (1 - self.accelZ)
|
||||
end
|
||||
|
||||
function ENT:FacePilotDirection()
|
||||
self.faceAngles = self:GetPilot():EyeAngles()
|
||||
self.faceAngles.p = math.Clamp(self.faceAngles.p, -30, 25)
|
||||
end
|
||||
|
||||
function ENT:UpdateDirection()
|
||||
if (IsValid(self:GetPilot())) then
|
||||
self:FacePilotDirection()
|
||||
end
|
||||
end
|
||||
|
||||
local angDiff = math.AngleDifference
|
||||
|
||||
function ENT:PhysicsUpdate(phys)
|
||||
local dt = FrameTime()
|
||||
|
||||
local velocity = phys:GetVelocity()
|
||||
local decay = self.velocityDecay
|
||||
local maxSpeed = self.maxSpeed * dt
|
||||
local targetDir = self.targetDir
|
||||
|
||||
velocity.x = decay.x * velocity.x + self.accelXY * maxSpeed * targetDir.x
|
||||
velocity.y = decay.y * velocity.y + self.accelXY * maxSpeed * targetDir.y
|
||||
velocity.z = decay.z * velocity.z
|
||||
+ self.accelXY * self.maxSpeedZ * targetDir.z * dt
|
||||
self:UpdateNoiseVelocity()
|
||||
velocity = velocity + self.noise * dt
|
||||
|
||||
if (velocity:LengthSqr() > self.maxSpeedSqr) then
|
||||
velocity:Normalize()
|
||||
velocity:Mul(self.maxSpeed)
|
||||
end
|
||||
phys:SetVelocity(velocity)
|
||||
|
||||
local angles = self:GetAngles()
|
||||
self.accelAnglular.x =
|
||||
angDiff(self.faceAngles.r, angles.r) * self.turnSpeed * dt
|
||||
self.accelAnglular.y =
|
||||
angDiff(self.faceAngles.p, angles.p) * self.turnSpeed * dt
|
||||
self.accelAnglular.z =
|
||||
angDiff(self.faceAngles.y, angles.y) * self.turnSpeed * dt
|
||||
phys:AddAngleVelocity(
|
||||
self.accelAnglular - phys:GetAngleVelocity() * self.angleDecay
|
||||
)
|
||||
|
||||
-- Makes the spotlight motion more smooth.
|
||||
if (IsValid(self.spotlight)) then
|
||||
self.spotlight:SetAngles(self:GetAngles())
|
||||
end
|
||||
|
||||
self.lastPhys = CurTime()
|
||||
end
|
||||
|
||||
function ENT:Die(dmgInfo)
|
||||
local force = dmgInfo and dmgInfo:GetDamageForce() or Vector(0, 0, 50)
|
||||
self:GibBreakClient(force)
|
||||
|
||||
local effect = EffectData()
|
||||
effect:SetStart(self:GetPos())
|
||||
effect:SetOrigin(self:GetPos())
|
||||
effect:SetMagnitude(0)
|
||||
effect:SetScale(0.5)
|
||||
effect:SetColor(25)
|
||||
effect:SetEntity(self)
|
||||
util.Effect("Explosion", effect, true, true)
|
||||
|
||||
self:EmitSound("NPC_SScanner.Die")
|
||||
self:Remove()
|
||||
end
|
||||
|
||||
function ENT:CreateDamageSmoke()
|
||||
if (IsValid(self.smoke)) then return end
|
||||
|
||||
self.smoke = ents.Create("env_smoketrail")
|
||||
self.smoke:SetParent(self)
|
||||
self.smoke:SetLocalPos(vector_origin)
|
||||
self.smoke:SetKeyValue("spawnrate", 5)
|
||||
self.smoke:SetKeyValue("opacity", 1)
|
||||
self.smoke:SetKeyValue("lifetime", 1)
|
||||
self.smoke:SetKeyValue("startcolor", "200 200 200")
|
||||
self.smoke:SetKeyValue("startsize", 5)
|
||||
self.smoke:SetKeyValue("endsize", 20)
|
||||
self.smoke:SetKeyValue("spawnradius", 10)
|
||||
self.smoke:SetKeyValue("minspeed", 5)
|
||||
self.smoke:SetKeyValue("maxspeed", 10)
|
||||
self.smoke:Spawn()
|
||||
self.smoke:Activate()
|
||||
end
|
||||
|
||||
function ENT:RemoveDamageSmoke()
|
||||
if (IsValid(self.smoke)) then
|
||||
self.smoke:Remove()
|
||||
end
|
||||
end
|
||||
|
||||
function ENT:DoDamageSound()
|
||||
-- smoke trail when damaged (env_smoketrail)
|
||||
local critical = self.maxHealth * 0.25
|
||||
if (self.lastHealth >= critical and self.health <= critical) then
|
||||
self:CreateDamageSmoke()
|
||||
self:EmitSound(self.sirenSound)
|
||||
elseif ((self.nextPainSound or 0) < CurTime()) then
|
||||
self.nextPainSound = CurTime() + 0.5
|
||||
|
||||
local painSound = table.Random(self.painSounds)
|
||||
self:EmitSound(painSound)
|
||||
end
|
||||
end
|
||||
|
||||
function ENT:OnTakeDamage(dmgInfo)
|
||||
self.lastHealth = self.health
|
||||
self.health = self.health - dmgInfo:GetDamage()
|
||||
|
||||
if (self.health <= 0) then
|
||||
self:Die(dmgInfo)
|
||||
else
|
||||
local pilot = self:GetPilot()
|
||||
if (IsValid(pilot)) then
|
||||
pilot:SetHealth(self.health)
|
||||
end
|
||||
self:DoDamageSound()
|
||||
end
|
||||
end
|
||||
|
||||
function ENT:OnRemove()
|
||||
self:DisableSpotlight()
|
||||
self:RemoveDamageSmoke()
|
||||
self:EjectPilot()
|
||||
end
|
||||
@@ -0,0 +1,52 @@
|
||||
--[[
|
||||
| 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 = "Scanner"
|
||||
ENT.Category = "HL2 RP"
|
||||
ENT.Spawnable = true
|
||||
ENT.AdminOnly = true
|
||||
ENT.AutomaticFrameAdvance = true
|
||||
|
||||
ENT.maxSpeed = 125
|
||||
ENT.maxSpeedZ = 50
|
||||
ENT.maxSpeedSqr = ENT.maxSpeed ^ 2
|
||||
ENT.minHoverPush = Vector(0, 0, 0.4)
|
||||
ENT.minHoverHeight = Vector(0, 0, 20)
|
||||
ENT.velocityDecay = Vector(0.975,0.975,0.95)
|
||||
ENT.accelXY = 0
|
||||
ENT.accelZ = 0
|
||||
ENT.noise = Vector(0, 0, 0)
|
||||
ENT.angleDecay = 0.2
|
||||
ENT.turnSpeed = 30
|
||||
ENT.faceAngles = Angle(0, 0, 0)
|
||||
ENT.accelAnglular = Vector(0, 0, 0)
|
||||
ENT.spotlightLength = 128
|
||||
ENT.spotlightWidth = 25
|
||||
ENT.spotlightEnableShadows = true
|
||||
ENT.spotlightNear = 1
|
||||
ENT.spotlightFar = 512
|
||||
ENT.spotlightFOV = 60
|
||||
ENT.spotlightLocalAngles = Angle(7.5, 0, 0)
|
||||
ENT.spotlightHDRColorScale = 0.67
|
||||
ENT.maxHealth = 100
|
||||
|
||||
function ENT:SpawnFunction(client, trace, className)
|
||||
local entity = ents.Create(className)
|
||||
entity:SetPos(trace.HitPos + Vector(0, 0, 32))
|
||||
entity:Spawn()
|
||||
entity:SetPilotEntity(client)
|
||||
|
||||
return entity
|
||||
end
|
||||
|
||||
function ENT:SetupDataTables()
|
||||
self:NetworkVar("Entity", 0, "Pilot")
|
||||
end
|
||||
45
gamemodes/darkrp/plugins/scannerplugin/sh_plugin.lua
Normal file
45
gamemodes/darkrp/plugins/scannerplugin/sh_plugin.lua
Normal file
@@ -0,0 +1,45 @@
|
||||
--[[
|
||||
| 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
|
||||
|
||||
PLUGIN.name = "Scanner Conversion"
|
||||
PLUGIN.author = "Madeon | Chessnut"
|
||||
PLUGIN.description = "A conversion of the NS Scanner plugin to IX."
|
||||
|
||||
ix.config.Add("pictureDelay", 15, "How often scanners can take pictures.", nil, {
|
||||
category = PLUGIN.name,
|
||||
data = {min = 0, max = 60}
|
||||
})
|
||||
|
||||
ix.lang.AddTable("english", {
|
||||
scannerPrepDownload = "Görsel indirme almaya hazırlanın..."
|
||||
})
|
||||
|
||||
ix.lang.AddTable("spanish", {
|
||||
scannerPrepDownload = "Prepárate para recibir una descarga visual..."
|
||||
})
|
||||
|
||||
local playerMeta = FindMetaTable("Player")
|
||||
|
||||
function playerMeta:IsScanner()
|
||||
return IsValid(self.ixScanner)
|
||||
end
|
||||
|
||||
if (CLIENT) then
|
||||
PLUGIN.PICTURE_WIDTH = 580
|
||||
PLUGIN.PICTURE_HEIGHT = 420
|
||||
end
|
||||
|
||||
ix.util.Include("sv_photos.lua")
|
||||
ix.util.Include("cl_photos.lua")
|
||||
ix.util.Include("sv_hooks.lua")
|
||||
ix.util.Include("cl_hooks.lua")
|
||||
185
gamemodes/darkrp/plugins/scannerplugin/sv_hooks.lua
Normal file
185
gamemodes/darkrp/plugins/scannerplugin/sv_hooks.lua
Normal file
@@ -0,0 +1,185 @@
|
||||
--[[
|
||||
| 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
|
||||
local IsValid = IsValid
|
||||
|
||||
function PLUGIN:GetHookCallPriority(hook)
|
||||
if (hook == "PostPlayerLoadout") then
|
||||
return 0
|
||||
end
|
||||
end
|
||||
|
||||
local SCANNER_SOUNDS = {
|
||||
"npc/scanner/scanner_blip1.wav",
|
||||
"npc/scanner/scanner_scan1.wav",
|
||||
"npc/scanner/scanner_scan2.wav",
|
||||
"npc/scanner/scanner_scan4.wav",
|
||||
"npc/scanner/scanner_scan5.wav",
|
||||
"npc/scanner/combat_scan1.wav",
|
||||
"npc/scanner/combat_scan2.wav",
|
||||
"npc/scanner/combat_scan3.wav",
|
||||
"npc/scanner/combat_scan4.wav",
|
||||
"npc/scanner/combat_scan5.wav",
|
||||
"npc/scanner/cbot_servoscared.wav",
|
||||
"npc/scanner/cbot_servochatter.wav"
|
||||
}
|
||||
|
||||
function PLUGIN:CreateScanner(client, isClawScanner)
|
||||
if (IsValid(client.ixScn)) then
|
||||
return
|
||||
end
|
||||
|
||||
local entity = ents.Create("ix_scanner")
|
||||
if (not IsValid(entity)) then
|
||||
return
|
||||
end
|
||||
|
||||
for _, scanner in ipairs(ents.FindByClass("ix_scanner")) do
|
||||
if (scanner:GetPilot() == client) then
|
||||
scanner:SetPilot(NULL)
|
||||
end
|
||||
end
|
||||
|
||||
entity:SetPos(client:GetPos() + Vector(0, 0, 100))
|
||||
entity:SetAngles(client:GetAngles())
|
||||
entity:SetColor(client:GetColor())
|
||||
entity:Spawn()
|
||||
entity:Activate()
|
||||
entity:SetPilotEntity(client)
|
||||
entity:SetCollisionGroup(COLLISION_GROUP_WORLD)
|
||||
|
||||
if (isClawScanner) then
|
||||
entity:SetClawScanner()
|
||||
end
|
||||
|
||||
entity:SetNetVar("player", client)
|
||||
client.ixScn = entity
|
||||
|
||||
return entity
|
||||
end
|
||||
|
||||
function PLUGIN:PlayerSpawn(client)
|
||||
timer.Simple(0.1, function()
|
||||
if (IsValid(client.ixScn)) then
|
||||
client.ixScn.noRespawn = true
|
||||
client.ixScn.spawn = client:GetPos()
|
||||
client.ixScn:Remove()
|
||||
client.ixScn = nil
|
||||
client:SetViewEntity(NULL)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
function PLUGIN:PlayerLoadedCharacter(client)
|
||||
net.Start("ixScannerClearPicture")
|
||||
net.Send(client)
|
||||
end
|
||||
|
||||
function PLUGIN:DoPlayerDeath(client)
|
||||
if (IsValid(client.ixScn)) then
|
||||
client:AddDeaths(1)
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
function PLUGIN:PlayerDisconnected(client)
|
||||
if (IsValid(client.ixScn)) then
|
||||
client.ixScn.noRespawn = true
|
||||
client.ixScn:Remove()
|
||||
client.ixScn = nil
|
||||
end
|
||||
end
|
||||
|
||||
function PLUGIN:PlayerDeath(client)
|
||||
if (IsValid(client.ixScn) and client.ixScn.health > 0) then
|
||||
client.ixScn:Die()
|
||||
client.ixScn = nil
|
||||
end
|
||||
end
|
||||
|
||||
function PLUGIN:KeyPress(client, key)
|
||||
if (IsValid(client.ixScn) and (client.ixScnDelay or 0) < CurTime()) then
|
||||
local source
|
||||
|
||||
if (key == IN_USE) then
|
||||
source = table.Random(SCANNER_SOUNDS)
|
||||
client.ixScnDelay = CurTime() + 1.75
|
||||
elseif (key == IN_RELOAD) then
|
||||
source = "npc/scanner/scanner_talk"..math.random(1, 2)..".wav"
|
||||
client.ixScnDelay = CurTime() + 10
|
||||
elseif (key == IN_WALK) then
|
||||
if (client:GetViewEntity() == client.ixScn) then
|
||||
client:SetViewEntity(NULL)
|
||||
else
|
||||
client:SetViewEntity(client.ixScn)
|
||||
end
|
||||
end
|
||||
|
||||
if (source) then
|
||||
client.ixScn:EmitSound(source)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function PLUGIN:PlayerNoClip(client)
|
||||
if (IsValid(client.ixScn)) then
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
function PLUGIN:PlayerUse(client, entity)
|
||||
if (IsValid(client.ixScn)) then
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
function PLUGIN:CanPlayerReceiveScan(client, photographer)
|
||||
return client.HasActiveCombineMask and client:HasActiveCombineMask()
|
||||
end
|
||||
|
||||
function PLUGIN:PlayerSwitchFlashlight(client, enabled)
|
||||
local scanner = client.ixScn
|
||||
if (not IsValid(scanner)) then return end
|
||||
|
||||
if ((scanner.nextLightToggle or 0) >= CurTime()) then return false end
|
||||
scanner.nextLightToggle = CurTime() + 0.5
|
||||
|
||||
local pitch
|
||||
if (scanner:IsSpotlightOn()) then
|
||||
scanner:DisableSpotlight()
|
||||
pitch = 240
|
||||
else
|
||||
scanner:EnableSpotlight()
|
||||
pitch = 250
|
||||
end
|
||||
|
||||
scanner:EmitSound("npc/turret_floor/click1.wav", 50, pitch)
|
||||
return false
|
||||
end
|
||||
|
||||
function PLUGIN:PlayerFootstep(client)
|
||||
if (IsValid(client.ixScn)) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
function PLUGIN:PlayerRankChanged(client)
|
||||
if (IsValid(client.ixScn)) then
|
||||
client:Spawn()
|
||||
end
|
||||
end
|
||||
|
||||
function PLUGIN:PostPlayerXenforoGroupsUpdate(client)
|
||||
if (IsValid(client.ixScn)) then
|
||||
client:StripWeapons()
|
||||
end
|
||||
end
|
||||
56
gamemodes/darkrp/plugins/scannerplugin/sv_photos.lua
Normal file
56
gamemodes/darkrp/plugins/scannerplugin/sv_photos.lua
Normal file
@@ -0,0 +1,56 @@
|
||||
--[[
|
||||
| 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/
|
||||
--]]
|
||||
|
||||
util.AddNetworkString("ixScannerData")
|
||||
util.AddNetworkString("ixScannerPicture")
|
||||
util.AddNetworkString("ixScannerClearPicture")
|
||||
|
||||
net.Receive("ixScannerData", function(len, client)
|
||||
if (IsValid(client.ixScn) and client:GetViewEntity() == client.ixScn and (client.ixNextPic or 0) < CurTime()) then
|
||||
local delay = ix.config.Get("pictureDelay", 15)
|
||||
client.ixNextPic = CurTime() + delay - 1
|
||||
|
||||
local length = net.ReadUInt(16)
|
||||
local data = net.ReadData(length)
|
||||
|
||||
if (length != #data) then
|
||||
return
|
||||
end
|
||||
|
||||
local receivers = {}
|
||||
|
||||
for _, v in ipairs(player.GetAll()) do
|
||||
if (hook.Run("CanPlayerReceiveScan", v, client)) then
|
||||
receivers[#receivers + 1] = v
|
||||
v:EmitSound("npc/overwatch/radiovoice/scanner_visual.wav")
|
||||
end
|
||||
end
|
||||
|
||||
if (#receivers > 0) then
|
||||
net.Start("ixScannerData")
|
||||
net.WriteUInt(#data, 16)
|
||||
net.WriteData(data, #data)
|
||||
net.Send(receivers)
|
||||
|
||||
if (ix.combineNotify) then
|
||||
ix.combineNotify:AddNotification("LOG:// Receiving Visual Download from local Airwatch asset")
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
net.Receive("ixScannerPicture", function(length, client)
|
||||
if (not IsValid(client.ixScn)) then return end
|
||||
if (client:GetViewEntity() ~= client.ixScn) then return end
|
||||
if ((client.ixNextFlash or 0) >= CurTime()) then return end
|
||||
|
||||
client.ixNextFlash = CurTime() + 1
|
||||
client.ixScn:Flash()
|
||||
end)
|
||||
Reference in New Issue
Block a user