mirror of
https://github.com/lifestorm/wnsrc.git
synced 2025-12-17 05:43:46 +03:00
Upload
This commit is contained in:
346
gamemodes/ixhl2rp/entities/weapons/gmod_tool/shared.lua
Normal file
346
gamemodes/ixhl2rp/entities/weapons/gmod_tool/shared.lua
Normal file
@@ -0,0 +1,346 @@
|
||||
--[[
|
||||
| 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/
|
||||
--]]
|
||||
|
||||
|
||||
-- Variables that are used on both client and server
|
||||
|
||||
SWEP.PrintName = "Tool Gun"
|
||||
SWEP.Author = ""
|
||||
SWEP.Contact = ""
|
||||
SWEP.Purpose = ""
|
||||
SWEP.Instructions = ""
|
||||
|
||||
SWEP.ViewModel = "models/weapons/c_toolgun.mdl"
|
||||
SWEP.WorldModel = "models/weapons/w_toolgun.mdl"
|
||||
|
||||
SWEP.UseHands = true
|
||||
SWEP.Spawnable = true
|
||||
|
||||
-- Be nice, precache the models
|
||||
util.PrecacheModel( SWEP.ViewModel )
|
||||
util.PrecacheModel( SWEP.WorldModel )
|
||||
|
||||
-- Todo, make/find a better sound.
|
||||
-- SWEP.ShootSound = Sound( "Airboat.FireGunRevDown" )
|
||||
SWEP.ShootSound = Sound( "" )
|
||||
|
||||
SWEP.Tool = {}
|
||||
|
||||
SWEP.Primary.ClipSize = -1
|
||||
SWEP.Primary.DefaultClip = -1
|
||||
SWEP.Primary.Automatic = false
|
||||
SWEP.Primary.Ammo = "none"
|
||||
|
||||
SWEP.Secondary.ClipSize = -1
|
||||
SWEP.Secondary.DefaultClip = -1
|
||||
SWEP.Secondary.Automatic = false
|
||||
SWEP.Secondary.Ammo = "none"
|
||||
|
||||
SWEP.CanHolster = true
|
||||
SWEP.CanDeploy = true
|
||||
|
||||
function SWEP:InitializeTools()
|
||||
|
||||
local temp = {}
|
||||
|
||||
for k,v in pairs( self.Tool ) do
|
||||
|
||||
temp[k] = table.Copy( v )
|
||||
temp[k].SWEP = self
|
||||
temp[k].Owner = self.Owner
|
||||
temp[k].Weapon = self.Weapon
|
||||
temp[k]:Init()
|
||||
|
||||
end
|
||||
|
||||
self.Tool = temp
|
||||
|
||||
end
|
||||
|
||||
function SWEP:SetupDataTables()
|
||||
|
||||
self:NetworkVar( "Entity", 0, "TargetEntity1" )
|
||||
self:NetworkVar( "Entity", 1, "TargetEntity2" )
|
||||
self:NetworkVar( "Entity", 2, "TargetEntity3" )
|
||||
self:NetworkVar( "Entity", 3, "TargetEntity4" )
|
||||
|
||||
end
|
||||
|
||||
-- Convenience function to check object limits
|
||||
function SWEP:CheckLimit( str )
|
||||
return self:GetOwner():CheckLimit( str )
|
||||
end
|
||||
|
||||
function SWEP:Initialize()
|
||||
|
||||
self:SetHoldType( "revolver" )
|
||||
|
||||
self:InitializeTools()
|
||||
|
||||
-- We create these here. The problem is that these are meant to be constant values.
|
||||
-- in the toolmode they're not because some tools can be automatic while some tools aren't.
|
||||
-- Since this is a global table it's shared between all instances of the gun.
|
||||
-- By creating new tables here we're making it so each tool has its own instance of the table
|
||||
-- So changing it won't affect the other tools.
|
||||
|
||||
self.Primary = {
|
||||
ClipSize = -1,
|
||||
DefaultClip = -1,
|
||||
Automatic = false,
|
||||
Ammo = "none"
|
||||
}
|
||||
|
||||
self.Secondary = {
|
||||
ClipSize = -1,
|
||||
DefaultClip = -1,
|
||||
Automatic = false,
|
||||
Ammo = "none"
|
||||
}
|
||||
|
||||
end
|
||||
|
||||
function SWEP:OnRestore()
|
||||
|
||||
self:InitializeTools()
|
||||
|
||||
end
|
||||
|
||||
function SWEP:Precache()
|
||||
|
||||
util.PrecacheSound( self.ShootSound )
|
||||
|
||||
end
|
||||
|
||||
function SWEP:Reload()
|
||||
|
||||
-- This makes the reload a semi-automatic thing rather than a continuous thing
|
||||
if ( !self.Owner:KeyPressed( IN_RELOAD ) ) then return end
|
||||
|
||||
local mode = self:GetMode()
|
||||
local trace = self.Owner:GetEyeTrace()
|
||||
if ( !trace.Hit ) then return end
|
||||
|
||||
local tool = self:GetToolObject()
|
||||
if ( !tool ) then return end
|
||||
|
||||
tool:CheckObjects()
|
||||
|
||||
-- Does the server setting say it's ok?
|
||||
if ( !tool:Allowed() ) then return end
|
||||
|
||||
-- Ask the gamemode if it's ok to do this
|
||||
if ( !gamemode.Call( "CanTool", self.Owner, trace, mode ) ) then return end
|
||||
|
||||
if ( !tool:Reload( trace ) ) then return end
|
||||
|
||||
self:DoShootEffect( trace.HitPos, trace.HitNormal, trace.Entity, trace.PhysicsBone, IsFirstTimePredicted() )
|
||||
|
||||
end
|
||||
|
||||
-- Returns the mode we're in
|
||||
function SWEP:GetMode()
|
||||
|
||||
return self.Mode
|
||||
|
||||
end
|
||||
|
||||
-- Think does stuff every frame
|
||||
function SWEP:Think()
|
||||
|
||||
self.Mode = self.Owner:GetInfo( "gmod_toolmode" )
|
||||
|
||||
local tool = self:GetToolObject()
|
||||
if ( !tool ) then return end
|
||||
|
||||
tool:CheckObjects()
|
||||
|
||||
self.last_mode = self.current_mode
|
||||
self.current_mode = self.Mode
|
||||
|
||||
-- Release ghost entities if we're not allowed to use this new mode?
|
||||
if ( !tool:Allowed() ) then
|
||||
self:GetToolObject( self.last_mode ):ReleaseGhostEntity()
|
||||
return
|
||||
end
|
||||
|
||||
if ( self.last_mode != self.current_mode ) then
|
||||
|
||||
if ( !self:GetToolObject( self.last_mode ) ) then return end
|
||||
|
||||
-- We want to release the ghost entity just in case
|
||||
self:GetToolObject( self.last_mode ):Holster()
|
||||
|
||||
end
|
||||
|
||||
self.Primary.Automatic = tool.LeftClickAutomatic or false
|
||||
self.Secondary.Automatic = tool.RightClickAutomatic or false
|
||||
self.RequiresTraceHit = tool.RequiresTraceHit or true
|
||||
|
||||
tool:Think()
|
||||
|
||||
end
|
||||
|
||||
-- The shoot effect
|
||||
function SWEP:DoShootEffect( hitpos, hitnormal, entity, physbone, bFirstTimePredicted )
|
||||
|
||||
self:EmitSound( self.ShootSound )
|
||||
self:SendWeaponAnim( ACT_VM_PRIMARYATTACK ) -- View model animation
|
||||
|
||||
-- There's a bug with the model that's causing a muzzle to
|
||||
-- appear on everyone's screen when we fire this animation.
|
||||
self.Owner:SetAnimation( PLAYER_ATTACK1 ) -- 3rd Person Animation
|
||||
|
||||
if ( !bFirstTimePredicted ) then return end
|
||||
|
||||
--[[
|
||||
|
||||
local effectdata = EffectData()
|
||||
effectdata:SetOrigin( hitpos )
|
||||
effectdata:SetNormal( hitnormal )
|
||||
effectdata:SetEntity( entity )
|
||||
effectdata:SetAttachment( physbone )
|
||||
util.Effect( "selection_indicator", effectdata )
|
||||
|
||||
|
||||
|
||||
local effectdata = EffectData()
|
||||
effectdata:SetOrigin( hitpos )
|
||||
effectdata:SetStart( self.Owner:GetShootPos() )
|
||||
effectdata:SetAttachment( 1 )
|
||||
effectdata:SetEntity( self )
|
||||
util.Effect( "ToolTracer", effectdata )
|
||||
|
||||
--]]
|
||||
|
||||
end
|
||||
|
||||
if (SERVER) then
|
||||
ix.log.AddType("toolgunFired", function(client, name)
|
||||
return string.format("%s has fired a toolgun with the name: %s", client:GetName(), name)
|
||||
end)
|
||||
end
|
||||
|
||||
-- Trace a line then send the result to a mode function
|
||||
function SWEP:PrimaryAttack()
|
||||
|
||||
local mode = self:GetMode()
|
||||
local tr = util.GetPlayerTrace( self.Owner )
|
||||
tr.mask = bit.bor( CONTENTS_SOLID, CONTENTS_MOVEABLE, CONTENTS_MONSTER, CONTENTS_WINDOW, CONTENTS_DEBRIS, CONTENTS_GRATE, CONTENTS_AUX )
|
||||
local trace = util.TraceLine( tr )
|
||||
if ( !trace.Hit ) then return end
|
||||
|
||||
local tool = self:GetToolObject()
|
||||
if ( !tool ) then return end
|
||||
|
||||
tool:CheckObjects()
|
||||
|
||||
-- Does the server setting say it's ok?
|
||||
if ( !tool:Allowed() ) then return end
|
||||
|
||||
-- Ask the gamemode if it's ok to do this
|
||||
if ( !gamemode.Call( "CanTool", self.Owner, trace, mode ) ) then return end
|
||||
if (SERVER) then
|
||||
ix.log.Add(self:GetOwner(), "toolgunFired", self:GetMode())
|
||||
end
|
||||
|
||||
if ( !tool:LeftClick( trace ) ) then return end
|
||||
|
||||
self:DoShootEffect( trace.HitPos, trace.HitNormal, trace.Entity, trace.PhysicsBone, IsFirstTimePredicted() )
|
||||
end
|
||||
|
||||
function SWEP:SecondaryAttack()
|
||||
|
||||
local mode = self:GetMode()
|
||||
local tr = util.GetPlayerTrace( self.Owner )
|
||||
tr.mask = bit.bor( CONTENTS_SOLID, CONTENTS_MOVEABLE, CONTENTS_MONSTER, CONTENTS_WINDOW, CONTENTS_DEBRIS, CONTENTS_GRATE, CONTENTS_AUX )
|
||||
local trace = util.TraceLine( tr )
|
||||
if ( !trace.Hit ) then return end
|
||||
|
||||
local tool = self:GetToolObject()
|
||||
if ( !tool ) then return end
|
||||
|
||||
tool:CheckObjects()
|
||||
|
||||
-- Ask the gamemode if it's ok to do this
|
||||
if ( !tool:Allowed() ) then return end
|
||||
if ( !gamemode.Call( "CanTool", self.Owner, trace, mode ) ) then return end
|
||||
|
||||
if ( !tool:RightClick( trace ) ) then return end
|
||||
|
||||
self:DoShootEffect( trace.HitPos, trace.HitNormal, trace.Entity, trace.PhysicsBone, IsFirstTimePredicted() )
|
||||
|
||||
end
|
||||
|
||||
function SWEP:Holster()
|
||||
|
||||
-- Just do what the SWEP wants to do if there's no tool
|
||||
if ( !self:GetToolObject() ) then return self.CanHolster end
|
||||
|
||||
local CanHolster = self:GetToolObject():Holster()
|
||||
if ( CanHolster ~= nil ) then return CanHolster end
|
||||
|
||||
return self.CanHolster
|
||||
|
||||
end
|
||||
|
||||
-- Delete ghosts here in case the weapon gets deleted all of a sudden somehow
|
||||
function SWEP:OnRemove()
|
||||
|
||||
if ( !self:GetToolObject() ) then return end
|
||||
|
||||
self:GetToolObject():ReleaseGhostEntity()
|
||||
|
||||
end
|
||||
|
||||
|
||||
-- This will remove any ghosts when a player dies and drops the weapon
|
||||
function SWEP:OwnerChanged()
|
||||
|
||||
if ( !self:GetToolObject() ) then return end
|
||||
|
||||
self:GetToolObject():ReleaseGhostEntity()
|
||||
|
||||
end
|
||||
|
||||
-- Deploy
|
||||
function SWEP:Deploy()
|
||||
|
||||
-- Just do what the SWEP wants to do if there is no tool
|
||||
if ( !self:GetToolObject() ) then return self.CanDeploy end
|
||||
|
||||
self:GetToolObject():UpdateData()
|
||||
|
||||
local CanDeploy = self:GetToolObject():Deploy()
|
||||
if ( CanDeploy ~= nil ) then return CanDeploy end
|
||||
|
||||
return self.CanDeploy
|
||||
|
||||
end
|
||||
|
||||
function SWEP:GetToolObject( tool )
|
||||
|
||||
local mode = tool or self:GetMode()
|
||||
|
||||
if ( !self.Tool[ mode ] ) then return false end
|
||||
|
||||
return self.Tool[ mode ]
|
||||
|
||||
end
|
||||
|
||||
function SWEP:FireAnimationEvent( pos, ang, event, options )
|
||||
|
||||
-- Disables animation based muzzle event
|
||||
if ( event == 21 ) then return true end
|
||||
-- Disable thirdperson muzzle flash
|
||||
if ( event == 5003 ) then return true end
|
||||
|
||||
end
|
||||
|
||||
include( "stool.lua" )
|
||||
162
gamemodes/ixhl2rp/entities/weapons/gmod_tool/stools/paint.lua
Normal file
162
gamemodes/ixhl2rp/entities/weapons/gmod_tool/stools/paint.lua
Normal file
@@ -0,0 +1,162 @@
|
||||
--[[
|
||||
| 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/
|
||||
--]]
|
||||
|
||||
|
||||
TOOL.Category = "Render"
|
||||
TOOL.Name = "#tool.paint.name"
|
||||
|
||||
TOOL.LeftClickAutomatic = true
|
||||
TOOL.RightClickAutomatic = true
|
||||
TOOL.RequiresTraceHit = true
|
||||
|
||||
TOOL.ClientConVar[ "decal" ] = "Blood"
|
||||
|
||||
TOOL.Information = {
|
||||
{ name = "left" },
|
||||
{ name = "right" },
|
||||
{ name = "reload" }
|
||||
}
|
||||
|
||||
local function PlaceDecal( ply, ent, data )
|
||||
|
||||
if ( !IsValid( ent ) && !ent:IsWorld() ) then return end
|
||||
|
||||
local bone = ent:GetPhysicsObjectNum( data.bone or 0 )
|
||||
if ( !IsValid( bone ) ) then bone = ent end
|
||||
|
||||
if ( SERVER ) then
|
||||
util.Decal( data.decal, bone:LocalToWorld( data.Pos1 ), bone:LocalToWorld( data.Pos2 ), ply )
|
||||
|
||||
local i = ent.DecalCount or 0
|
||||
i = i + 1
|
||||
duplicator.StoreEntityModifier( ent, "decal" .. i, data )
|
||||
ent.DecalCount = i
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--
|
||||
-- Register decal duplicator
|
||||
--
|
||||
for i = 1, 32 do
|
||||
|
||||
duplicator.RegisterEntityModifier( "decal" .. i, function( ply, ent, data )
|
||||
timer.Simple( i * 0.05, function() PlaceDecal( ply, ent, data ) end )
|
||||
end )
|
||||
|
||||
end
|
||||
|
||||
function TOOL:Reload( trace )
|
||||
if ( !IsValid( trace.Entity ) ) then return false end
|
||||
|
||||
trace.Entity:RemoveAllDecals()
|
||||
|
||||
if ( SERVER ) then
|
||||
for i = 1, 32 do
|
||||
duplicator.ClearEntityModifier( trace.Entity, "decal" .. i )
|
||||
end
|
||||
trace.Entity.DecalCount = nil
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
function TOOL:LeftClick( trace )
|
||||
|
||||
return self:RightClick( trace, true )
|
||||
|
||||
end
|
||||
|
||||
function TOOL:RightClick( trace, bNoDelay )
|
||||
|
||||
local decal = self:GetClientInfo( "decal" )
|
||||
|
||||
local Pos1 = trace.HitPos + trace.HitNormal
|
||||
local Pos2 = trace.HitPos - trace.HitNormal
|
||||
|
||||
local Bone = trace.Entity:GetPhysicsObjectNum( trace.PhysicsBone or 0 )
|
||||
if ( !IsValid( Bone ) ) then Bone = trace.Entity end
|
||||
|
||||
Pos1 = Bone:WorldToLocal( Pos1 )
|
||||
Pos2 = Bone:WorldToLocal( Pos2 )
|
||||
|
||||
PlaceDecal( self:GetOwner(), trace.Entity, { Pos1 = Pos1, Pos2 = Pos2, bone = trace.PhysicsBone, decal = decal } )
|
||||
|
||||
if ( bNoDelay ) then
|
||||
self:GetWeapon():SetNextPrimaryFire( CurTime() + 0.05 )
|
||||
self:GetWeapon():SetNextSecondaryFire( CurTime() + 0.05 )
|
||||
else
|
||||
self:GetWeapon():SetNextPrimaryFire( CurTime() + 0.2 )
|
||||
self:GetWeapon():SetNextSecondaryFire( CurTime() + 0.2 )
|
||||
end
|
||||
|
||||
return false
|
||||
|
||||
end
|
||||
|
||||
game.AddDecal( "Eye", "decals/eye" )
|
||||
game.AddDecal( "Dark", "decals/dark" )
|
||||
game.AddDecal( "Smile", "decals/smile" )
|
||||
game.AddDecal( "Light", "decals/light" )
|
||||
game.AddDecal( "Cross", "decals/cross" )
|
||||
game.AddDecal( "Nought", "decals/nought" )
|
||||
game.AddDecal( "Noughtsncrosses", "decals/noughtsncrosses" )
|
||||
|
||||
list.Add( "PaintMaterials", "Eye" )
|
||||
list.Add( "PaintMaterials", "Smile" )
|
||||
list.Add( "PaintMaterials", "Light" )
|
||||
list.Add( "PaintMaterials", "Dark" )
|
||||
list.Add( "PaintMaterials", "Blood" )
|
||||
list.Add( "PaintMaterials", "YellowBlood" )
|
||||
list.Add( "PaintMaterials", "Impact.Metal" )
|
||||
list.Add( "PaintMaterials", "Scorch" )
|
||||
list.Add( "PaintMaterials", "BeerSplash" )
|
||||
list.Add( "PaintMaterials", "ExplosiveGunshot" )
|
||||
list.Add( "PaintMaterials", "BirdPoop" )
|
||||
list.Add( "PaintMaterials", "PaintSplatPink" )
|
||||
list.Add( "PaintMaterials", "PaintSplatGreen" )
|
||||
list.Add( "PaintMaterials", "PaintSplatBlue" )
|
||||
list.Add( "PaintMaterials", "ManhackCut" )
|
||||
list.Add( "PaintMaterials", "FadingScorch" )
|
||||
list.Add( "PaintMaterials", "Antlion.Splat" )
|
||||
list.Add( "PaintMaterials", "Splash.Large" )
|
||||
list.Add( "PaintMaterials", "BulletProof" )
|
||||
list.Add( "PaintMaterials", "GlassBreak" )
|
||||
list.Add( "PaintMaterials", "Impact.Sand" )
|
||||
list.Add( "PaintMaterials", "Impact.BloodyFlesh" )
|
||||
list.Add( "PaintMaterials", "Impact.Antlion" )
|
||||
list.Add( "PaintMaterials", "Impact.Glass" )
|
||||
list.Add( "PaintMaterials", "Impact.Wood" )
|
||||
list.Add( "PaintMaterials", "Impact.Concrete" )
|
||||
list.Add( "PaintMaterials", "Noughtsncrosses" )
|
||||
list.Add( "PaintMaterials", "Nought" )
|
||||
list.Add( "PaintMaterials", "Cross" )
|
||||
|
||||
function TOOL.BuildCPanel( CPanel )
|
||||
|
||||
-- Remove duplicates.
|
||||
local Options = {}
|
||||
for id, str in pairs( list.Get( "PaintMaterials" ) ) do
|
||||
if ( !table.HasValue( Options, str ) ) then
|
||||
table.insert( Options, str )
|
||||
end
|
||||
end
|
||||
|
||||
table.sort( Options )
|
||||
|
||||
local listbox = CPanel:AddControl( "ListBox", { Label = "#tool.paint.texture", Height = 17 + table.Count( Options ) * 17 } )
|
||||
for k, decal in pairs( Options ) do
|
||||
local line = listbox:AddLine( decal )
|
||||
line.data = { paint_decal = decal }
|
||||
|
||||
if ( GetConVarString( "paint_decal" ) == tostring( decal ) ) then line:SetSelected( true ) end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,105 @@
|
||||
--[[
|
||||
| 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/
|
||||
--]]
|
||||
|
||||
|
||||
TOOL.Category = "HL2RP Staff QoL"
|
||||
TOOL.Name = "NPC Spawner Editor"
|
||||
TOOL.RequiresTraceHit = true
|
||||
|
||||
TOOL.Information = {
|
||||
{ name = "left" },
|
||||
{ name = "right" },
|
||||
{ name = "reload" }
|
||||
}
|
||||
function TOOL:GetPlayerBoundsTrace()
|
||||
local client = self:GetOwner()
|
||||
|
||||
return util.TraceLine({
|
||||
start = client:GetShootPos(),
|
||||
endpos = client:GetShootPos() + client:GetForward() * 96,
|
||||
filter = client
|
||||
})
|
||||
end
|
||||
function TOOL:LeftClick( trace )
|
||||
|
||||
|
||||
if (SERVER) then
|
||||
if !CAMI.PlayerHasAccess(client, "Helix - Basic Admin Commands") then return false end
|
||||
|
||||
local entity = trace.Entity
|
||||
if !entity or entity and !IsValid(entity) then return end
|
||||
if !self.GetOwner then return end
|
||||
if !self:GetOwner() then return end
|
||||
if !IsValid(self:GetOwner()) then return end
|
||||
if entity:GetClass() != "ix_npcspawner" then return end
|
||||
entity:Use(self:GetOwner())
|
||||
end
|
||||
end
|
||||
function TOOL:RightClick( trace )
|
||||
local entity = trace.Entity
|
||||
local client = self:GetOwner()
|
||||
if !entity or entity and !IsValid(entity) then
|
||||
client.npcEditStart = nil
|
||||
client.npcEnt = nil
|
||||
return
|
||||
end
|
||||
if !self.GetOwner then return end
|
||||
if !self:GetOwner() then return end
|
||||
if !IsValid(self:GetOwner()) then return end
|
||||
if entity:GetClass() != "ix_npcspawner" then return end
|
||||
if client.npcEditStart then
|
||||
client.npcEditStart = nil
|
||||
client.npcEnt = nil
|
||||
else
|
||||
client.npcEditStart = entity:GetPos() + (entity:GetForward() * -60 + entity:GetRight()*-40 + entity:GetUp()*128)
|
||||
client.npcEnt = entity
|
||||
end
|
||||
end
|
||||
function TOOL:Reload(trace)
|
||||
local client = self:GetOwner()
|
||||
if !CAMI.PlayerHasAccess(client, "Helix - Basic Admin Commands") then return false end
|
||||
if !self.GetOwner then return end
|
||||
if !self:GetOwner() then return end
|
||||
if !IsValid(self:GetOwner()) then return end
|
||||
if !client.npcEditStart or !client.npcEnt then return end
|
||||
local tr = util.TraceLine({
|
||||
start = client:GetShootPos(),
|
||||
endpos = client:GetShootPos() + client:GetForward() * 96,
|
||||
filter = client
|
||||
})
|
||||
client.npcEnt:SetSpawnPosStart(client.npcEditStart)
|
||||
client.npcEnt:SetSpawnPosEnd(tr.HitPos)
|
||||
|
||||
client.npcEditStart = nil
|
||||
client.npcEnt = nil
|
||||
end
|
||||
if CLIENT then
|
||||
hook.Add("PostDrawTranslucentRenderables", "NPCSpawnEdit", function(bDepth, bSkybox)
|
||||
if ( bSkybox ) then return end
|
||||
if LocalPlayer().npcEditStart then
|
||||
local tr = util.TraceLine({
|
||||
start = LocalPlayer():GetShootPos(),
|
||||
endpos = LocalPlayer():GetShootPos() + LocalPlayer():GetForward() * 96,
|
||||
filter = LocalPlayer()
|
||||
})
|
||||
local center, min, max = LocalPlayer().npcEnt:SpawnAreaPosition(LocalPlayer().npcEditStart, tr.HitPos)
|
||||
local color = Color(255, 255, 255, 255)
|
||||
|
||||
render.DrawWireframeBox(center, angle_zero, min, max, color)
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
language.Add( "Tool.sh_npcspawnedit.name", "NPC Spawner Configurator" )
|
||||
language.Add( "Tool.sh_npcspawnedit.desc", "You can edit NPC spawner entities with it." )
|
||||
language.Add( "Tool.sh_npcspawnedit.left", "Open spawner menu" )
|
||||
language.Add( "Tool.sh_npcspawnedit.right", "Edit spawner area bounds. Click again to stop changing bounds." )
|
||||
language.Add( "Tool.sh_npcspawnedit.reload", "Save your area bound changes." )
|
||||
end
|
||||
@@ -0,0 +1,74 @@
|
||||
--[[
|
||||
| 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/
|
||||
--]]
|
||||
|
||||
|
||||
TOOL.Category = "HL2RP Staff QoL"
|
||||
TOOL.Name = "Panel Add"
|
||||
TOOL.RequiresTraceHit = true
|
||||
|
||||
TOOL.ClientConVar[ "url" ] = ""
|
||||
TOOL.ClientConVar[ "scale" ] = 1
|
||||
TOOL.ClientConVar[ "brightness" ] = 100
|
||||
|
||||
TOOL.Information = {
|
||||
{ name = "left" },
|
||||
{ name = "right" },
|
||||
{ name = "reload" }
|
||||
}
|
||||
|
||||
function TOOL:LeftClick( trace )
|
||||
if (SERVER) then
|
||||
if !CAMI.PlayerHasAccess(self:GetOwner(), "Helix - Manage Panels") then return false end
|
||||
|
||||
local position = trace.HitPos
|
||||
local angles = trace.HitNormal:Angle()
|
||||
angles:RotateAroundAxis(angles:Up(), 90)
|
||||
angles:RotateAroundAxis(angles:Forward(), 90)
|
||||
|
||||
if !ix.plugin.list then return end
|
||||
if !ix.plugin.list["3dpanel"] then return end
|
||||
if !ix.plugin.list["3dpanel"].AddPanel then return end
|
||||
|
||||
local url = self:GetClientInfo( "url", "" )
|
||||
local scale = self:GetClientNumber( "scale", 0 )
|
||||
local brightness = self:GetClientNumber( "brightness", 0 )
|
||||
|
||||
ix.plugin.list["3dpanel"]:AddPanel(position + angles:Up() * 0.1, angles, url, scale, brightness)
|
||||
|
||||
return "@panelAdded"
|
||||
end
|
||||
end
|
||||
|
||||
function TOOL:RightClick( trace )
|
||||
if !ix.plugin.list then return end
|
||||
if !ix.plugin.list["3dpanel"] then return end
|
||||
if !ix.plugin.list["3dpanel"].RemovePanel then return end
|
||||
|
||||
local position = trace.HitPos
|
||||
-- Remove the panel(s) and get the amount removed.
|
||||
local amount = ix.plugin.list["3dpanel"]:RemovePanel(position, false)
|
||||
|
||||
return "@panelRemoved", amount
|
||||
end
|
||||
|
||||
function TOOL.BuildCPanel( CPanel )
|
||||
CPanel:AddControl( "Header", { Description = "Enter URL!" } )
|
||||
CPanel:AddControl( "textbox", { Label = "URL", Command = "sh_paneladd_url", Help = false } )
|
||||
CPanel:AddControl( "Slider", { Label = "Scale", Command = "sh_paneladd_scale", Type = "Float", Min = 0.001, Max = 5, Help = false } )
|
||||
CPanel:AddControl( "Slider", { Label = "Brightness", Command = "sh_paneladd_brightness", Type = "Float", Min = 0, Max = 255, Help = false } )
|
||||
end
|
||||
|
||||
if CLIENT then
|
||||
language.Add( "Tool.sh_paneladd.name", "Panel Add" )
|
||||
language.Add( "Tool.sh_paneladd.desc", "Same as /paneladd" )
|
||||
language.Add( "Tool.sh_paneladd.left", "Primary: Add Panel" )
|
||||
language.Add( "Tool.sh_paneladd.right", "Right Click: Remove Panel" )
|
||||
language.Add( "Tool.sh_paneladd.reload", "Nothing." )
|
||||
end
|
||||
@@ -0,0 +1,84 @@
|
||||
--[[
|
||||
| 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/
|
||||
--]]
|
||||
|
||||
|
||||
TOOL.Category = "HL2RP Staff QoL"
|
||||
TOOL.Name = "Persist"
|
||||
TOOL.RequiresTraceHit = true
|
||||
|
||||
TOOL.Information = {
|
||||
{ name = "left" },
|
||||
{ name = "right" },
|
||||
{ name = "reload" }
|
||||
}
|
||||
|
||||
local function GetRealModel(entity)
|
||||
return entity:GetClass() == "prop_effect" and entity.AttachedEntity:GetModel() or entity:GetModel()
|
||||
end
|
||||
|
||||
function TOOL:LeftClick( trace )
|
||||
if (SERVER) then
|
||||
if !CAMI.PlayerHasAccess(client, "Helix - Basic Admin Commands") then return false end
|
||||
|
||||
local entity = trace.Entity
|
||||
if !entity or entity and !IsValid(entity) then return end
|
||||
if entity:IsPlayer() or entity:IsVehicle() or entity.bNoPersist then return end
|
||||
if !self.GetOwner then return end
|
||||
if !self:GetOwner() then return end
|
||||
if !IsValid(self:GetOwner()) then return end
|
||||
if !ix.plugin.list then return end
|
||||
if !ix.plugin.list["persistence"] then return end
|
||||
if !ix.plugin.list["persistence"].stored then return end
|
||||
|
||||
local lampCount = 0
|
||||
|
||||
for _, v in pairs(ix.plugin.list["persistence"].stored) do
|
||||
if IsValid(v) and v:GetClass() == "gmod_lamp" then
|
||||
lampCount = lampCount + 1
|
||||
end
|
||||
end
|
||||
|
||||
if !entity:GetNetVar("Persistent") then
|
||||
if entity:GetClass() == "gmod_lamp" and lampCount >= ix.config.Get("maxLamps", 1) then
|
||||
return self:GetOwner():Notify("Max persisted lamps reached.")
|
||||
end
|
||||
|
||||
ix.plugin.list["persistence"].stored[#ix.plugin.list["persistence"].stored + 1] = entity
|
||||
|
||||
entity:SetNetVar("Persistent", true)
|
||||
ix.saveEnts:SaveEntity(entity)
|
||||
|
||||
ix.log.Add(self:GetOwner(), "persist", GetRealModel(entity), true)
|
||||
self:GetOwner():Notify("You persisted this entity.")
|
||||
else
|
||||
for k, v in ipairs(ix.plugin.list["persistence"].stored) do
|
||||
if (v == entity) then
|
||||
table.remove(ix.plugin.list["persistence"].stored, k)
|
||||
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
entity:SetNetVar("Persistent", false)
|
||||
ix.saveEnts:DeleteEntity(entity)
|
||||
|
||||
ix.log.Add(self:GetOwner(), "persist", GetRealModel(entity), false)
|
||||
self:GetOwner():Notify("You unpersisted this entity.")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if CLIENT then
|
||||
language.Add( "Tool.sh_persist.name", "Persist" )
|
||||
language.Add( "Tool.sh_persist.desc", "Same as persist in context menu" )
|
||||
language.Add( "Tool.sh_persist.left", "Primary: Persist/Unpersist" )
|
||||
language.Add( "Tool.sh_persist.right", "Nothing." )
|
||||
language.Add( "Tool.sh_persist.reload", "Nothing." )
|
||||
end
|
||||
@@ -0,0 +1,79 @@
|
||||
--[[
|
||||
| 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/
|
||||
--]]
|
||||
|
||||
|
||||
TOOL.Category = "HL2RP Staff QoL"
|
||||
TOOL.Name = "Text Add"
|
||||
TOOL.RequiresTraceHit = true
|
||||
|
||||
TOOL.ClientConVar[ "text" ] = ""
|
||||
TOOL.ClientConVar[ "scale" ] = 1
|
||||
|
||||
TOOL.Information = {
|
||||
{ name = "left" },
|
||||
{ name = "right" },
|
||||
{ name = "reload" }
|
||||
}
|
||||
|
||||
function TOOL:LeftClick( trace )
|
||||
if (SERVER) then
|
||||
if !CAMI.PlayerHasAccess(self:GetOwner(), "Helix - Basic Admin Commands") then return false end
|
||||
|
||||
local position = trace.HitPos
|
||||
local angles = trace.HitNormal:Angle()
|
||||
angles:RotateAroundAxis(angles:Up(), 90)
|
||||
angles:RotateAroundAxis(angles:Forward(), 90)
|
||||
|
||||
if !ix.plugin.list then return end
|
||||
if !ix.plugin.list["3dtext"] then return end
|
||||
if !ix.plugin.list["3dtext"].AddText then return end
|
||||
|
||||
local text = self:GetClientInfo( "text", "" )
|
||||
local scale = self:GetClientNumber( "scale", 0 )
|
||||
|
||||
local index = ix.plugin.list["3dtext"]:AddText(position + angles:Up() * 0.1, angles, text, scale)
|
||||
|
||||
undo.Create("ix3dText")
|
||||
undo.SetPlayer(self:GetOwner())
|
||||
undo.AddFunction(function()
|
||||
if (ix.plugin.list["3dtext"]:RemoveTextByID(index)) then
|
||||
ix.log.Add(self:GetOwner(), "undo3dText")
|
||||
end
|
||||
end)
|
||||
undo.Finish()
|
||||
|
||||
return "@textAdded"
|
||||
end
|
||||
end
|
||||
|
||||
function TOOL:RightClick( trace )
|
||||
if !ix.plugin.list then return end
|
||||
if !ix.plugin.list["3dtext"] then return end
|
||||
if !ix.plugin.list["3dtext"].RemoveText then return end
|
||||
|
||||
local position = trace.HitPos + trace.HitNormal * 2
|
||||
local amount = ix.plugin.list["3dtext"]:RemoveText(position, false)
|
||||
|
||||
return "@textRemoved", amount
|
||||
end
|
||||
|
||||
function TOOL.BuildCPanel( CPanel )
|
||||
CPanel:AddControl( "Header", { Description = "Enter Text!" } )
|
||||
CPanel:AddControl( "textbox", { Label = "Text", Command = "sh_textadd_text", Help = false } )
|
||||
CPanel:AddControl( "Slider", { Label = "Scale", Command = "sh_textadd_scale", Type = "Float", Min = 0.001, Max = 5, Help = false } )
|
||||
end
|
||||
|
||||
if CLIENT then
|
||||
language.Add( "Tool.sh_textadd.name", "Text Add" )
|
||||
language.Add( "Tool.sh_textadd.desc", "Same as /textadd" )
|
||||
language.Add( "Tool.sh_textadd.left", "Primary: Add Text" )
|
||||
language.Add( "Tool.sh_textadd.right", "Right Click: Remove Text." )
|
||||
language.Add( "Tool.sh_textadd.reload", "Nothing." )
|
||||
end
|
||||
Reference in New Issue
Block a user